Skip to content

Commit 5bb6679

Browse files
committed
multiple-pause-resume: fix shellcheck warnings
Reduce the number of shellcheck warnings. No functional change is introduced. Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
1 parent f520ac6 commit 5bb6679

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

test-case/multiple-pause-resume.sh

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ set -e
2121
##
2222

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

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

2929
OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
@@ -52,7 +52,7 @@ loop_count=${OPT_VAL['l']}
5252
# configure random value range
5353
rnd_min=${OPT_VAL['i']}
5454
rnd_max=${OPT_VAL['a']}
55-
rnd_range=$[ $rnd_max - $rnd_min ]
55+
rnd_range=$((rnd_max - rnd_min))
5656
[[ $rnd_range -le 0 ]] && dlogw "Error random range scope [ min:$rnd_min - max:$rnd_max ]" && exit 2
5757

5858
tplg=${OPT_VAL['t']}
@@ -65,23 +65,23 @@ declare -a cmd_idx_lst
6565
declare -a file_idx_lst
6666

6767
# merge all pipeline to the 1 group
68-
for i in $(seq 0 $(expr $PIPELINE_COUNT - 1))
68+
for i in $(seq 0 $((PIPELINE_COUNT - 1)))
6969
do
70-
pipeline_idx_lst=(${pipeline_idx_lst[*]} $i)
71-
type=$(func_pipeline_parse_value $i type)
70+
pipeline_idx_lst=("${pipeline_idx_lst[@]}" "$i")
71+
type=$(func_pipeline_parse_value "$i" type)
7272
if [ "$type" == "playback" ];then
73-
cmd_idx_lst=(${cmd_idx_lst[*]} "aplay")
74-
file_idx_lst=(${file_idx_lst[*]} "/dev/zero")
73+
cmd_idx_lst=("${cmd_idx_lst[@]}" "aplay")
74+
file_idx_lst=("${file_idx_lst[@]}" "/dev/zero")
7575
elif [ "$type" == "capture" ];then
76-
cmd_idx_lst=(${cmd_idx_lst[*]} "arecord")
77-
file_idx_lst=(${file_idx_lst[*]} "/dev/null")
76+
cmd_idx_lst=("${cmd_idx_lst[@]}" "arecord")
77+
file_idx_lst=("${file_idx_lst[@]}" "/dev/null")
7878
elif [ "$type" == "both" ];then
79-
cmd_idx_lst=(${cmd_idx_lst[*]} "aplay")
80-
file_idx_lst=(${file_idx_lst[*]} "/dev/zero")
79+
cmd_idx_lst=("${cmd_idx_lst[@]}" "aplay")
80+
file_idx_lst=("${file_idx_lst[@]}" "/dev/zero")
8181
# both include playback & capture, so duplicate it
82-
pipeline_idx_lst=(${pipeline_idx_lst[*]} $i)
83-
cmd_idx_lst=(${cmd_idx_lst[*]} "arecord")
84-
file_idx_lst=(${file_idx_lst[*]} "/dev/null")
82+
pipeline_idx_lst=("${pipeline_idx_lst[@]}" "$i")
83+
cmd_idx_lst=("${cmd_idx_lst[@]}" "arecord")
84+
file_idx_lst=("${file_idx_lst[@]}" "/dev/null")
8585
else
8686
die "Unknow pipeline type: $type"
8787
fi
@@ -93,10 +93,10 @@ done
9393

9494
# create combination list
9595
declare -a pipeline_combine_lst
96-
for i in $(sof-combinatoric.py -n ${#pipeline_idx_lst[*]} -p $max_count)
96+
for i in $(sof-combinatoric.py -n ${#pipeline_idx_lst[*]} -p "$max_count")
9797
do
98-
# convert combine string to combine element
99-
pipeline_combine_str="$(echo $i|sed 's/,/ /g')"
98+
# convert combine string to combine element by replacing commas with spaces for the for loop below
99+
pipeline_combine_str="${i//,/ }"
100100
pipeline_combine_lst=("${pipeline_combine_lst[@]}" "$pipeline_combine_str")
101101
done
102102
[[ ${#pipeline_combine_lst[@]} -eq 0 ]] && dlogw "pipeline combine is empty" && exit 2
@@ -152,10 +152,10 @@ do
152152
do
153153
unset pid_lst
154154
declare -a pid_lst
155-
for idx in $(echo $pipeline_combine_str)
155+
for idx in $pipeline_combine_str
156156
do
157-
func_pause_resume_pipeline $idx
158-
pid_lst=(${pid_lst[*]} $!)
157+
func_pause_resume_pipeline "$idx"
158+
pid_lst=("${pid_lst[@]}" $!)
159159
done
160160
# wait for expect script finished
161161
dlogi "wait for expect process finished"
@@ -170,16 +170,17 @@ do
170170
echo
171171
if [ "$(pidof expect)" ]; then
172172
dloge "Still have expect process not finished after wait for $max_wait_time"
173-
# now dump process
174-
ps -ef |grep -E 'aplay|arecord' || true
173+
# list aplay/arecord processes
174+
pgrep -a -f aplay || true
175+
pgrep -a -f arecord || true
175176
exit 1
176177
fi
177178
# now check for all expect quit status
178179
# dump the pipeline combine, because pause resume will have too many operation log
179-
for idx in $(echo $pipeline_combine_str)
180+
for idx in $pipeline_combine_str
180181
do
181182
pipeline_index=${pipeline_idx_lst[$idx]}
182-
pcm=$(func_pipeline_parse_value $pipeline_index pcm)
183+
pcm=$(func_pipeline_parse_value "$pipeline_index" pcm)
183184
dlogi "pipeline: $pcm with ${cmd_idx_lst[$idx]}"
184185
done
185186
dlogi "Check expect exit status"

0 commit comments

Comments
 (0)