Skip to content

Commit 88afba8

Browse files
committed
Replace duplicate multiple-pipeline-playback with a wrapper
Finally removes massive duplication with multiple-pipeline-capture.sh Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 2353053 commit 88afba8

File tree

1 file changed

+3
-156
lines changed

1 file changed

+3
-156
lines changed
Lines changed: 3 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,8 @@
11
#!/bin/bash
22

3-
### WARNING: this file is 99% COPY/PASTE from multiple-pipeline-capture.sh! ###
4-
5-
##
6-
## Case Name: Run multiple pipelines for playback
7-
## Preconditions:
8-
## check-playback-10sec pass
9-
## Description:
10-
## Pick up pipelines from TPLG file for max count
11-
## Rule:
12-
## a. fill pipeline need match max count
13-
## b. fill pipeline type order: playback > capture
14-
## c. if pipeline in TPLG is not enough of count, max count is pipeline count
15-
## Case step:
16-
## 1. Parse TPLG file to get pipeline count to decide max count is parameter or pipeline count
17-
## 2. load playback for aplay to fill pipeline count
18-
## 3. load capture for arecord to fill pipeline count
19-
## 4. wait for 0.5s for process already loaded
20-
## 5. check process status & process count
21-
## 6. wait for sleep time
22-
## 7. check process status & process count
23-
## Expect result:
24-
## all pipelines are alive and without kernel error
25-
##
26-
273
set -e
284

29-
# shellcheck source=case-lib/lib.sh
30-
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
31-
32-
OPT_OPT_lst['t']='tplg' OPT_DESC_lst['t']='tplg file, default value is env TPLG: $TPLG'
33-
OPT_PARM_lst['t']=1 OPT_VALUE_lst['t']="$TPLG"
34-
35-
OPT_OPT_lst['c']='count' OPT_DESC_lst['c']='test pipeline count'
36-
OPT_PARM_lst['c']=1 OPT_VALUE_lst['c']=4
37-
38-
OPT_OPT_lst['w']='wait' OPT_DESC_lst['w']='perpare wait time by sleep'
39-
OPT_PARM_lst['w']=1 OPT_VALUE_lst['w']=5
40-
41-
OPT_OPT_lst['r']='random' OPT_DESC_lst['r']='random load pipeline'
42-
OPT_PARM_lst['r']=0 OPT_VALUE_lst['r']=0
43-
44-
OPT_OPT_lst['s']='sof-logger' OPT_DESC_lst['s']="Open sof-logger trace the data will store at $LOG_ROOT"
45-
OPT_PARM_lst['s']=0 OPT_VALUE_lst['s']=1
46-
47-
OPT_OPT_lst['l']='loop' OPT_DESC_lst['l']='loop count'
48-
OPT_PARM_lst['l']=1 OPT_VALUE_lst['l']=1
49-
50-
func_opt_parse_option "$@"
51-
loop_cnt=${OPT_VALUE_lst['l']}
52-
tplg=${OPT_VALUE_lst['t']}
53-
[[ ${OPT_VALUE_lst['s']} -eq 1 ]] && func_lib_start_log_collect
54-
55-
max_count=0
56-
func_pipeline_export "$tplg" "type:any" # this line will help to get $PIPELINE_COUNT
57-
# get the min value of TPLG:'pipeline count' with Case:'pipeline count'
58-
[[ $PIPELINE_COUNT -gt ${OPT_VALUE_lst['c']} ]] && max_count=${OPT_VALUE_lst['c']} || max_count=$PIPELINE_COUNT
59-
60-
# now small function define
61-
declare -A APP_LST DEV_LST
62-
APP_LST['playback']='aplay_opts'
63-
DEV_LST['playback']='/dev/zero'
64-
APP_LST['capture']='arecord_opts'
65-
DEV_LST['capture']='/dev/null'
66-
67-
tmp_count=$max_count
68-
69-
# define for load pipeline
70-
func_run_pipeline_with_type()
71-
{
72-
[[ $tmp_count -le 0 ]] && return
73-
func_pipeline_export "$tplg" "type:$1"
74-
local -a idx_lst
75-
if [ ${OPT_VALUE_lst['r']} -eq 0 ]; then
76-
idx_lst=( $(seq 0 $(expr $PIPELINE_COUNT - 1)) )
77-
else
78-
# convert array to line, shuf to get random line, covert line to array
79-
idx_lst=( $(seq 0 $(expr $PIPELINE_COUNT - 1)|sed 's/ /\n/g'|shuf|xargs) )
80-
fi
81-
for idx in ${idx_lst[*]}
82-
do
83-
channel=$(func_pipeline_parse_value $idx channel)
84-
rate=$(func_pipeline_parse_value $idx rate)
85-
fmt=$(func_pipeline_parse_value $idx fmt)
86-
dev=$(func_pipeline_parse_value $idx dev)
87-
pcm=$(func_pipeline_parse_value $idx pcm)
88-
89-
dlogi "Testing: $pcm [$dev]"
90-
91-
"${APP_LST[$1]}" -D $dev -c $channel -r $rate -f $fmt "${DEV_LST[$1]}" -q &
92-
93-
: $((tmp_count--))
94-
if [ "$tmp_count" -le 0 ]; then return 0; fi
95-
done
96-
}
97-
98-
func_error_exit()
99-
{
100-
dloge "$*"
101-
102-
pgrep -a aplay && pkill -9 aplay
103-
pgrep -a arecord && pkill -9 arecord
104-
105-
exit 1
106-
}
107-
108-
for i in $(seq 1 $loop_cnt)
109-
do
110-
# set up checkpoint for each iteration
111-
func_lib_setup_kernel_checkpoint
112-
dlogi "===== Testing: (Loop: $i/$loop_cnt) ====="
113-
114-
# start capture:
115-
func_run_pipeline_with_type "playback"
116-
func_run_pipeline_with_type "capture"
117-
118-
dlogi "pipeline start sleep 0.5s for device wakeup"
119-
sleep ${OPT_VALUE_lst['w']}
120-
121-
# check all refer capture pipeline status
122-
# 1. check process count:
123-
rec_count=$(pidof arecord|wc -w)
124-
tmp_count=$((tmp_count + rec_count))
125-
play_count=$(pidof aplay|wc -w)
126-
tmp_count=$((tmp_count + play_count))
127-
[[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count"
128-
129-
# 2. check arecord process status
130-
dlogi "checking pipeline status"
131-
[ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null ||
132-
func_error_exit "Catch the abnormal process status of arecord"
133-
[ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null ||
134-
func_error_exit "Catch the abnormal process status of aplay"
135-
136-
dlogi "preparing sleep ${OPT_VALUE_lst['w']}"
137-
sleep ${OPT_VALUE_lst['w']}
138-
139-
# 3. check process count again:
140-
tmp_count=0
141-
rec_count=$(pidof arecord|wc -w)
142-
tmp_count=$((tmp_count + rec_count))
143-
play_count=$(pidof aplay|wc -w)
144-
tmp_count=$((tmp_count + play_count))
145-
[[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count"
146-
147-
# 4. check arecord process status
148-
dlogi "checking pipeline status again"
149-
[ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null ||
150-
func_error_exit "Catch the abnormal process status of arecord"
151-
[ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null ||
152-
func_error_exit "Catch the abnormal process status of aplay"
153-
154-
dlogc 'pkill -9 aplay arecord'
155-
[ "$rec_count" = 0 ] || pkill -9 arecord
156-
[ "$play_count" = 0 ] || pkill -9 aplay
157-
158-
# check kernel log for each iteration to catch issues
159-
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" || die "Caught error in kernel log"
160-
done
5+
TESTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
1616

7+
# Need "exec" otherwise it believes to be a Sub-Test
8+
exec "$TESTDIR"/test-case/multiple-pipeline.sh -f p "$@"

0 commit comments

Comments
 (0)