From 7a8d4e2c6b7f559df02c6a9bfb5c7ed856bf8f4c Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 24 Apr 2022 13:19:10 +0200 Subject: [PATCH] test: wait for Finit to reach runlevel 2 before starting tests Signed-off-by: Joachim Wiberg --- test/tenv/lib.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/tenv/lib.sh b/test/tenv/lib.sh index b60c22ae..3508bc4b 100755 --- a/test/tenv/lib.sh +++ b/test/tenv/lib.sh @@ -168,12 +168,24 @@ log "$color_reset" 'Setup of test environment done, waiting for Finit ...' '' finit_pid=$(retry "pgrep -P $finit_ppid") -if type test_setup > /dev/null 2>&1 ; then - test_setup -fi - #tty=/dev/$(texec cat /sys/class/tty/console/active) #texec cat "$tty" & # Allow Finit to start up properly before launching the test -sleep 2 +i=0 +while [ $i -lt 10 ]; do + echo "Checking runlevel ..." + lvl=$(texec sh -c "initctl runlevel | awk '{print \$2;}'") + echo "Runlevel is $lvl" + if [ $lvl -eq 2 ]; then + say 'Reached runlevel 2, releasing test.' + break; + fi + echo "Waiting for Finit ..." + i=$((i + 1)) + sleep 1 +done + +if type test_setup > /dev/null 2>&1 ; then + test_setup +fi