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

test-case: rename pause-resume to pause-release #1025

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
133 changes: 133 additions & 0 deletions test-case/check-pause-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/bin/bash

set -e

##
## Case Name: check-pause-release
## Preconditions:
## N/A
## Description:
## playback/capture on each pipeline and trigger pause/release with expect
## expect sleep for sleep time then mocks spacebar keypresses ' ' to
## cause release action
## Case step:
## 1. aplay/arecord on PCM
## 2. use expect to trigger pause/release
## Expect result:
## no error happen for aplay/arecord
##

# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $''TPLG'
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"

OPT_NAME['m']='mode' OPT_DESC['m']='test mode'
OPT_HAS_ARG['m']=1 OPT_VAL['m']='playback'

OPT_NAME['c']='count' OPT_DESC['c']='pause/release repeat count'
OPT_HAS_ARG['c']=1 OPT_VAL['c']=10

OPT_NAME['f']='file' OPT_DESC['f']='file name'
OPT_HAS_ARG['f']=1 OPT_VAL['f']=''

OPT_NAME['i']='min' OPT_DESC['i']='random range min value, unit is ms'
OPT_HAS_ARG['i']=1 OPT_VAL['i']='100'

OPT_NAME['a']='max' OPT_DESC['a']='random range max value, unit is ms'
OPT_HAS_ARG['a']=1 OPT_VAL['a']='200'

OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1

OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipelines"
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"

func_opt_parse_option "$@"
setup_kernel_check_point

tplg=${OPT_VAL['t']}
test_mode=${OPT_VAL['m']}
repeat_count=${OPT_VAL['c']}
#TODO: file name salt for capture
file_name=${OPT_VAL['f']}
# configure random value range
rnd_min=${OPT_VAL['i']}
rnd_max=${OPT_VAL['a']}
rnd_range=$(( rnd_max - rnd_min ))
[[ $rnd_range -le 0 ]] && dlogw "Error random range scope [ min:$rnd_min - max:$rnd_max ]" && exit 2

case $test_mode in
"playback")
cmd=aplay
cmd_opts="$SOF_APLAY_OPTS"
dummy_file=/dev/zero
;;
"capture")
cmd=arecord
cmd_opts="$SOF_ARECORD_OPTS"
dummy_file=/dev/null
;;
*)
die "Invalid test mode: $test_mode (allow value : playback, capture)"
;;
esac

logger_disabled || func_lib_start_log_collect

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

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
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)
dev=$(func_pipeline_parse_value "$idx" dev)
snd=$(func_pipeline_parse_value "$idx" snd)

# expect is tcl language script
# expr rand(): produces random numbers between 0 and 1
# after ms: Ms must be an integer giving a time in milliseconds.
# The command sleeps for ms milliseconds and then returns.
dlogi "Entering expect script with:
$cmd $SOF_ALSA_OPTS $cmd_opts -D $dev -r $rate -c $channel -f $fmt -vv -i $file_name -q"

expect <<END
spawn $cmd $SOF_ALSA_OPTS $cmd_opts -D $dev -r $rate -c $channel -f $fmt -vv -i $file_name -q
set i 1
expect {
"*#*+*\%" {
set sleep_t [expr int([expr rand() * $rnd_range]) + $rnd_min ]
puts "\r(\$i/$repeat_count) Wait for \$sleep_t ms before pause"
send " "
after \$sleep_t
exp_continue
}
"*PAUSE*" {
set sleep_t [expr int([expr rand() * $rnd_range]) + $rnd_min ]
puts "\r(\$i/$repeat_count) Wait for \$sleep_t ms before release"
send " "
after \$sleep_t
incr i
if { \$i > $repeat_count } { exit 0 }
exp_continue
}
}
exit 1
END
ret=$?
#flush the output
echo
if [ $ret -ne 0 ]; then
func_lib_lsof_error_dump "$snd"
sof-process-kill.sh ||
dlogw "Kill process catch error"
exit $ret
fi
# check kernel log for each iteration to catch issues
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" || die "Caught error in kernel log"
done
133 changes: 0 additions & 133 deletions test-case/check-pause-resume.sh

This file was deleted.

1 change: 1 addition & 0 deletions test-case/check-pause-resume.sh
Loading