Skip to content

Commit

Permalink
Explicitly invoke start_test() in every test-case/*.sh
Browse files Browse the repository at this point in the history
Stop unconditionally imposing start_test() to everything sourcing lib.sh

This makes it possible to source lib.sh without running anything which
can be useful for debugging.

For now this should be a no-op for all tests except two files in `tools/` which
were never really "tests" in the first place:

- tools/kmod/sof_remove.sh
- tools/sof-kernel-log-check.sh

In these, start_test() never made sense it never really run thanks the
(awkward) "is_subtest()" escape.

There are other tests where start_test() should not be invoked either,
most notably test-case/verify-kernel-boot-log.sh in order to fix
thesofproject#1112 but this is a huge
commit already; one change at a time.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed May 1, 2024
1 parent 8ab82ba commit a82935b
Show file tree
Hide file tree
Showing 40 changed files with 81 additions and 5 deletions.
1 change: 0 additions & 1 deletion case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1024,4 +1024,3 @@ perf_analyze()
fi
}

start_test
2 changes: 2 additions & 0 deletions test-case/check-alsabat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ frequency=${OPT_VAL['F']}
sigmak=${OPT_VAL['k']}
frames=${OPT_VAL['n']}

start_test

if [ "$pcm_p" = "" ]||[ "$pcm_c" = "" ];
then
dloge "No playback or capture PCM is specified. Skip the alsabat test"
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-audio-equalizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ loop_cnt=${OPT_VAL['l']}
func_pipeline_export "$tplg" "eq:any"
sofcard=${SOFCARD:-0}

start_test

# Test equalizer
func_test_eq()
{
Expand Down
1 change: 1 addition & 0 deletions test-case/check-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ loop_cnt=${OPT_VAL['l']}
out_dir=${OPT_VAL['o']}
file_prefix=${OPT_VAL['f']}

start_test
logger_disabled || func_lib_start_log_collect

setup_kernel_check_point
Expand Down
1 change: 1 addition & 0 deletions test-case/check-fw-echo-reference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ loop_cnt=${OPT_VAL['l']}
frames=${OPT_VAL['n']}
frequency=${OPT_VAL['f']}

start_test
logger_disabled || func_lib_start_log_collect

func_pipeline_export "$tplg" "echo:any"
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-ipc-flood.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ lpc_loop_cnt=${OPT_VAL['c']}
ipc_flood_dfs=${OPT_VAL['f']}
loop_cnt=${OPT_VAL['l']}

start_test

sof-kernel-dump.sh | grep sof-audio | grep -q "Firmware debug" ||
skip_test "need debug version firmware"

Expand Down
1 change: 1 addition & 0 deletions test-case/check-keyword-detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ history_depth=${OPT_VAL['s']}
preamble_time=${OPT_VAL['p']}
duration=${OPT_VAL['d']}

start_test
logger_disabled || func_lib_start_log_collect

func_pipeline_export "$tplg" "kpb:any"
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-kmod-load-unload-after-playback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ tplg=${OPT_VAL['t']}
loop_cnt=${OPT_VAL['l']}
pb_duration=${OPT_VAL['d']}

start_test

func_pipeline_export "$tplg" "type:playback"

func_lib_check_sudo
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-kmod-load-unload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ OPT_HAS_ARG['p']=0 OPT_VAL['p']=1
func_opt_parse_option "$@"
setup_kernel_check_point

start_test

loop_cnt=${OPT_VAL['l']}

PATH="${PATH%%:*}/kmod:$PATH"
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-pause-release-suspend-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ sleep_period=${OPT_VAL['i']}
test_mode=${OPT_VAL['m']}
file_name=${OPT_VAL['F']}

start_test

case $test_mode in
"playback")
cmd=aplay
Expand Down
3 changes: 3 additions & 0 deletions test-case/check-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ file_name=${OPT_VAL['f']}
# configure random value range
rnd_min=${OPT_VAL['i']}
rnd_max=${OPT_VAL['a']}

start_test

rnd_range=$(( rnd_max - rnd_min ))
[[ $rnd_range -le 0 ]] && dlogw "Error random range scope [ min:$rnd_min - max:$rnd_max ]" && exit 2

Expand Down
1 change: 1 addition & 0 deletions test-case/check-performance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func_opt_parse_option "$@"
tplg=${OPT_VAL['t']}
duration=${OPT_VAL['d']}

start_test
logger_disabled || func_lib_start_log_collect

setup_kernel_check_point
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-playback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ duration=${OPT_VAL['d']}
loop_cnt=${OPT_VAL['l']}
file=${OPT_VAL['f']}


start_test
logger_disabled || func_lib_start_log_collect

# checking if source file exists
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-reboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ loop_count=${OPT_VAL['l']}
delay=${OPT_VAL['d']}
timeout=${OPT_VAL['t']}

start_test

# write the total & current count to the status file
status_log=$LOG_ROOT/status.txt
echo "$loop_count $(uname -r)" >> $status_log
Expand Down
3 changes: 3 additions & 0 deletions test-case/check-runtime-pm-double-active.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func_check_dsp_status()
func_opt_parse_option "$@"
tplg=${OPT_VAL['t']}
loop_count=${OPT_VAL['l']}

start_test

[[ -z $tplg ]] && dloge "Miss tplg file to run" && exit 2

[[ $(sof-dump-status.py --dsp_status 0) == "unsupported" ]] &&
Expand Down
3 changes: 3 additions & 0 deletions test-case/check-runtime-pm-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ setup_kernel_check_point

tplg=${OPT_VAL['t']}
loop_count=${OPT_VAL['l']}

start_test

[[ -z $tplg ]] && die "Miss tplg file to run"

[[ $(sof-dump-status.py --dsp_status 0) == "unsupported" ]] &&
Expand Down
1 change: 1 addition & 0 deletions test-case/check-signal-stop-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ count=${OPT_VAL['c']}
interval=${OPT_VAL['i']}
test_mode=${OPT_VAL['m']}

start_test
logger_disabled || func_lib_start_log_collect

case $test_mode in
Expand Down
1 change: 1 addition & 0 deletions test-case/check-smart-amplifier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ duration=${OPT_VAL['d']}
loop_cnt=${OPT_VAL['l']}
tplg=${OPT_VAL['t']}

start_test
logger_disabled || func_lib_start_log_collect

func_pipeline_export "$tplg" "smart_amp:any"
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-sof-logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ source "${TOPDIR}"/case-lib/lib.sh

func_opt_parse_option "$@"

start_test

# check sof-logger location
type -a sof-logger ||
die "sof-logger Not Installed!"
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-suspend-resume-with-audio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ setup_kernel_check_point
func_lib_check_sudo

tplg=${OPT_VAL['t']}

start_test
logger_disabled || func_lib_start_log_collect

# overwrite the subscript: test-case LOG_ROOT environment
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-suspend-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ OPT_HAS_ARG['r']=0 OPT_VAL['r']=0
func_opt_parse_option "$@"
func_lib_check_sudo

start_test

type=${OPT_VAL['T']}
# switch type
if [ "$type" ]; then
Expand Down
8 changes: 5 additions & 3 deletions test-case/check-userspace-cardinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ set -e
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

# check pulseaudio runs properly or not
func_lib_check_pa || die "Please check whether pulseaudio runs correctly or not"

func_opt_parse_option "$@"
setup_kernel_check_point

start_test

# check pulseaudio runs properly or not
func_lib_check_pa || die "Please check whether pulseaudio runs correctly or not"

: $((available_card=0))
while read -r card; do
# pactl list cards short format should be like:
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-userspace-paplay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ OPT_HAS_ARG['C']=1 OPT_VAL['C']=2
func_opt_parse_option "$@"
setup_kernel_check_point

start_test

round_cnt=${OPT_VAL['r']}
duration=${OPT_VAL['d']}
file=${OPT_VAL['f']}
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-userspace-parecord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ format=${OPT_VAL['F']}
rate=${OPT_VAL['R']}
channel=${OPT_VAL['C']}

start_test

[[ -e $file ]] || { dlogw "$file does not exist, use /dev/zero as dummy playback source" && file=/dev/null; }

# TODO: check the parameter is valid or not
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-volume-levels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ ARECORD_WAV1=$(mktemp --suffix=.wav)
ARECORD_WAV2=$(mktemp --suffix=.wav)
ARECORD_WAV3=$(mktemp --suffix=.wav)

start_test

#
# Main test procedure
#
Expand Down
1 change: 1 addition & 0 deletions test-case/check-xrun-injection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ test_mode=${OPT_VAL['m']}
count=${OPT_VAL['c']}
interval=${OPT_VAL['i']}

start_test
logger_disabled || func_lib_start_log_collect

setup_kernel_check_point
Expand Down
3 changes: 3 additions & 0 deletions test-case/multiple-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ loop_count=${OPT_VAL['l']}
rnd_min=${OPT_VAL['i']}
rnd_max=${OPT_VAL['a']}
rnd_range=$((rnd_max - rnd_min))

start_test

[[ $rnd_range -le 0 ]] && dlogw "Error random range scope [ min:$rnd_min - max:$rnd_max ]" && exit 2

tplg=${OPT_VAL['t']}
Expand Down
2 changes: 2 additions & 0 deletions test-case/multiple-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func_opt_parse_option "$@"
loop_cnt=${OPT_VAL['l']}
tplg=${OPT_VAL['t']}
f_arg=${OPT_VAL['f']}

start_test
logger_disabled || func_lib_start_log_collect

# skip the Echo Reference pipeline
Expand Down
3 changes: 3 additions & 0 deletions test-case/simultaneous-playback-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ tplg=${OPT_VAL['t']}
wait_time=${OPT_VAL['w']}
loop_cnt=${OPT_VAL['l']}

start_test

# get 'both' pcm, it means pcm have same id with different type
declare -A tmp_id_lst
id_lst_str=""
Expand All @@ -59,6 +61,7 @@ unset tmp_id_lst tplg_path
id_lst_str=${id_lst_str/,/} # remove 1st, which is not used
[[ ${#id_lst_str} -eq 0 ]] && dlogw "no pipeline with both playback and capture capabilities found in $tplg" && exit 2
func_pipeline_export "$tplg" "id:$id_lst_str"

logger_disabled || func_lib_start_log_collect

func_error_exit()
Expand Down
2 changes: 2 additions & 0 deletions test-case/test-socwatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ duration=${OPT_VAL['d']}
wait_time=${OPT_VAL['w']}
loop_count=${OPT_VAL['l']}

start_test

check_socwatch_module_loaded()
{
lsmod | grep -q socwatch || dlogi "socwatch is not loaded"
Expand Down
2 changes: 2 additions & 0 deletions test-case/test-speaker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ OPT_HAS_ARG['s']=0 OPT_VAL['s']=1

func_opt_parse_option "$@"
tplg=${OPT_VAL['t']}

start_test
logger_disabled || func_lib_start_log_collect

func_pipeline_export "$tplg" "type:playback"
Expand Down
2 changes: 2 additions & 0 deletions test-case/verify-bootsequence.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ ALSAUCM_VER=1.2.3-15
func_opt_parse_option "$@"
setup_kernel_check_point

start_test

main()
{
local tmp
Expand Down
2 changes: 2 additions & 0 deletions test-case/verify-firmware-presence.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
func_opt_parse_option "$@"
setup_kernel_check_point

start_test

path=$(sof-dump-status.py -P)
platform=$(sof-dump-status.py -p)
fw="$path/sof-$platform.ri"
Expand Down
5 changes: 5 additions & 0 deletions test-case/verify-kernel-boot-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ set -e
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

start_test
# TODO: replace start_test with this:
trap 'print_test_result_exit $?' EXIT
# https://github.com/thesofproject/sof-test/issues/1112

main()
{
printf 'System booted at: '; uptime -s
Expand Down
2 changes: 2 additions & 0 deletions test-case/verify-kernel-module-load-probe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func_opt_parse_option "$@"

setup_kernel_check_point

start_test

dlogi "Checking if sof relative modules loaded"
dlogc "lsmod | grep \"sof\""

Expand Down
2 changes: 2 additions & 0 deletions test-case/verify-pcm-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ OPT_HAS_ARG['t']=1 OPT_VAL['t']="${TPLG:-}"
func_opt_parse_option "$@"
tplg=${OPT_VAL['t']}

start_test

tplg_path=$(func_lib_get_tplg_path "$tplg") ||
die "No available topology for this test case"

Expand Down
2 changes: 2 additions & 0 deletions test-case/verify-sof-firmware-load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func_opt_parse_option "$@"

disable_kernel_check_point

start_test

cmd="journalctl_cmd"

dlogi "Checking SOF Firmware load info in kernel log"
Expand Down
2 changes: 2 additions & 0 deletions test-case/verify-tplg-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func_opt_parse_option "$@"
setup_kernel_check_point
tplg=${OPT_VAL['t']}

start_test

tplg_path=$(func_lib_get_tplg_path "$tplg") ||
die "No available topology ($tplg) for this test case"

Expand Down
2 changes: 2 additions & 0 deletions test-case/verify-ucm-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
func_opt_parse_option "$@"
setup_kernel_check_point

start_test

declare -A verb_array

# get the cards all verbs. The verbs are the items of SectionUseCase in
Expand Down
2 changes: 2 additions & 0 deletions test-case/volume-basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ setup_kernel_check_point
tplg=${OPT_VAL['t']}
maxloop=${OPT_VAL['l']}

start_test

func_error_exit()
{
dloge "$*"
Expand Down

0 comments on commit a82935b

Please sign in to comment.