diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index 0f3f7940..a489f982 100644 --- a/case-lib/hijack.sh +++ b/case-lib/hijack.sh @@ -2,7 +2,6 @@ SUDO_CMD=$(command -v sudo) -trap 'func_exit_handler $?' EXIT # Overwrite other functions' exit to perform environment cleanup function func_exit_handler() { @@ -179,6 +178,13 @@ function func_exit_handler() fi } + print_test_result_exit $exit_status +} + +print_test_result_exit() +{ + local exit_status="$1" + # We must always print some 'Test Result' otherwise some callers # will time out. These strings must match (at least) Jenkins' # expectations, see internal sof-framework/clsTestCase.py @@ -198,7 +204,7 @@ function func_exit_handler() ;; esac - builtin exit $exit_status + builtin exit "$exit_status" } SUDO_LEVEL="" diff --git a/case-lib/lib.sh b/case-lib/lib.sh index b5756442..2db58f79 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -77,6 +77,9 @@ start_test() return 0 } + # func_exit_handler() is in hijack.sh + trap 'func_exit_handler $?' EXIT + if test -z "$MAX_WAIT_FW_LOADING"; then local _pltf; _pltf=$("$SCRIPT_HOME/tools/sof-dump-status.py" -p) case "$_pltf" in diff --git a/test-case/check-kmod-load-unload-after-playback.sh b/test-case/check-kmod-load-unload-after-playback.sh index 2a946753..849c1a3f 100755 --- a/test-case/check-kmod-load-unload-after-playback.sh +++ b/test-case/check-kmod-load-unload-after-playback.sh @@ -62,8 +62,16 @@ if [ ${OPT_VAL['p']} -eq 1 ];then func_lib_disable_pulseaudio fi -"$case_dir"/check-playback.sh -l 1 -t $tplg -d $pb_duration || +playback_subtest() +{ + # Disable logging with -s because subtests don't invoke func_exit_handler() which + # can leave loggers behind (and hang rmmod) + # Also, we don't want two (concurrent!?) sets of logs for the same test. + "$case_dir"/check-playback.sh -l 1 -t $tplg -d $pb_duration -s || die "aplay check failed" +} + +playback_subtest for counter in $(seq 1 $loop_cnt) do @@ -91,6 +99,5 @@ do fi done - "$case_dir"/check-playback.sh -l 1 -t $tplg -d $pb_duration || - die "aplay check failed" + playback_subtest done