From f4384714a2f33c23fb3120288c03324eef721e51 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 17 Feb 2022 19:18:27 -0800 Subject: [PATCH 1/2] lib.sh: add new poll_wait_for() function This will immediately be used for waiting until the firmware is loaded but is generic and will be useful in other places. Signed-off-by: Marc Herbert --- case-lib/lib.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 92541bd4..2798ae56 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -40,6 +40,41 @@ if [ ! "$SOFCARD" ]; then awk '/sof-[a-z]/ && $1 ~ /^[0-9]+$/ { $1=$1; print $1; exit 0;}') fi +# Arguments: +# +# - poll interval in secs +# - timeout in secs, rounded up to the next interval +# - command and arguments +# +poll_wait_for() +{ + test $# -ge 3 || + die "poll_wait_for() invoked with $# arguments" + + local ival="$1"; shift + local maxtime="$1"; shift + + printf "Polling '%s' every ${ival}s for ${maxtime}s\n" "$*" + + local waited=0 attempts=1 pass=true + while ! "$@"; do + if [ "$waited" -ge "$maxtime" ]; then + pass=false + break; + fi + sleep "$ival" + : $((attempts++)); waited=$((waited+ival)) + done + local timeinfo="${waited}s and ${attempts} attempts" + if $pass; then + printf "Completed '%s' after ${timeinfo}\n" "$*" + else + >&2 printf "Command '%s' timed out after ${timeinfo}\n" "$*" + fi + + $pass +} + setup_kernel_check_point() { # Make the check point $SOF_TEST_INTERVAL second(s) earlier to avoid From c1347be49c1d8ef305948d660931ee1b98020591 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 17 Feb 2022 19:23:09 -0800 Subject: [PATCH 2/2] check-kmod-load-unload: wait 10 seconds for firmware to boot Now that the test has been just fixed in commit 71a9ccac4ecfa, of course it started failing: https://sof-ci.01.org/sofpr/PR5383/build12069/devicetest/?model=BYT_MB_NOCODEC&testcase=check-kmod-load-unload-after-playback This proves the older version wasn't testing anything: classic case of "green failure" https://github.com/thesofproject/sof-test/issues?q=+label%3A%22False+Pass+%2F+green+failure%22+ Firmware does not boot instantly. We even have retries for when it fails: https://github.com/thesofproject/linux/pull/3255 https://github.com/thesofproject/linux/commit/2a3c9269474c So, poll journalctl for a maximum of 10 seconds before failing. Signed-off-by: Marc Herbert --- test-case/check-kmod-load-unload.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-case/check-kmod-load-unload.sh b/test-case/check-kmod-load-unload.sh index 28312df9..2e863078 100755 --- a/test-case/check-kmod-load-unload.sh +++ b/test-case/check-kmod-load-unload.sh @@ -91,7 +91,8 @@ do die "Found error(s) in kernel log after module insertion" dlogi "checking if firmware is loaded successfully" - if sof_firmware_boot_complete --since=@"$KERNEL_CHECKPOINT"; then + # Check every 1s for 10s + if poll_wait_for 1 10 sof_firmware_boot_complete --since=@"$KERNEL_CHECKPOINT"; then grep_firmware_info_in_logs --since=@"$KERNEL_CHECKPOINT" else die "Failed to load firmware after module insertion"