From fbee1d1380866ed6076e2d6054e94f9940da6c63 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 18 Apr 2024 14:09:20 -0700 Subject: [PATCH 1/4] check-kmod-load-unload-after-playback: new playback_subtest() Extract new playback_subtest() function to de-duplicate. Pure clean-up, zero functional change. Signed-off-by: Marc Herbert --- test-case/check-kmod-load-unload-after-playback.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test-case/check-kmod-load-unload-after-playback.sh b/test-case/check-kmod-load-unload-after-playback.sh index 2a946753..a893dff9 100755 --- a/test-case/check-kmod-load-unload-after-playback.sh +++ b/test-case/check-kmod-load-unload-after-playback.sh @@ -62,8 +62,13 @@ 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() +{ + "$case_dir"/check-playback.sh -l 1 -t $tplg -d $pb_duration || die "aplay check failed" +} + +playback_subtest for counter in $(seq 1 $loop_cnt) do @@ -91,6 +96,5 @@ do fi done - "$case_dir"/check-playback.sh -l 1 -t $tplg -d $pb_duration || - die "aplay check failed" + playback_subtest done From 98971f6de187f8e19e11a2c44c6e5c649545166a Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 5 Apr 2024 14:00:29 -0700 Subject: [PATCH 2/4] hijack.sh: extract new print_test_result_exit() function Extract new print_test_result_exit() function from exit handler(). This make it possible for some "light-weight" tests like verify-kernel-boot-log.sh to not depend on the heavy and start_test() and exit handler machinery. Signed-off-by: Marc Herbert --- case-lib/hijack.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index 0f3f7940..b8f43c1a 100644 --- a/case-lib/hijack.sh +++ b/case-lib/hijack.sh @@ -179,6 +179,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 +205,7 @@ function func_exit_handler() ;; esac - builtin exit $exit_status + builtin exit "$exit_status" } SUDO_LEVEL="" From 412292bd79638dd7414588c578ec3a597e3cc1bb Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 18 Apr 2024 14:27:24 -0700 Subject: [PATCH 3/4] check-kmod-load-unload-after-playback: disable logging in subtest This unblocks #1170 and allows "installing" the func_exit_handler() trap in start_test() which will allow making start_test() optional. Signed-off-by: Marc Herbert --- test-case/check-kmod-load-unload-after-playback.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test-case/check-kmod-load-unload-after-playback.sh b/test-case/check-kmod-load-unload-after-playback.sh index a893dff9..849c1a3f 100755 --- a/test-case/check-kmod-load-unload-after-playback.sh +++ b/test-case/check-kmod-load-unload-after-playback.sh @@ -64,7 +64,10 @@ fi playback_subtest() { - "$case_dir"/check-playback.sh -l 1 -t $tplg -d $pb_duration || + # 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" } From dd906bfa4ea65636f463215e639c343a2ef601ae Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 5 Apr 2024 13:56:21 -0700 Subject: [PATCH 4/4] lib.sh: install func_exit_handler() from start_test() func_exit_handler() makes sense only when used with start_test() start_test() is a "mandatory" right now because it's invoked from lib.sh. But this is wrong because it should be possible to import lib.sh functions without actually running anything and it's causing various issues like sof_remove.sh depending on the firmware being loaded, see discussion in #1169 This commit will make it possible NOT to use start_test(). Signed-off-by: Marc Herbert --- case-lib/hijack.sh | 1 - case-lib/lib.sh | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index b8f43c1a..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() { 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