Skip to content

Commit 3617834

Browse files
committed
multiple-pipeline: fix set -e compatibility and add it
Notably remove top-level "expr" because "expr 0" is surprisingly a failure and expr is antiquited anyway (SC2003) Also add a dlogi() before killing so no one mistakes the deaths of aplay and arecord for failures. Progress towards #312. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 37e44c4 commit 3617834

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test-case/multiple-pipeline-capture.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
## all pipelines are alive and without kernel error
2323
##
2424

25+
set -e
26+
2527
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
2628

2729
OPT_OPT_lst['t']='tplg' OPT_DESC_lst['t']='tplg file, default value is env TPLG: $TPLG'
@@ -87,8 +89,8 @@ func_run_pipeline_with_type()
8789
dlogc "${APP_LST[$1]} -D $dev -c $channel -r $rate -f $fmt ${DEV_LST[$1]} -q"
8890
"${APP_LST[$1]}" -D $dev -c $channel -r $rate -f $fmt "${DEV_LST[$1]}" -q &
8991

90-
tmp_count=$(expr $tmp_count - 1 )
91-
[[ $tmp_count -le 0 ]] && return
92+
: $((tmp_count--))
93+
if [ "$tmp_count" -le 0 ]; then return 0; fi
9294
done
9395
}
9496

@@ -116,9 +118,9 @@ do
116118
# check all refer capture pipeline status
117119
# 1. check process count:
118120
pcount=$(pidof arecord|wc -w)
119-
tmp_count=$(expr $tmp_count + $pcount)
121+
tmp_count=$((tmp_count + pcount))
120122
pcount=$(pidof aplay|wc -w)
121-
tmp_count=$(expr $tmp_count + $pcount)
123+
tmp_count=$((tmp_count + pcount))
122124
[[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count"
123125

124126
# 2. check arecord process status
@@ -134,9 +136,9 @@ do
134136
# 3. check process count again:
135137
tmp_count=0
136138
pcount=$(pidof arecord|wc -w)
137-
tmp_count=$(expr $tmp_count + $pcount)
139+
tmp_count=$((tmp_count + pcount))
138140
pcount=$(pidof aplay|wc -w)
139-
tmp_count=$(expr $tmp_count + $pcount)
141+
tmp_count=$((tmp_count + pcount))
140142
[[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count"
141143

142144
# 4. check arecord process status
@@ -147,7 +149,7 @@ do
147149
[[ $? -eq 1 ]] && func_error_exit "Catch the abnormal process status of aplay"
148150

149151

150-
# kill all arecord
152+
dlogc 'pkill -9 aplay arecord'
151153
pkill -9 arecord
152154
pkill -9 aplay
153155

0 commit comments

Comments
 (0)