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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-09-10 13:16:09 +02:00
1 parent b39a4498a3
commit ab554568b2
1 file changed
+10 -5
+10 -5
View File
@@ -226,7 +226,8 @@ wdstart()
wdkill() wdkill()
{ {
kill -KILL $wdpid say "Stopping test watchdog, pid $wdpid"
kill -KILL $wdpid
} }
teardown() teardown()
@@ -247,11 +248,15 @@ teardown()
log "$fg_red" 'TEST FAIL' '' log "$fg_red" 'TEST FAIL' ''
fi fi
say "Telling Finit to shut down (set -$-) ..."
set +e set +e
if [ -n "${finit_pid+x}" ]; then say "Telling Finit to shut down (set -$-) ..."
texec kill -SIGUSR2 1 while [ -n "${finit_pid+x}" ]; do
fi if ! kill -USR2 "${finit_pid}" 2>/dev/null; then
break
fi
say "Retrying shutdown ..."
sleep 1
done
say "Waiting for Finit to shut down ..." say "Waiting for Finit to shut down ..."
wait wait