From be4ad8623089fc246733f6e863dfb84303918540 Mon Sep 17 00:00:00 2001 From: BFE Engineering Date: Sat, 17 Oct 2026 17:51:08 -0600 Subject: [PATCH] qemu: power-signal test waits for the trap install (#22) init-power-signals-test.sh slept a fixed 0.5 s before sending each signal. On a loaded runner the shell had not installed its traps yet, so SIGTERM took its default action and the case failed with nothing written. Each case now polls /proc//status until SigCgt has the signal's bit (10 s hang backstop, WARDEN_TEST_TRAP_WAIT_S), and fails clearly if the handler never appears. Regression: a case whose handler install is held back 1.5 s (fails on the old fixed sleep), plus a check that the wait gives up on a shell without a handler. Fixes #22 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG --- qemu/tests/init-power-signals-test.sh | 52 ++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/qemu/tests/init-power-signals-test.sh b/qemu/tests/init-power-signals-test.sh index b11f05e..5a557b6 100755 --- a/qemu/tests/init-power-signals-test.sh +++ b/qemu/tests/init-power-signals-test.sh @@ -3,7 +3,9 @@ # busybox reboot/poweroff/halt, which only signal PID 1. Runs the real # helpers from qemu/rootfs/etc/warden-lib.sh in a plain sh with stub # commands, idles it the way /sbin/init does, sends each signal and requires -# the matching action within two seconds. +# the matching action within two seconds. Each signal goes out only once the +# shell has its handler installed (SigCgt), so a slow start cannot turn the +# signal's default action into a false failure (bfe-core1106-sdk#22). set -uo pipefail # Job control: each case's shell leads its own process group, so cleanup can # kill the whole group. An orphaned `sleep 3600` would otherwise keep this @@ -16,15 +18,41 @@ SH="${WARDEN_TEST_SH:-sh}" WORK="$(mktemp -d)" || exit 1 trap 'rm -rf "$WORK"' EXIT FAIL=0 +# Hang backstop for the handler install; a quiet host takes milliseconds. +TRAP_WAIT_S="${WARDEN_TEST_TRAP_WAIT_S:-10}" -run_case() { # run_case