From ab554568b2dcea5bacf2776dfbef29b5abce905a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 4 Aug 2023 22:07:22 +0200 Subject: [PATCH] test: handle very short tests that exit before reaching runlevel 2 Bootstrap-only tests that just verify basic functionality are often very short. This change handles that by retrying SIGUSR2 until Finit has had the chance to finalize bootstrap and enable signals. Signed-off-by: Joachim Wiberg --- test/lib/setup.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/lib/setup.sh b/test/lib/setup.sh index 6b1f6822..02ff115d 100755 --- a/test/lib/setup.sh +++ b/test/lib/setup.sh @@ -226,7 +226,8 @@ wdstart() wdkill() { - kill -KILL $wdpid + say "Stopping test watchdog, pid $wdpid" + kill -KILL $wdpid } teardown() @@ -247,11 +248,15 @@ teardown() log "$fg_red" 'TEST FAIL' '' fi - say "Telling Finit to shut down (set -$-) ..." set +e - if [ -n "${finit_pid+x}" ]; then - texec kill -SIGUSR2 1 - fi + say "Telling Finit to shut down (set -$-) ..." + while [ -n "${finit_pid+x}" ]; do + if ! kill -USR2 "${finit_pid}" 2>/dev/null; then + break + fi + say "Retrying shutdown ..." + sleep 1 + done say "Waiting for Finit to shut down ..." wait