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 9d02ef8
Show file tree
Hide file tree
Showing 40 changed files with 66 additions and 3 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
1 change: 1 addition & 0 deletions test-case/check-alsabat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ else
set_alsa_settings "$MODEL"
fi

start_test
logger_disabled || func_lib_start_log_collect

function __upload_wav_file
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 @@ -45,6 +45,8 @@ if sudo file $ipc_flood_dfs | grep 'No such file'; then
fi
dlogi "Checking ipc flood test!"

start_test

for i in $(seq 1 $loop_cnt)
do
# TODO: use journalctl to replace dmesg
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 @@ -62,6 +62,8 @@ if [ ${OPT_VAL['p']} -eq 1 ];then
func_lib_disable_pulseaudio
fi

start_test

playback_subtest()
{
# Disable logging with -s because subtests don't invoke func_exit_handler() which
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: 1 addition & 1 deletion test-case/check-pause-release-suspend-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ esac

[[ -z $file_name ]] && file_name=$dummy_file


start_test
logger_disabled || func_lib_start_log_collect

setup_kernel_check_point
Expand Down
1 change: 1 addition & 0 deletions test-case/check-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ case $test_mode in
;;
esac

start_test
logger_disabled || func_lib_start_log_collect

[[ -z $file_name ]] && file_name=$dummy_file
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
1 change: 1 addition & 0 deletions test-case/check-runtime-pm-double-active.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ DEV_LST['playback']='/dev/zero'
APP_LST['capture']='arecord'
DEV_LST['capture']='/dev/null'

start_test
logger_disabled || func_lib_start_log_collect
func_pipeline_export "$tplg" "type:any"

Expand Down
1 change: 1 addition & 0 deletions test-case/check-runtime-pm-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ DEV_LST['playback']='/dev/zero'
APP_LST['capture']='arecord'
DEV_LST['capture']='/dev/null'

start_test
logger_disabled || func_lib_start_log_collect
func_pipeline_export "$tplg" "type:any"

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
1 change: 1 addition & 0 deletions test-case/check-sof-logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func_opt_parse_option "$@"
type -a sof-logger ||
die "sof-logger Not Installed!"

start_test

# Checksum a list of files, one filename per stdin line.
# Whitespace-safe and shellcheck-approved.
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
2 changes: 2 additions & 0 deletions test-case/check-userspace-cardinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func_lib_check_pa || die "Please check whether pulseaudio runs correctly or not"
func_opt_parse_option "$@"
setup_kernel_check_point

start_test

: $((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 @@ -55,6 +55,8 @@ channel=${OPT_VAL['C']}

# TODO: check the parameter is valid or not

start_test

# go through all the sources
# get all the sources name
sourcekeys=$(pactlinfo.py --showsources)
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
1 change: 1 addition & 0 deletions test-case/multiple-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ rnd_range=$((rnd_max - rnd_min))
tplg=${OPT_VAL['t']}
func_pipeline_export "$tplg" "type:any & ~pcm:Amplifier Reference"

start_test
logger_disabled || func_lib_start_log_collect

declare -a pipeline_idx_lst
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
2 changes: 2 additions & 0 deletions test-case/simultaneous-playback-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ 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"

start_test
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 @@ -41,6 +41,8 @@ dlogc "sof-dump-status.py -i ${SOFCARD:-0}"
dlogi "Pipeline(s) from system:"
echo "$pcm_str"

start_test

if [[ "$tplg_str" != "$pcm_str" ]]; then
dloge "Pipeline(s) from topology don't match pipeline(s) from system"
dlogi "Dump aplay -l"
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 @@ -44,6 +44,8 @@ func_error_exit()

[[ -z $tplg ]] && die "Missing tplg file needed to run"
func_pipeline_export "$tplg" "type:playback"

start_test
logger_disabled || func_lib_start_log_collect

[[ $PIPELINE_COUNT -eq 0 ]] && die "Missing playback pipeline for aplay to run"
Expand Down

0 comments on commit 9d02ef8

Please sign in to comment.