Skip to content

Commit e5c6f98

Browse files
marc-hbxiulipan
authored andcommitted
multiple-pipeline: replace pidof->ps to catch uninterruptible sleep
pidof ignores processes in uninterruptable sleep by default, probably because sending them signals is futile. pidof has a -z option but it's just simpler to use "ps". Also de-duplicate code into new ps_checks() function Fixes: #472 Any aplay or arecord process can be in uninterruptable sleep when doing I/O but the easiest way to reproduce is to wait a few seconds and let the DSP go to sleep. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent eeb066e commit e5c6f98

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

test-case/multiple-pipeline.sh

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ func_error_exit()
105105
exit 1
106106
}
107107

108+
109+
ps_checks()
110+
{
111+
local play_count rec_count total_count
112+
# Extra logging
113+
# >&2 ps u --no-headers -C aplay -C arecord || true
114+
115+
rec_count=$(ps --no-headers -C arecord | wc -l)
116+
play_count=$(ps --no-headers -C aplay | wc -l)
117+
total_count=$((rec_count + play_count))
118+
119+
[ "$total_count" -eq "$max_count" ] ||
120+
func_error_exit "Target pipeline count: $max_count, current process count: $total_count"
121+
122+
[ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null ||
123+
func_error_exit "Caught abnormal process status of arecord"
124+
[ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null ||
125+
func_error_exit "Caught abnormal process status of aplay"
126+
}
127+
128+
108129
for i in $(seq 1 $loop_cnt)
109130
do
110131
# set up checkpoint for each iteration
@@ -128,45 +149,22 @@ do
128149
die "Wrong -f argument $f_arg, see -h"
129150
esac
130151

131-
dlogi "pipeline start sleep 0.5s for device wakeup"
152+
dlogi "sleep ${OPT_VALUE_lst['w']}s for sound device wakeup"
132153
sleep ${OPT_VALUE_lst['w']}
133154

134-
# check all refer capture pipeline status
135-
# 1. check process count:
136-
rec_count=$(pidof arecord|wc -w)
137-
tmp_count=$((tmp_count + rec_count))
138-
play_count=$(pidof aplay|wc -w)
139-
tmp_count=$((tmp_count + play_count))
140-
[[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count"
141-
142-
# 2. check arecord process status
143155
dlogi "checking pipeline status"
144-
[ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null ||
145-
func_error_exit "Catch the abnormal process status of arecord"
146-
[ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null ||
147-
func_error_exit "Catch the abnormal process status of aplay"
156+
ps_checks
148157

149158
dlogi "preparing sleep ${OPT_VALUE_lst['w']}"
150159
sleep ${OPT_VALUE_lst['w']}
151160

152-
# 3. check process count again:
153-
tmp_count=0
154-
rec_count=$(pidof arecord|wc -w)
155-
tmp_count=$((tmp_count + rec_count))
156-
play_count=$(pidof aplay|wc -w)
157-
tmp_count=$((tmp_count + play_count))
158-
[[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count"
159-
160-
# 4. check arecord process status
161+
# check processes again
161162
dlogi "checking pipeline status again"
162-
[ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null ||
163-
func_error_exit "Catch the abnormal process status of arecord"
164-
[ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null ||
165-
func_error_exit "Catch the abnormal process status of aplay"
163+
ps_checks
166164

167165
dlogc 'pkill -9 aplay arecord'
168-
[ "$rec_count" = 0 ] || pkill -9 arecord
169-
[ "$play_count" = 0 ] || pkill -9 aplay
166+
pkill -9 arecord || true
167+
pkill -9 aplay || true
170168

171169
# check kernel log for each iteration to catch issues
172170
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" || die "Caught error in kernel log"

0 commit comments

Comments
 (0)