Skip to content

Commit

Permalink
check-pause-resume: handle volume MAX output in expect
Browse files Browse the repository at this point in the history
When volume is MAX, current expect misses the case. Why volume is MAX is
separate question. Momentary pop can be ingored but if volume is 100% DC
return error.
And added for ignoring dump-hw-params and last case is anything else,
it means unexpected outputs, will return error also.

This is example of output from aplay or arecord.
1. Playing
"##    +                                            | 11%"
2. When paused
"=== PAUSE ==="
3. When volume is MAX
"##################################################+| MAX"

Signed-off-by: Fred Oh <[email protected]>
  • Loading branch information
fredoh9 committed Jul 14, 2022
1 parent e0af412 commit ab6d555
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
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 @@ -121,6 +121,8 @@ rm -rf /tmp/sof-test.lock
# catch: Evaluate script and trap exceptional returns
# after ms: Ms must be an integer giving a time in milliseconds.
# The command sleeps for ms milliseconds and then returns.
# FIXME: Need to handle more of aplay/arecord output. Need to apply similar fix with
# check-pause-resume.sh, multiple-pause-resume.sh
expect <<AUDIO
spawn $cmd -D $pcm -r $rate -c $channel -f $fmt -vv -i $dummy_file -q
set i 1
Expand Down
22 changes: 20 additions & 2 deletions test-case/check-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ do
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
set maxcount 1
expect {
"*#*+*\%" {
-re "#.*\%" {
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*" {
"*=== PAUSE*" {
set sleep_t [expr int([expr rand() * $rnd_range]) + $rnd_min ]
puts "\r(\$i/$repeat_count) Wait for \$sleep_t ms before resume"
send " "
Expand All @@ -116,13 +117,30 @@ expect {
if { \$i > $repeat_count } { exit 0 }
exp_continue
}
-re "#.*MAX" {
if { \$maxcount > 10 } { puts "\rMAX Volume error!"; exit 1 }
puts "\rError: MAX volume detected (\$maxcount/10), Wait for 500ms"
incr maxcount
after 500
exp_continue
}
-re "*:*\n"|"Hardware PCM card*" {
puts "\rexpect ignore dump-hw-params"
after 10
exp_continue
}
"^?*\n" {
puts "\rError: unexpected output detected, exit 1"
exit 1
}
}
exit 1
END
ret=$?
#flush the output
echo
if [ $ret -ne 0 ]; then
echo "Expect block return $ret"
func_lib_lsof_error_dump "$snd"
sof-process-kill.sh ||
dlogw "Kill process catch error"
Expand Down
21 changes: 19 additions & 2 deletions test-case/multiple-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ func_pause_resume_pipeline()
expect <<END &
spawn $cmd -D $dev -r $rate -c $channel -f $fmt -vv -i $file -q
set i 1
set maxcount 1
expect {
"*#*+*\%" {
-re "#.*\%" {
set sleep_t [expr int([expr rand() * $rnd_range]) + $rnd_min ]
puts "\r(\$i/$repeat_count) pcm'$pcm' cmd'$cmd' id'$idx': Wait for \$sleep_t ms before pause"
send " "
after \$sleep_t
exp_continue
}
"*PAUSE*" {
"*=== PAUSE*" {
set sleep_t [expr int([expr rand() * $rnd_range]) + $rnd_min ]
puts "\r(\$i/$repeat_count) pcm'$pcm' cmd'$cmd' id'$idx': Wait for \$sleep_t ms before resume"
send " "
Expand All @@ -135,6 +136,22 @@ expect {
if { \$i > $repeat_count } { exit 0 }
exp_continue
}
-re "#.*MAX" {
if { \$maxcount > 10 } { puts "\rMAX Volume error!"; exit 1 }
puts "\rError: MAX volume detected (\$maxcount/10), Wait for 500ms"
incr maxcount
after 500
exp_continue
}
-re "*:*\n"|"Hardware PCM card*" {
puts "\rexpect ignore dump-hw-params"
after 10
exp_continue
}
"^?*\n" {
puts "\rError: unexpected output detected, exit 1"
exit 1
}
}
exit 1
END
Expand Down

0 comments on commit ab6d555

Please sign in to comment.