From 6fec8e0c4417b57790862655d214f8411cbe3667 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 3 Nov 2023 10:38:08 +0200 Subject: [PATCH] multiple-pause-resume.sh: Check for aplay/arecord pid when waiting It has been observed that the expect process has been terminated (pidof returns with no PID) but the child aplay is still running. This only happens with ChainDMA enabled PCMs where the time to stop the stream takes more than 100ms (from trigger stop to PCM close). With the right timing on such PCM the pidof expect will break the wait loop and we progress to the next iteration which - again with right timing and setup - might fail if the aplay is still in a process of closing and the next iteration includes the same PCM. Add the aplay and arecord commands to the pidof command to make sure that the iteration has been completed before starting a new one. We will still catch timeouts and in that case we should kill the stuck processes. Signed-off-by: Peter Ujfalusi --- test-case/multiple-pause-resume.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test-case/multiple-pause-resume.sh b/test-case/multiple-pause-resume.sh index 0df264a4..97d7c037 100755 --- a/test-case/multiple-pause-resume.sh +++ b/test-case/multiple-pause-resume.sh @@ -149,22 +149,28 @@ do # It's very far from perfect but it helps a little bit. sleep 0.1 done - # wait for expect script finished - dlogi "wait for expect process finished" + # wait for aplay/arecord finished + dlogi "wait for expect/aplay/arecord process finished" iwait=$max_wait_time while [ $iwait -gt 0 ] do iwait=$((iwait - 1)) sleep 1s - [[ ! "$(pidof expect)" ]] && break + [[ ! "$(pidof expect aplay arecord)" ]] && break done - # fix aplay/arecord last output + # Catch timout after the wait loop echo - if [ "$(pidof expect)" ]; then + if [ "$(pidof expect aplay arecord)" ]; then dloge "Still have expect process not finished after wait for $max_wait_time" - # list aplay/arecord processes + # list expect/aplay/arecord processes + pgrep -a -f expect || true pgrep -a -f aplay || true pgrep -a -f arecord || true + + # kill aplay/arecord + sof-process-kill.sh || + dlogw "Kill process catch error" + exit 1 fi # now check for all expect quit status