Skip to content
Closed
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
63 changes: 39 additions & 24 deletions test-case/multiple-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,31 @@
set -e

##
## Case Name: Run multiple pipeline for pause resume
## Case Name: multiple-pause-resume
## Preconditions:
## N/A
## Description:
## pickup multiple pipline to do pause resume
## fake pause/resume with expect
## expect sleep for sleep time then mocks spacebar keypresses ' ' to
## cause resume action
## Run pipelines in parallel and pause-resume them.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks this is so much clearer, now I understand the logic. My main problem was that I didn't understand what sof-combinatoric.py does and you very clearly explained that.

I think this help is still missing just one important thing: it should simply say what the code does: that the value '1' is really just a convenience shortcut for the pipeline count. Right now it sounds like '1' triggers some special logic but it does not, '1' merely sets a value and then the exact same code runs. So it is a bit of special case but nowhere near as much as this sounds.

##
## We can use '-c' option to control the number of pipelines
## that runs in parallel, the default value for '-c' is 1,
## with which all pipelines will run in parallel and get pause-
## resumed. Manually specified value should be greater than 1,
## and less than the maximum pipeline count.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Manually specified value should be greater than 1, and less than the maximum pipeline count.

That does not seem correct. It is possible and OK to specify 1 or the pipeline count (and they have the same, documented effect)

It is also possible to pass a value greater than the maximum count as you silently cap that to the maximum. Capping is probably OK but that's not what the help above says.

##
## If pipeline count N (1 < N < Max) is specified, each combination
## of N pipelines out of all will be tested. For example,
## supposed we have 4 pipelines in topology with ID 0, 1, 2, 3, and
## '-c 2' is used, below combination will be iterated.
## 0,1 0,2 0,3 1,2 1,3 2,3
##
## We use 'expect' to send SPACE to each aplay/arecord process,
## to simulate the real pause-resume action.
## Case step:
## 1. run 1st pipeline
## 2. pickup any other pipeline
## 3. use expect to fake pause/resume in each pipeline
## 4. go through with tplg file
## 1. Get the number of pipelines that will run in parallel from '-c' option
## 2. Get all the combination of N pipelines out of all.
## 3. Start pipelines and use expect to send SPACE to pause-resume them
## 4. Goes to next pipeline combination
## Expect result:
## no errors occur for either process
##
Expand All @@ -30,7 +42,7 @@ OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=3

OPT_NAME['c']='count' OPT_DESC['c']='combine test pipeline count'
OPT_HAS_ARG['c']=1 OPT_VAL['c']=2
OPT_HAS_ARG['c']=1 OPT_VAL['c']=1

OPT_NAME['r']='loop' OPT_DESC['r']='pause resume repeat count'
OPT_HAS_ARG['r']=1 OPT_VAL['r']=3
Expand All @@ -48,11 +60,11 @@ func_opt_parse_option "$@"

repeat_count=${OPT_VAL['r']}
loop_count=${OPT_VAL['l']}
# configure random value range
# pause-resume interval will be a random value between rnd_min and rnd_max
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
[[ $rnd_range -le 0 ]] && dlogw "Random range is not accepted [ min:$rnd_min - max:$rnd_max ]" && exit 2

tplg=${OPT_VAL['t']}
func_pipeline_export "$tplg" "type:any"
Expand All @@ -63,7 +75,9 @@ declare -a pipeline_idx_lst
declare -a cmd_idx_lst
declare -a file_idx_lst

# merge all pipeline to the 1 group
# Create two arrays to store command and file that will be used when start a pipeline.
# For playback pipeline, aplay and /dev/zero will be used, for capture pipeline arecord
# and /dev/null will be used.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: having this comment before the declares would help.

for i in $(seq 0 $(expr $PIPELINE_COUNT - 1))
do
pipeline_idx_lst=(${pipeline_idx_lst[*]} $i)
Expand All @@ -77,28 +91,29 @@ do
elif [ "$type" == "both" ];then
cmd_idx_lst=(${cmd_idx_lst[*]} "aplay")
file_idx_lst=(${file_idx_lst[*]} "/dev/zero")
# both include playback & capture, so duplicate it
# 'both' contains playback & capture pipeline
pipeline_idx_lst=(${pipeline_idx_lst[*]} $i)
cmd_idx_lst=(${cmd_idx_lst[*]} "arecord")
file_idx_lst=(${file_idx_lst[*]} "/dev/null")
else
die "Unknow pipeline type: $type"
die "Unknown pipeline type: $type"
fi
done

# get the min value of TPLG:'pipeline count' with Case:'pipeline count'
[[ ${#pipeline_idx_lst[*]} -gt ${OPT_VAL['c']} ]] && max_count=${OPT_VAL['c']} || max_count=${#pipeline_idx_lst[*]}
[[ $max_count -eq 1 ]] && dlogw "pipeline count is 1, don't need to run this case" && exit 2
max_count="${OPT_VAL['c']}"
if [ "$max_count" -gt "$PIPELINE_COUNT" ] || [ "$max_count" == "1" ]; then
max_count="$PIPELINE_COUNT"
fi

# create combination list
# create pipeline combination list
declare -a pipeline_combine_lst
for i in $(sof-combinatoric.py -n ${#pipeline_idx_lst[*]} -p $max_count)
do
# convert combine string to combine element
pipeline_combine_str="$(echo $i|sed 's/,/ /g')"
pipeline_combine_lst=("${pipeline_combine_lst[@]}" "$pipeline_combine_str")
done
[[ ${#pipeline_combine_lst[@]} -eq 0 ]] && dlogw "pipeline combine is empty" && exit 2
[[ ${#pipeline_combine_lst[@]} -eq 0 ]] && dlogw "Failed to generate pipeline combination" && exit 2

func_pause_resume_pipeline()
{
Expand Down Expand Up @@ -156,7 +171,7 @@ do
pid_lst=(${pid_lst[*]} $!)
done
# wait for expect script finished
dlogi "wait for expect process finished"
dlogi "wait expect process to exit"
i=$max_wait_time
while [ $i -gt 0 ]
do
Expand All @@ -167,13 +182,13 @@ do
# fix aplay/arecord last output
echo
if [ "$(pidof expect)" ]; then
dloge "Still have expect process not finished after wait for $max_wait_time"
dloge "Error: expect process is still running after $max_wait_time seconds"
# now dump process
ps -ef |grep -E 'aplay|arecord' || true
exit 1
fi
# now check for all expect quit status
# dump the pipeline combine, because pause resume will have too many operation log
# now check for all expect exit status
# dump the pipeline combination
for idx in $(echo $pipeline_combine_str)
do
pipeline_index=${pipeline_idx_lst[$idx]}
Expand Down