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 problem. Expect should handle MAX volume case as playing case.
And added for handling all of expected cases and if not the known cases,
the last case is error.

This is example of output from aplay or arecord.
1. Playing
"##    +                                            | 11%"
2. When paused
"=== PAUSE ==="
3. When volume is MAX
"##################################################+| MAX"
4. In the beginning of the command, multiple lines of dump-hw-params

Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
  • Loading branch information
fredoh9 committed Jul 13, 2022
1 parent e0af412 commit eb12965
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
12 changes: 11 additions & 1 deletion test-case/check-pause-release-suspend-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ spawn $cmd -D $pcm -r $rate -c $channel -f $fmt -vv -i $dummy_file -q
set i 1
set sleep_t $sleep_period
expect {
"#*+*\%" {
-re "#.*\%|#.*MAX" {
#audio stream (aplay or arecord) is active now and playing
puts "\r===== (\$i/$repeat_count) pb_pbm: Pause $cmd, then wait for ===== "
puts "\r(\$i/$repeat_count) pb_pbm: $sleep_t ms after pause"
Expand Down Expand Up @@ -169,7 +169,17 @@ expect {
if { \$i > $repeat_count } { exit 0 }
exp_continue
}
"*:*\n" {
puts "\rexpect ignore dump-hw-params"
after 10
exp_continue
}
"^?*\n" {
puts "\rError: unexpected output detected, exit 1"
exit 1
}
}
exit 1
AUDIO

ret=$?
Expand Down
14 changes: 12 additions & 2 deletions test-case/check-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ do
spawn $cmd $SOF_ALSA_OPTS $cmd_opts -D $dev -r $rate -c $channel -f $fmt -vv -i $file_name -q
set i 1
expect {
"*#*+*\%" {
-re "#.*\%|#.*MAX" {
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 +116,23 @@ expect {
if { \$i > $repeat_count } { exit 0 }
exp_continue
}
"*:*\n" {
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
13 changes: 11 additions & 2 deletions test-case/multiple-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ func_pause_resume_pipeline()
spawn $cmd -D $dev -r $rate -c $channel -f $fmt -vv -i $file -q
set i 1
expect {
"*#*+*\%" {
-re "#.*\%|#.*MAX" {
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 +135,15 @@ expect {
if { \$i > $repeat_count } { exit 0 }
exp_continue
}
"*:*\n" {
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 eb12965

Please sign in to comment.