From 256d486120faf4d133137a44a4faa8e17cdac36c Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Thu, 18 Jan 2024 11:04:10 -0800 Subject: [PATCH 1/2] tests: add timeout to wait_while() --- tests/10-events-interrupt.sh | 4 ++-- tests/shared_test_functions.sh | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/10-events-interrupt.sh b/tests/10-events-interrupt.sh index 5419a249..0e1ae75a 100644 --- a/tests/10-events-interrupt.sh +++ b/tests/10-events-interrupt.sh @@ -31,12 +31,12 @@ scenario_cmd() { ) & # Wait for the binary to initialize its signal handler - wait_while test ! -e "${pidfile}" + wait_while 0 test ! -e "${pidfile}" pid=$( cat "${pidfile}" ) # Signal and wait for the binary to finish writing the logfile kill -s USR1 "${pid}" - wait_while test ! -e "${flag_1}" + wait_while 0 test ! -e "${flag_1}" # Compare with good values setup_check "test-empty-events" diff --git a/tests/shared_test_functions.sh b/tests/shared_test_functions.sh index a37639a4..342f560f 100644 --- a/tests/shared_test_functions.sh +++ b/tests/shared_test_functions.sh @@ -22,8 +22,8 @@ # Look for ${cmd} in the ${PATH}, and ensure that it supports ${args}. # - has_pid(cmd): # Look for a ${cmd} in $(ps). -# - wait_while(func): -# Wait until ${func} returns non-zero. +# - wait_while(timeout, func): +# Wait up to ${timeout} milliseconds, or until ${func} returns non-zero. # - setup_check(description, check_prev): # Set up the below variables. # - expected_exitcode(expected, actual): @@ -133,11 +133,14 @@ has_pid() { return 1 } -## wait_while(func): +## wait_while(timeout, func): # Wait while ${func} returns 0. If ${msleep} is defined, use that to wait -# 100ms; otherwise, wait in 1 second increments. +# 100ms; otherwise, wait in 1 second increments. If ${timeout} is non-zero, +# return 1 if ${timeout} milliseconds have passed. wait_while() { _wait_while_ms=0 + _wait_while_timeout=$1 + shift 1 # Check for the ending condition while "$@"; do @@ -147,6 +150,15 @@ wait_while() { "${_wait_while_ms}" "$*" 1>&2 fi + # Bail if we've exceeded the timeout + if [ "${_wait_while_timeout}" -gt 0 ] && \ + [ "${_wait_while_ms}" -gt "${_wait_while_timeout}" ]; then + if [ "${VERBOSE}" -ne 0 ]; then + printf "Bail; timeout exceeded\n" 1>&2 + fi + return 1 + fi + # Wait using the appropriate binary if [ -n "${msleep:-}" ]; then "${msleep}" 100 From 606a6763e47440d612c63fcecc9217374da4f7c5 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Wed, 7 Feb 2024 10:08:12 -0800 Subject: [PATCH 2/2] build: allow CFLAGS_DEFAULT for libs For reference, see the "all:" target on line 26. This should have been part of: 2023-04-08 build: add LIBS variable ef148383988e4e2ee9a1d54495a6c75167f05863 and: 2018-06-28 build: add ability to generate top-level flag files 349592399703376673d3ccf443e501212baa2df0 --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index b376aa50..9adcc5f7 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,7 @@ toplevel: apisupport-config.h cflags-filter.sh \ # For "loop-back" building of a subdirectory .PHONY: buildsubdir buildsubdir: toplevel + export CFLAGS="$${CFLAGS:-${CFLAGS_DEFAULT}}"; \ . ./posix-flags.sh; \ . ./cpusupport-config.h; \ . ./cflags-filter.sh; \ @@ -75,6 +76,7 @@ buildsubdir: toplevel # For "loop-back" building of libraries .PHONY: libs libs: apisupport-config.h cflags-filter.sh cpusupport-config.h posix-flags.sh + export CFLAGS="$${CFLAGS:-${CFLAGS_DEFAULT}}"; \ . ./posix-flags.sh; \ . ./cpusupport-config.h; \ . ./cflags-filter.sh; \