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
2023-09-10 13:16:09 +02:00
parent b39a4498a3
commit ab554568b2
+10 -5
View File
@@ -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