Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly invoke start_test() in every test-case/*.sh #1187

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ minvalue() { printf '%d' $(( "$1" < "$2" ? "$1" : "$2" )); }
# concurrency 1% of the time, detecting it 99% of the time is much
# more than enough to spot reservation problems.
#
# 3. Register the func_exit_handler() EXIT trap that collects logs, kills
# loggers and prints test results.
#
# 4. Waits for the FW to be successfully booted (can be disabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can it be disabled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO_POLL_FW_LOADING 30 lines below, it's not that long of a function (as no function should be)

Also documented in config.sh

#
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: one blank line should be enough?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree it's nitpick

start_test()
{
if is_subtest; then
Expand Down Expand Up @@ -1018,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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit message, what is the meaning of the opening sentence in relation to moving the start_test from lib.sh to test cases?
Stop unconditionally imposing start_test() to everything sourcing lib.sh

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the question...
Now it's explicit, so each test has a choice to call start_test or not. That's all this PR is about.

When start_test was in lib.sh, tests had no choice but to run start_test

start_test started as a small thing so running it unconditionally was a "small bug" but it has kept growing.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the start_test used to run at line 21?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is a minor change: start_test is now running after option parsing. It was confusing to "start" a test and run the exit handler, etc. when no testing had started yet because a wrong option was passed.


# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this churn is to keep the systemctl_show_pulseaudio in tools/kmod/sof_remove.sh instead of just dropping it from the sof_remove.sh along with sourcing the case-lib/lib.sh and be done?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the main benefit for sof_remove.sh is the ability to run it more than once. It used to fail when the firmware wasn't running. Also avoids some confusing logs: sof_remove.sh is not a "test"

There will be a much bigger and much more important bug fix not related to sof_remove.sh, see commit message.

Also restores the ability to source lib.sh interactively, also mentioned in the commit message

Copy link
Collaborator Author

@marc-hb marc-hb May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of just dropping it from the sof_remove.sh along with sourcing the case-lib/lib.sh

The (non-mandatory) pulseaudio check is debatable. Including lib.sh is much less so. There's no reason to copy/paste routines when it can easily be avoided.

Anyway the most important and urgent benefit of this design fix is preparing the fix for #1036 and #1112. The same design fix just happens to help with some other scripts like sof_remove.sh.

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO will be next PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes immediately after this one. I want at least one run of daily tests between the two.

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
Loading