From a225efc554a7d2902de15f5e562198ce62f4dedc Mon Sep 17 00:00:00 2001 From: Chao Song Date: Tue, 13 Apr 2021 12:19:23 +0800 Subject: [PATCH] sof-test: include test interval in kernel check point The sof-framework will add a 5-second test interval between two test cases. This patch makes the kernel check point include this test interval to avoid log loss. And also rename func_lib_setup_kernel_check_point to setup_kernel_check_point, because the prefix doesn't provide much information. Signed-off-by: Chao Song --- case-lib/config.sh | 5 +++++ case-lib/lib.sh | 9 +++++---- test-case/check-capture.sh | 2 +- test-case/check-fw-echo-reference.sh | 2 +- test-case/check-ipc-flood.sh | 2 +- test-case/check-keyword-detection.sh | 2 +- test-case/check-kmod-load-unload.sh | 6 +++--- test-case/check-pause-release-suspend-resume.sh | 2 +- test-case/check-pause-resume.sh | 2 +- test-case/check-playback.sh | 2 +- test-case/check-runtime-pm-double-active.sh | 2 +- test-case/check-runtime-pm-status.sh | 2 +- test-case/check-signal-stop-start.sh | 2 +- test-case/check-smart-amplifier.sh | 2 +- test-case/check-suspend-resume-with-audio.sh | 2 +- test-case/check-suspend-resume.sh | 2 +- test-case/check-xrun-injection.sh | 2 +- test-case/multiple-pause-resume.sh | 2 +- test-case/multiple-pipeline.sh | 2 +- test-case/simultaneous-playback-capture.sh | 2 +- test-case/test-speaker.sh | 2 +- test-case/volume-basic-test.sh | 2 +- 22 files changed, 32 insertions(+), 26 deletions(-) diff --git a/case-lib/config.sh b/case-lib/config.sh index 2dd1075b..2929b4a4 100644 --- a/case-lib/config.sh +++ b/case-lib/config.sh @@ -56,3 +56,8 @@ SUDO_LEVEL=${SUDO_LEVEL:-} # pipelines will be filtered out. Example: # # NO_HDMI_MODE=true + +# Test interval between two test cases, the default value is 5 seconds +# in CI, which is controlled by sof-framework. In manual run, user can +# override the default value. +SOF_TEST_INTERVAL=${SOF_TEST_INTERVAL:-5} diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 5a287fd5..85123960 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -40,10 +40,11 @@ if [ ! "$SOFCARD" ]; then awk '/sof-[a-z]/ && $1 ~ /^[0-9]+$/ { $1=$1; print $1; exit 0;}') fi -func_lib_setup_kernel_checkpoint() +setup_kernel_check_point() { - # shellcheck disable=SC2034 # external script will use it - KERNEL_CHECKPOINT=$(date +%s) + # Make the check point $SOF_TEST_INTERVAL second(s) earlier to avoid log loss. + # Note this may lead to an error caused by one test appear in the next one. + KERNEL_CHECKPOINT=$(($(date +%s) - $SOF_TEST_INTERVAL)) } # This function adds a fake error to dmesg (which is always saved by @@ -342,5 +343,5 @@ is_sof_used() journalctl_cmd() { journalctl -k -q --no-pager --utc --output=short-monotonic \ - --no-hostname "$@" + --no-hostname "$@" } diff --git a/test-case/check-capture.sh b/test-case/check-capture.sh index 093a2937..a448948f 100755 --- a/test-case/check-capture.sh +++ b/test-case/check-capture.sh @@ -59,7 +59,7 @@ file_prefix=${OPT_VAL['f']} [[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect -func_lib_setup_kernel_checkpoint +setup_kernel_check_point func_lib_check_sudo func_pipeline_export "$tplg" "type:capture & ${OPT_VAL['S']}" diff --git a/test-case/check-fw-echo-reference.sh b/test-case/check-fw-echo-reference.sh index c7801bb4..4a66748b 100755 --- a/test-case/check-fw-echo-reference.sh +++ b/test-case/check-fw-echo-reference.sh @@ -44,7 +44,7 @@ frequency=${OPT_VAL['f']} [[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect func_pipeline_export "$tplg" "echo:any" -func_lib_setup_kernel_checkpoint +setup_kernel_check_point if [ "$PIPELINE_COUNT" != "2" ]; then die "Only detect $PIPELINE_COUNT pipeline(s) from topology, but two are needed" diff --git a/test-case/check-ipc-flood.sh b/test-case/check-ipc-flood.sh index e3993a9c..216c8ab3 100755 --- a/test-case/check-ipc-flood.sh +++ b/test-case/check-ipc-flood.sh @@ -44,7 +44,7 @@ do # cleanup dmesg buffer for each iteration sudo dmesg -c > /dev/null # set up timestamp for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point dlogi "===== [$i/$loop_cnt] loop Begin =====" dlogc "sudo bash -c 'echo $lpc_loop_cnt > $ipc_flood_dfs'" sudo bash -c "'echo $lpc_loop_cnt > $ipc_flood_dfs'" diff --git a/test-case/check-keyword-detection.sh b/test-case/check-keyword-detection.sh index 9e4d85da..bec4c1da 100755 --- a/test-case/check-keyword-detection.sh +++ b/test-case/check-keyword-detection.sh @@ -55,7 +55,7 @@ duration=${OPT_VAL['d']} [[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect func_pipeline_export "$tplg" "kpbm:any" -func_lib_setup_kernel_checkpoint +setup_kernel_check_point if test "$PIPELINE_COUNT" != "1"; then die "detected $PIPELINE_COUNT wov pipeline(s) from topology, but 1 is needed" diff --git a/test-case/check-kmod-load-unload.sh b/test-case/check-kmod-load-unload.sh index bea03401..aedaf317 100755 --- a/test-case/check-kmod-load-unload.sh +++ b/test-case/check-kmod-load-unload.sh @@ -33,7 +33,7 @@ OPT_NAME['p']='pulseaudio' OPT_DESC['p']='disable pulseaudio on the test proce OPT_HAS_ARG['p']=0 OPT_VAL['p']=1 func_opt_parse_option "$@" -func_lib_setup_kernel_checkpoint +setup_kernel_check_point loop_cnt=${OPT_VAL['l']} @@ -48,7 +48,7 @@ for idx in $(seq 1 $loop_cnt) do dlogi "===== Starting iteration $idx of $loop_cnt =====" ## - 1: remove module section - func_lib_setup_kernel_checkpoint + setup_kernel_check_point # After module removal, it takes about 10s for "aplay -l" to show # device list, within this 10s, it shows "no soundcard found". Here @@ -78,7 +78,7 @@ do sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" || die "error found after kmod unload is real error, failing" - func_lib_setup_kernel_checkpoint + setup_kernel_check_point dlogi "run kmod/sof_insert.sh" sudo sof_insert.sh || { # FIXME: don't exit the status of dloge(). Use die() diff --git a/test-case/check-pause-release-suspend-resume.sh b/test-case/check-pause-release-suspend-resume.sh index 40135285..ab389f0d 100755 --- a/test-case/check-pause-release-suspend-resume.sh +++ b/test-case/check-pause-release-suspend-resume.sh @@ -110,7 +110,7 @@ esac [[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect -func_lib_setup_kernel_checkpoint +setup_kernel_check_point dlogi "Entering audio stream expect script with: $cmd -D $pcm -r $rate -c $channel -f $fmt -vv -i $dummy_file -q" dlogi "Will enter suspend-resume cycle during paused period of audio stream process" diff --git a/test-case/check-pause-resume.sh b/test-case/check-pause-resume.sh index da1265d7..ffcc0378 100755 --- a/test-case/check-pause-resume.sh +++ b/test-case/check-pause-resume.sh @@ -81,7 +81,7 @@ func_pipeline_export "$tplg" "type:$test_mode & ${OPT_VAL['S']}" for idx in $(seq 0 $((PIPELINE_COUNT - 1))) do # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point channel=$(func_pipeline_parse_value "$idx" channel) rate=$(func_pipeline_parse_value "$idx" rate) fmt=$(func_pipeline_parse_value "$idx" fmt) diff --git a/test-case/check-playback.sh b/test-case/check-playback.sh index abf3c133..d29621ae 100755 --- a/test-case/check-playback.sh +++ b/test-case/check-playback.sh @@ -67,7 +67,7 @@ else dlogi "using $file as playback source" fi -func_lib_setup_kernel_checkpoint +setup_kernel_check_point func_lib_check_sudo func_pipeline_export "$tplg" "type:playback & ${OPT_VAL['S']}" diff --git a/test-case/check-runtime-pm-double-active.sh b/test-case/check-runtime-pm-double-active.sh index e21e0ab3..8dd79a7d 100755 --- a/test-case/check-runtime-pm-double-active.sh +++ b/test-case/check-runtime-pm-double-active.sh @@ -89,7 +89,7 @@ do for i in $(seq 1 $loop_count) do # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point dlogi "===== Iteration $i of $loop_count for $pcm =====" # playback or capture device - check status dlogc "$cmd -D $dev -r $rate -c $channel -f $fmt $dummy_file -q" diff --git a/test-case/check-runtime-pm-status.sh b/test-case/check-runtime-pm-status.sh index 8d4a7697..6bfad273 100755 --- a/test-case/check-runtime-pm-status.sh +++ b/test-case/check-runtime-pm-status.sh @@ -83,7 +83,7 @@ do for i in $(seq 1 $loop_count) do # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point dlogi "===== Iteration $i of $loop_count for $pcm =====" # playback or capture device - check status dlogc "$cmd -D $dev -r $rate -c $channel -f $fmt $dummy_file -q" diff --git a/test-case/check-signal-stop-start.sh b/test-case/check-signal-stop-start.sh index ec734505..bcfdcd53 100755 --- a/test-case/check-signal-stop-start.sh +++ b/test-case/check-signal-stop-start.sh @@ -56,7 +56,7 @@ case $test_mode in ;; esac -func_lib_setup_kernel_checkpoint +setup_kernel_check_point func_stop_start_pipeline() { diff --git a/test-case/check-smart-amplifier.sh b/test-case/check-smart-amplifier.sh index a3702a69..633b0306 100755 --- a/test-case/check-smart-amplifier.sh +++ b/test-case/check-smart-amplifier.sh @@ -59,7 +59,7 @@ tplg=${OPT_VAL['t']} [[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect func_pipeline_export "$tplg" "smart_amp:any" -func_lib_setup_kernel_checkpoint +setup_kernel_check_point [ "$PIPELINE_COUNT" == "2" ] || die "Only detect $PIPELINE_COUNT pipeline(s) from topology, but two are needed" diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index 8228f844..e1199c8f 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -91,7 +91,7 @@ fi for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) do # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point # store local checkpoint as we have sub-test LOCAL_CHECK_POINT="$KERNEL_CHECKPOINT" channel=$(func_pipeline_parse_value $idx channel) diff --git a/test-case/check-suspend-resume.sh b/test-case/check-suspend-resume.sh index 1af2a73a..6718a4e6 100755 --- a/test-case/check-suspend-resume.sh +++ b/test-case/check-suspend-resume.sh @@ -74,7 +74,7 @@ for i in $(seq 1 $loop_count) do dlogi "===== Round($i/$loop_count) =====" # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point sleep_count=$(cat /sys/power/wakeup_count) dlogc "Run the command: rtcwake -m mem -s ${sleep_lst[$i]}" sudo rtcwake -m mem -s ${sleep_lst[$i]} diff --git a/test-case/check-xrun-injection.sh b/test-case/check-xrun-injection.sh index 1a641f17..57b066cf 100755 --- a/test-case/check-xrun-injection.sh +++ b/test-case/check-xrun-injection.sh @@ -43,7 +43,7 @@ interval=${OPT_VAL['i']} [[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect -func_lib_setup_kernel_checkpoint +setup_kernel_check_point func_lib_check_sudo case $test_mode in diff --git a/test-case/multiple-pause-resume.sh b/test-case/multiple-pause-resume.sh index 809cad3d..58e85795 100755 --- a/test-case/multiple-pause-resume.sh +++ b/test-case/multiple-pause-resume.sh @@ -145,7 +145,7 @@ for i in $(seq 1 $loop_count) do dlogi "===== Loop count( $i / $loop_count ) =====" # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point for pipeline_combine_str in "${pipeline_combine_lst[@]}" do unset pid_lst diff --git a/test-case/multiple-pipeline.sh b/test-case/multiple-pipeline.sh index 445264eb..5721f30b 100755 --- a/test-case/multiple-pipeline.sh +++ b/test-case/multiple-pipeline.sh @@ -144,7 +144,7 @@ ps_checks() for i in $(seq 1 $loop_cnt) do # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point dlogi "===== Testing: (Loop: $i/$loop_cnt) =====" # start playback or capture: diff --git a/test-case/simultaneous-playback-capture.sh b/test-case/simultaneous-playback-capture.sh index 65801ba2..ccce40c5 100755 --- a/test-case/simultaneous-playback-capture.sh +++ b/test-case/simultaneous-playback-capture.sh @@ -69,7 +69,7 @@ func_error_exit() for i in $(seq 1 $loop_cnt) do # set up checkpoint for each iteration - func_lib_setup_kernel_checkpoint + setup_kernel_check_point dlogi "===== Testing: (Loop: $i/$loop_cnt) =====" # following sof-tplgreader, split 'both' pipelines into separate playback & capture pipelines, with playback occurring first for order in $(seq 0 2 $(expr $PIPELINE_COUNT - 1)) diff --git a/test-case/test-speaker.sh b/test-case/test-speaker.sh index 29ca21b9..19e52417 100755 --- a/test-case/test-speaker.sh +++ b/test-case/test-speaker.sh @@ -32,7 +32,7 @@ tplg=${OPT_VAL['t']} func_pipeline_export "$tplg" "type:playback" tcnt=${OPT_VAL['l']} -func_lib_setup_kernel_checkpoint +setup_kernel_check_point for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) do channel=$(func_pipeline_parse_value $idx channel) diff --git a/test-case/volume-basic-test.sh b/test-case/volume-basic-test.sh index 166695b0..dd2bce3b 100755 --- a/test-case/volume-basic-test.sh +++ b/test-case/volume-basic-test.sh @@ -62,7 +62,7 @@ dlogi "pgalist number = ${#pgalist[@]}" for i in $(seq 1 $maxloop) do - func_lib_setup_kernel_checkpoint + setup_kernel_check_point dlogi "===== Round($i/$maxloop) =====" # TODO: need to check command effect for i in "${pgalist[@]}"