Skip to content

Commit 2b19003

Browse files
committed
Updated the Audio test scripts to include support for PulseAudio and PipeWire
Signed-off-by: tmoida <[email protected]>
1 parent baf427a commit 2b19003

File tree

5 files changed

+279
-74
lines changed

5 files changed

+279
-74
lines changed

Runner/plans/meta-ar-ci-premerge.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ metadata:
1414
run:
1515
steps:
1616
- cd Runner
17-
- $PWD/suites/Multimedia/Audio/AudioPlayback/run.sh || true
18-
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res || true
19-
- $PWD/suites/Multimedia/Audio/AudioRecord/run.sh || true
20-
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioRecord/AudioRecord.res || true
17+
- AUDIO_BACKEND=pulseaudio $PWD/suites/Multimedia/Audio/AudioPlayback/run.sh || true
18+
- AUDIO_BACKEND=pulseaudio $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res || true
19+
- AUDIO_BACKEND=pipewire $PWD/suites/Multimedia/Audio/AudioPlayback/run.sh || true
20+
- AUDIO_BACKEND=pipewire $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res || true
21+
- AUDIO_BACKEND=pulseaudio $PWD/suites/Multimedia/Audio/AudioRecord/run.sh || true
22+
- AUDIO_BACKEND=pulseaudio $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioRecord/AudioRecord.res || true
23+
- AUDIO_BACKEND=pipewire $PWD/suites/Multimedia/Audio/AudioRecord/run.sh || true
24+
- AUDIO_BACKEND=pipewire $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioRecord/AudioRecord.res || true
2125
- $PWD/utils/result_parse.sh
2226

Runner/suites/Multimedia/Audio/AudioPlayback/Read_me.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
# Audio playback Validation Script for Qualcomm Linux based platform (Yocto)
1+
# Audio Playback Validation Script for Qualcomm Linux-based Platform (Yocto)
22

33
## Overview
44

5-
This script automates the validation of audio playback capabilities on the Qualcomm Linux based platform running a Yocto-based Linux system. It utilizes pulseaudio test app to decode wav file.
5+
This script automates the validation of audio playback capabilities on the Qualcomm Linux-based platform running a Yocto-based Linux system. It supports both PulseAudio and PipeWire backends for audio playback.
66

77
## Features
88

9-
- Decoding PCM clip
10-
- Compatible with Yocto-based root filesystem
9+
- Plays a test audio clip using either `paplay` or `pw-play`
10+
- Supports configurable playback volume, timeout, and loop count
11+
- Automatically downloads and extracts audio clip if not present
12+
- Captures kernel logs before and after playback
13+
- Scans dmesg logs for audio-related errors
14+
- Validates presence of required daemons and binaries
1115

1216
## Prerequisites
1317

1418
Ensure the following components are present in the target Yocto build:
1519

16-
- `paplay` binary(available at /usr/bin)
20+
- `paplay` binary (for PulseAudio)
21+
- `pw-play`, `pgrep`, `timeout`, `grep` (for PipeWire)
22+
- `pulseaudio` or `pipewire` daemon must be running depending on backend
1723

1824
## Directory Structure
1925

@@ -34,7 +40,7 @@ Instructions
3440

3541
1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.
3642

37-
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
43+
2. Verify Transfer: Ensure that the repo has been successfully copied to any directory on the target device.
3844

3945
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
4046

@@ -46,22 +52,36 @@ git clone <this-repo>
4652
cd <this-repo>
4753
scp -r Runner user@target_device_ip:<Path in device>
4854
ssh user@target_device_ip
49-
cd <Path in device>/Runner && ./run-test.sh AudioPlayback
55+
cd <Path in device>/Runner
56+
**Run with PulseAudio**
57+
AUDIO_BACKEND=pulseaudio ./run-test.sh AudioPlayback
58+
**Run with PipeWire**
59+
AUDIO_BACKEND=pipewire ./run-test.sh AudioPlayback
60+
61+
Environment Variables:
62+
You can customize playback behavior using the following environment variables:
63+
AUDIO_BACKEND: Selects the audio backend (pulseaudio or pipewire). Default is pulseaudio.
64+
PLAYBACK_TIMEOUT: Timeout duration for playback (e.g., 15s). Default is 15s.
65+
PLAYBACK_LOOPS: Number of times to repeat playback. Default is 1.
66+
PLAYBACK_VOLUME: Playback volume.
67+
For paplay: Range is 0–65536 (default: 65536)
68+
For pw-play: Range is 0.0–1.0 (default: 1.0)
5069
```
5170
Sample Output:
5271
```
53-
sh-5.2# cd <Path in device>/Runner/ && ./run-test.sh AudioPlayback
54-
[Executing test case: AudioPlayback] 2025-05-28 19:01:59 -
55-
[INFO] 2025-05-28 19:01:59 - ------------------------------------------------------------
56-
[INFO] 2025-05-28 19:01:59 - ------------------- Starting AudioPlayback Testcase ------------
57-
[INFO] 2025-05-28 19:01:59 - Checking if dependency binary is available
58-
[INFO] 2025-05-28 19:01:59 - Playback clip present: AudioClips/yesterday_48KHz.wav
59-
[PASS] 2025-05-28 19:02:14 - Playback completed or timed out (ret=124) as expected.
60-
[PASS] 2025-05-28 19:02:14 - AudioPlayback : Test Passed
61-
[INFO] 2025-05-28 19:02:14 - See results/audioplayback/playback_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details
62-
[INFO] 2025-05-28 19:02:14 - ------------------- Completed AudioPlayback Testcase -------------
63-
[PASS] 2025-05-28 19:02:14 - AudioPlayback passed
64-
sh-5.2#
72+
sh-5.2# AUDIO_BACKEND=pipewire ./run-test.sh AudioPlayback
73+
[Executing test case: AudioPlayback] 2025-08-14 10:17:35 -
74+
[INFO] 2025-08-14 10:17:35 - ------------------------------------------------------------
75+
[INFO] 2025-08-14 10:17:35 - ------------------- Starting AudioPlayback Testcase ------------
76+
[INFO] 2025-08-14 10:17:35 - Using audio backend: pipewire
77+
[INFO] 2025-08-14 10:17:35 - Checking if dependency binary is available
78+
[INFO] 2025-08-14 10:17:35 - Playback clip present: AudioClips/yesterday_48KHz.wav
79+
[INFO] 2025-08-14 10:17:51 - Scanning dmesg for audio: errors & success patterns
80+
[INFO] 2025-08-14 10:17:51 - No audio-related errors found (no OK pattern requested)
81+
[PASS] 2025-08-14 10:17:51 - Playback completed or timed out (ret=124) as expected.
82+
[PASS] 2025-08-14 10:17:51 - AudioPlayback : Test Passed
83+
[PASS] 2025-08-14 10:17:51 - AudioPlayback passed
84+
[INFO] 2025-08-14 10:17:51 - ========== Test Summary ==========
6585
```
6686
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res` directory.
6787

@@ -76,3 +96,4 @@ sh-5.2#
7696

7797
SPDX-License-Identifier: BSD-3-Clause-Clear
7898
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
99+

Runner/suites/Multimedia/Audio/AudioPlayback/run.sh

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,79 @@ if [ -z "$__INIT_ENV_LOADED" ]; then
2424
# shellcheck disable=SC1090
2525
. "$INIT_ENV"
2626
fi
27-
# shellcheck disable=SC1090,SC1091
27+
28+
# Source library first
2829
. "$TOOLS/functestlib.sh"
30+
31+
# Override with BusyBox-compatible version
32+
check_network_status() {
33+
ip addr | awk '/state UP/ {iface=$2} /inet / {if (iface) print iface; iface=""}' | cut -d: -f1 | head -n 1
34+
}
35+
2936
# ---------------------------------------------------------------
3037

3138
TESTNAME="AudioPlayback"
32-
TESTBINARY="paplay"
3339
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/Pulse-Audio-Files-v1.0/AudioClips.tar.gz"
3440
PLAYBACK_CLIP="AudioClips/yesterday_48KHz.wav"
3541
AUDIO_DEVICE="low-latency0"
3642
LOGDIR="results/audioplayback"
3743
RESULT_FILE="$TESTNAME.res"
3844

45+
# Determine backend and binary
46+
AUDIO_BACKEND="${AUDIO_BACKEND:-pulseaudio}" # Default to pulseaudio if not set
47+
48+
# PLAYBACK_VOLUME: 0-65536 for paplay, 0.0-1.0 for pw-play
49+
# PLAYBACK_TIMEOUT: seconds (default: 15)
50+
# PLAYBACK_LOOPS: number of times to repeat playback
51+
PLAYBACK_TIMEOUT="${PLAYBACK_TIMEOUT:-15s}"
52+
PLAYBACK_LOOPS="${PLAYBACK_LOOPS:-1}"
53+
# Set default volume based on backend
54+
# paplay volume range: 0–65536
55+
# pw-play volume range: 0.0–1.0
56+
if [ "$AUDIO_BACKEND" = "pulseaudio" ]; then
57+
PLAYBACK_VOLUME="${PLAYBACK_VOLUME:-65536}"
58+
elif [ "$AUDIO_BACKEND" = "pipewire" ]; then
59+
PLAYBACK_VOLUME="${PLAYBACK_VOLUME:-1.0}"
60+
fi
61+
62+
# Select playback command based on backend
63+
case "$AUDIO_BACKEND" in
64+
pulseaudio)
65+
TESTBINARY="paplay"
66+
PLAY_CMD="paplay --volume=$PLAYBACK_VOLUME \"$PLAYBACK_CLIP\" -d \"$AUDIO_DEVICE\""
67+
;;
68+
pipewire)
69+
TESTBINARY="pw-play"
70+
PLAY_CMD="pw-play --volume=$PLAYBACK_VOLUME \"$PLAYBACK_CLIP\""
71+
;;
72+
*)
73+
log_fail "Invalid AUDIO_BACKEND specified: $AUDIO_BACKEND. Use 'pulseaudio' or 'pipewire'."
74+
echo "$TESTNAME FAIL" > "$RESULT_FILE"
75+
exit 1
76+
;;
77+
esac
78+
3979
test_path=$(find_test_case_by_name "$TESTNAME")
4080
cd "$test_path" || exit 1
41-
4281
# Prepare logdir
4382
mkdir -p "$LOGDIR"
4483
chmod -R 777 "$LOGDIR"
4584

4685
log_info "------------------------------------------------------------"
4786
log_info "------------------- Starting $TESTNAME Testcase ------------"
87+
log_info "Using audio backend: $AUDIO_BACKEND"
88+
89+
# Daemon check
90+
if [ "$AUDIO_BACKEND" = "pulseaudio" ]; then
91+
if ! pgrep pulseaudio > /dev/null && ! pgrep pipewire-pulse > /dev/null; then
92+
log_skip_exit "$TESTNAME" "Neither PulseAudio nor pipewire-pulse daemon is running"
93+
fi
94+
elif [ "$AUDIO_BACKEND" = "pipewire" ]; then
95+
pgrep pipewire > /dev/null || log_skip_exit "$TESTNAME" "PipeWire daemon not running"
96+
fi
4897

4998
log_info "Checking if dependency binary is available"
50-
check_dependencies "$TESTBINARY" pgrep grep timeout
51-
99+
check_dependencies "$TESTBINARY" pgrep grep
52100
# Download/extract audio if not present
53101
if [ ! -f "$PLAYBACK_CLIP" ]; then
54102
log_info "Audio clip not found, downloading..."
@@ -68,27 +116,52 @@ fi
68116
log_info "Playback clip present: $PLAYBACK_CLIP"
69117

70118
# --- Capture logs BEFORE playback (for debugging) ---
71-
dmesg > "$LOGDIR/dmesg_before.log"
119+
get_kernel_log > "$LOGDIR/dmesg_before.log"
72120

73121
# --- Start the Playback, capture output ---
74-
timeout 15s paplay "$PLAYBACK_CLIP" -d "$AUDIO_DEVICE" > "$LOGDIR/playback_stdout.log" 2>&1
75-
ret=$?
122+
PLAYBACK_SUCCESS=0
123+
124+
for i in $(seq 1 "$PLAYBACK_LOOPS"); do
125+
log_info "Playback loop $i of $PLAYBACK_LOOPS"
126+
# Choose timeout method
127+
if command -v timeout >/dev/null 2>&1; then
128+
# Use system timeout if available
129+
timeout "$PLAYBACK_TIMEOUT" sh -c "$PLAY_CMD" >> "$LOGDIR/playback_stdout.log" 2>&1
130+
ret=$?
131+
else
132+
# Use library fallback if timeout is missing
133+
run_with_timeout "$PLAYBACK_TIMEOUT" sh -c "$PLAY_CMD" >> "$LOGDIR/playback_stdout.log" 2>&1
134+
ret=$?
135+
fi
136+
137+
if [ "$ret" -eq 0 ]; then
138+
log_pass "Playback loop $i: Completed successfully (ret=0)"
139+
elif [ "$ret" -eq 1 ] && [ "$AUDIO_BACKEND" = "pipewire" ]; then
140+
log_warn "Playback loop $i: Interrupted/timed out for PipeWire (ret=1)"
141+
elif [ "$ret" -eq 124 ]; then
142+
log_warn "Playback loop $i: Timed out (ret=124)"
143+
else
144+
log_fail "Playback loop $i: Failed with error code $ret"
145+
PLAYBACK_SUCCESS=1
146+
break # Early exit on first true failure
147+
fi
148+
done
76149

77150
# --- Capture logs AFTER playback (for debugging) ---
78-
dmesg > "$LOGDIR/dmesg_after.log"
151+
get_kernel_log > "$LOGDIR/dmesg_after.log"
152+
scan_dmesg_errors "audio" "$LOGDIR"
79153

80-
if [ "$ret" -eq 0 ] || [ "$ret" -eq 124 ] ; then
81-
log_pass "Playback completed or timed out (ret=$ret) as expected."
82-
log_pass "$TESTNAME : Test Passed"
154+
# Set final result based on loop outcomes
155+
if [ "$PLAYBACK_SUCCESS" -eq 0 ]; then
156+
log_pass_exit "$TESTNAME" "Audio playback test completed successfully for all loops"
83157
echo "$TESTNAME PASS" > "$RESULT_FILE"
84158
exit 0
85159
else
86-
log_fail "$TESTBINARY playback exited with error code $ret"
87-
log_fail "$TESTNAME : Test Failed"
160+
log_fail_exit "$TESTNAME" "Audio playback test failed in loop $i"
88161
echo "$TESTNAME FAIL" > "$RESULT_FILE"
89162
exit 1
90163
fi
91164

92-
log_info "See $LOGDIR/playback_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details"
165+
log_info "See $LOGDIR/playback_stdout.log, dmesg_before/after.log for debug details"
93166
log_info "------------------- Completed $TESTNAME Testcase -------------"
94-
exit 0
167+
exit 0

Runner/suites/Multimedia/Audio/AudioRecord/Read_me.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
# Audio encode Validation Script for Qualcomm Linux based platform (Yocto)
1+
# Audio Record Validation Script for Qualcomm Linux-based Platform (Yocto)
22

33
## Overview
44

5-
This script automates the validation of audio encode capabilities on the Qualcomm Linux based platform running a Yocto-based Linux system. It utilizes pulseaudio test app to encode file.
5+
This script automates the validation of audio recording capabilities on the Qualcomm Linux-based platform running a Yocto-based Linux system. It supports both PulseAudio and PipeWire backends for audio recording.
66

77
## Features
88

9-
- Encode PCM clip with --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0
9+
- Records PCM audio to '/tmp/rec1.wav' using either `parec` or `pw-record`
10+
- Automatically detects and sets PipeWire source ID if PipeWire is used
11+
- Uses `AUDIO_BACKEND` environment variable to select backend (default: pulseaudio)
12+
- Captures kernel logs before and after recording
13+
- Scans dmesg logs for audio-related errors
14+
- Supports configurable timeout and loop count for recording
15+
- Validates presence of required daemons and binaries
1016
- Compatible with Yocto-based root filesystem
1117

1218
## Prerequisites
1319

1420
Ensure the following components are present in the target Yocto build:
1521

16-
- `parec` binary(available at /usr/bin)
22+
- `parec` binary (for PulseAudio)
23+
- `pw-record`, `wpctl`, `grep`, `sed`, `timeout`, `pgrep` (for PipeWire)
24+
- `pulseaudio` or `pipewire` daemon must be running depending on backend
25+
1726

1827
## Directory Structure
1928

@@ -34,7 +43,7 @@ Instructions
3443

3544
1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.
3645

37-
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
46+
2. Verify Transfer: Ensure that the repo has been successfully copied to any directory on the target device.
3847

3948
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
4049

@@ -46,22 +55,33 @@ git clone <this-repo>
4655
cd <this-repo>
4756
scp -r Runner user@target_device_ip:<Path in device>
4857
ssh user@target_device_ip
49-
cd <Path in device>Runner && ./run-test.sh AudioRecord
58+
cd <Path in device>Runner
59+
**Run with PulseAudio**
60+
AUDIO_BACKEND=pulseaudio ./run-test.sh AudioRecord
61+
**Run with PipeWire**
62+
AUDIO_BACKEND=pipewire ./run-test.sh AudioRecord
63+
64+
Environment Variables:
65+
You can customize recording behavior using the following environment variables:
66+
AUDIO_BACKEND: Selects the audio backend (pulseaudio or pipewire). Default is pulseaudio.
67+
RECORD_TIMEOUT: Timeout duration for recording (e.g., 12s). Default is 12s.
68+
RECORD_LOOPS: Number of times to repeat recording. Default is 1.
5069
```
5170

5271
Sample Output:
5372
```
54-
sh-5.2# cd <Path in device>/Runner/ && ./run-test.sh AudioRecord
55-
[Executing test case: AudioRecord] 2025-05-28 19:03:33 -
56-
[INFO] 2025-05-28 19:03:33 - ------------------------------------------------------------
57-
[INFO] 2025-05-28 19:03:33 - ------------------- Starting AudioRecord Testcase ------------
58-
[INFO] 2025-05-28 19:03:33 - Checking if dependency binary is available
59-
[PASS] 2025-05-28 19:03:45 - Recording completed or timed out (ret=124) as expected and output file exists.
60-
[PASS] 2025-05-28 19:03:45 - AudioRecord : Test Passed
61-
[INFO] 2025-05-28 19:03:45 - See results/audiorecord/parec_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details
62-
[INFO] 2025-05-28 19:03:45 - ------------------- Completed AudioRecord Testcase -------------
63-
[PASS] 2025-05-28 19:03:45 - AudioRecord passed
64-
sh-5.2#
73+
sh-5.2# AUDIO_BACKEND=pipewire ./run-test.sh AudioRecord
74+
[Executing test case: AudioRecord] 2025-08-14 10:35:43 -
75+
[INFO] 2025-08-14 10:35:43 - ------------------------------------------------------------
76+
[INFO] 2025-08-14 10:35:43 - ------------------- Starting AudioRecord Testcase ------------
77+
[INFO] 2025-08-14 10:35:43 - Using audio backend: pipewire
78+
[INFO] 2025-08-14 10:35:43 - Checking if dependency binary is available
79+
[INFO] 2025-08-14 10:35:43 - Detected PipeWire source ID: 50
80+
[INFO] 2025-08-14 10:35:55 - Scanning dmesg for audio: errors & success patterns
81+
[INFO] 2025-08-14 10:35:55 - No audio-related errors found (no OK pattern requested)
82+
[PASS] 2025-08-14 10:35:55 - Recording completed or timed out (ret=124) as expected and output file exists.
83+
[PASS] 2025-08-14 10:35:55 - AudioRecord : Test Passed
84+
[PASS] 2025-08-14 10:35:55 - AudioRecord passed
6585
```
6686

6787
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioRecord/AudioRecord.res` directory.
@@ -77,3 +97,4 @@ sh-5.2#
7797

7898
SPDX-License-Identifier: BSD-3-Clause-Clear
7999
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
100+

0 commit comments

Comments
 (0)