Skip to content

Commit 4a24ae8

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 4a24ae8

File tree

6 files changed

+440
-204
lines changed

6 files changed

+440
-204
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

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
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
15+
- Compatible with Yocto-based root filesystem
1116

1217
## Prerequisites
1318

1419
Ensure the following components are present in the target Yocto build:
1520

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

1825
## Directory Structure
1926

2027
```bash
2128
Runner/
22-
├──suites/
23-
├ ├── Multimedia/
24-
│ ├ ├── Audio/
25-
│ ├ ├ ├── AudioPlayback/
26-
│ ├ ├ ├ ├ └── run.sh
27-
├ ├ ├ ├ ├ └── Read_me.md
29+
├── run-test.sh
30+
├── utils/
31+
│ ├── functestlib.sh
32+
│ └── libaudio.sh
33+
└── suites/
34+
└── Multimedia/
35+
└── Audio/
36+
├── AudioPlayback/
37+
├── run.sh
38+
└── Read_me.md
2839
```
2940

3041
## Usage
3142

32-
33-
Instructions
34-
43+
Instructions:
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.
36-
37-
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
38-
45+
2. Verify Transfer: Ensure that the repo has been successfully copied to any directory on the target device.
3946
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
4047

4148
Run a specific test using:
@@ -46,33 +53,64 @@ git clone <this-repo>
4653
cd <this-repo>
4754
scp -r Runner user@target_device_ip:<Path in device>
4855
ssh user@target_device_ip
49-
cd <Path in device>/Runner && ./run-test.sh AudioPlayback
56+
cd <Path in device>/Runner
57+
58+
**Run with PulseAudio**
59+
AUDIO_BACKEND=pulseaudio ./run-test.sh AudioPlayback
60+
AUDIO_BACKEND=pulseaudio PLAYBACK_TIMEOUT=20s PLAYBACK_LOOPS=2 PLAYBACK_VOLUME=5000 ./run-test.sh AudioPlayback
61+
cd Runner/suites/Multimedia/Audio/AudioPlayback && ./run.sh --backend pulseaudio --loops 2 --timeout 20s --volume 5000
62+
63+
**Run with PipeWire**
64+
AUDIO_BACKEND=pipewire ./run-test.sh AudioPlayback
65+
AUDIO_BACKEND=pipewire PLAYBACK_TIMEOUT=10s PLAYBACK_LOOPS=3 PLAYBACK_VOLUME=0.5 ./run-test.sh AudioPlayback
66+
cd Runner/suites/Multimedia/Audio/AudioPlayback && ./run.sh --backend pipewire --loops 3 --timeout 10s --volume 0.5
67+
68+
Environment Variables:
69+
You can customize playback behavior using the following environment variables:
70+
AUDIO_BACKEND: Selects the audio backend (pulseaudio or pipewire). Default is PipeWire.
71+
PLAYBACK_TIMEOUT: Timeout duration for playback (e.g., 10s). Default is 15s.
72+
PLAYBACK_LOOPS: Number of times to repeat playback. Default is 1.
73+
PLAYBACK_VOLUME: Playback volume.
74+
For paplay: Range is 0–65536 (default: 65536)
75+
For pw-play: Range is 0.0–1.0 (default: 1.0)
76+
77+
CLI Options
78+
Option Description
79+
--backend Select audio backend: pulseaudio or pipewire
80+
--loops Number of playback loops
81+
--timeout Playback timeout duration (e.g., 15s)
82+
--volume Volume level (PA: 0-65536, PW: 0.0-1.0)
83+
--help Show usage instructions
84+
5085
```
5186
Sample Output:
5287
```
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#
88+
sh-5.2# AUDIO_BACKEND=pipewire ./run-test.sh AudioPlayback
89+
[Executing test case: AudioPlayback] 2025-09-04 09:13:06 -
90+
[INFO] 2025-09-04 09:13:06 - ---------------- Starting AudioPlayback Testcase ----------------
91+
[INFO] 2025-09-04 09:13:06 - Using audio backend: pipewire
92+
[INFO] 2025-09-04 09:13:06 - Playback clip present: AudioClips/yesterday_48KHz.wav
93+
[INFO] 2025-09-04 09:13:06 - Playback loop 1 of 1
94+
[WARN] 2025-09-04 09:13:21 - Playback loop 1: Timed out (ret=124)
95+
[INFO] 2025-09-04 09:13:21 - Scanning dmesg for audio: errors & success patterns
96+
[INFO] 2025-09-04 09:13:21 - No audio-related errors found (no OK pattern requested)
97+
[PASS] 2025-09-04 09:13:21 - Audio playback test completed successfully
98+
[PASS] 2025-09-04 09:13:21 - AudioPlayback passed
6599
```
66-
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res` directory.
100+
101+
Results:
102+
Results are stored in: results/AudioPlayback/
103+
Summary result file: AudioPlayback.res
67104

68105

69106
## Notes
70107

71-
- The script does not take any arguments.
72-
- It validates the presence of required libraries before executing tests.
108+
- The script validates the presence of required libraries before executing tests.
73109
- If any critical tool is missing, the script exits with an error message.
110+
- Logs include dmesg_before.log, dmesg_after.log, and playback_stdout.log.
74111

75112
## License
76113

77114
SPDX-License-Identifier: BSD-3-Clause-Clear
78115
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
116+
Lines changed: 49 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,66 @@
11
#!/bin/sh
2-
3-
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
42
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
54

6-
# --------- Robustly source init_env and functestlib.sh ----------
75
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6+
7+
# Locate and source init_env
88
INIT_ENV=""
99
SEARCH="$SCRIPT_DIR"
1010
while [ "$SEARCH" != "/" ]; do
11-
if [ -f "$SEARCH/init_env" ]; then
12-
INIT_ENV="$SEARCH/init_env"
13-
break
14-
fi
15-
SEARCH=$(dirname "$SEARCH")
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
1616
done
17+
[ -z "$INIT_ENV" ] && echo "[ERROR] init_env not found" && exit 1
18+
# shellcheck source=/dev/null
19+
[ -z "$__INIT_ENV_LOADED" ] && . "$INIT_ENV"
1720

18-
if [ -z "$INIT_ENV" ]; then
19-
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20-
exit 1
21-
fi
22-
23-
if [ -z "$__INIT_ENV_LOADED" ]; then
24-
# shellcheck disable=SC1090
25-
. "$INIT_ENV"
26-
fi
27-
# shellcheck disable=SC1090,SC1091
2821
. "$TOOLS/functestlib.sh"
29-
# ---------------------------------------------------------------
30-
31-
TESTNAME="AudioPlayback"
32-
TESTBINARY="paplay"
33-
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/Pulse-Audio-Files-v1.0/AudioClips.tar.gz"
34-
PLAYBACK_CLIP="AudioClips/yesterday_48KHz.wav"
35-
AUDIO_DEVICE="low-latency0"
36-
LOGDIR="results/audioplayback"
37-
RESULT_FILE="$TESTNAME.res"
22+
. "$TOOLS/libaudio.sh"
3823

39-
test_path=$(find_test_case_by_name "$TESTNAME")
40-
cd "$test_path" || exit 1
24+
# Override with BusyBox-compatible version
25+
check_network_status() {
26+
ip addr | awk '/state UP/ {iface=$2} /inet / {if (iface) print iface; iface=""}' | cut -d: -f1 | head -n 1
27+
}
4128

42-
# Prepare logdir
43-
mkdir -p "$LOGDIR"
44-
chmod -R 777 "$LOGDIR"
45-
46-
log_info "------------------------------------------------------------"
47-
log_info "------------------- Starting $TESTNAME Testcase ------------"
48-
49-
log_info "Checking if dependency binary is available"
50-
check_dependencies "$TESTBINARY" pgrep grep timeout
51-
52-
# Download/extract audio if not present
53-
if [ ! -f "$PLAYBACK_CLIP" ]; then
54-
log_info "Audio clip not found, downloading..."
55-
extract_tar_from_url "$TAR_URL" || {
56-
log_fail "Failed to fetch/extract playback audio tarball"
57-
echo "$TESTNAME FAIL" > "$RESULT_FILE"
58-
exit 1
59-
}
60-
fi
61-
62-
if [ ! -f "$PLAYBACK_CLIP" ]; then
63-
log_fail "Playback clip $PLAYBACK_CLIP not found after extraction."
64-
echo "$TESTNAME : FAIL" > "$RESULT_FILE"
65-
exit 1
66-
fi
67-
68-
log_info "Playback clip present: $PLAYBACK_CLIP"
29+
# Set TESTNAME
30+
TESTNAME="AudioPlayback"
6931

70-
# --- Capture logs BEFORE playback (for debugging) ---
71-
dmesg > "$LOGDIR/dmesg_before.log"
32+
# Usage help
33+
usage() {
34+
cat <<EOF
35+
Usage: $0 [options]
36+
37+
Options:
38+
--backend {pulseaudio|pipewire}
39+
--loops N
40+
--timeout SECS
41+
--volume VAL (PA: 0-65536, PW: 0.0-1.0)
42+
EOF
43+
}
44+
45+
# Parse CLI args
46+
while [ $# -gt 0 ]; do
47+
case "$1" in
48+
--backend) export AUDIO_BACKEND="$2"; shift 2 ;;
49+
--loops) export PLAYBACK_LOOPS="$2"; shift 2 ;;
50+
--timeout) export PLAYBACK_TIMEOUT="$2"; shift 2 ;;
51+
--volume) export PLAYBACK_VOLUME="$2"; shift 2 ;;
52+
--help) usage; exit 0 ;;
53+
*) echo "[ERROR] Unknown option: $1"; usage; exit 1 ;;
54+
esac
55+
done
7256

73-
# --- Start the Playback, capture output ---
74-
timeout 15s paplay "$PLAYBACK_CLIP" -d "$AUDIO_DEVICE" > "$LOGDIR/playback_stdout.log" 2>&1
75-
ret=$?
57+
# Fallback to env if not set
58+
export AUDIO_BACKEND="${AUDIO_BACKEND:-pipewire}"
7659

77-
# --- Capture logs AFTER playback (for debugging) ---
78-
dmesg > "$LOGDIR/dmesg_after.log"
60+
log_info "---------------- Starting $TESTNAME Testcase ----------------"
61+
log_info "Using audio backend: $AUDIO_BACKEND"
7962

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"
83-
echo "$TESTNAME PASS" > "$RESULT_FILE"
84-
exit 0
85-
else
86-
log_fail "$TESTBINARY playback exited with error code $ret"
87-
log_fail "$TESTNAME : Test Failed"
88-
echo "$TESTNAME FAIL" > "$RESULT_FILE"
89-
exit 1
90-
fi
63+
init_audio_env "$TESTNAME" "$AUDIO_BACKEND"
64+
audio_playback
9165

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

0 commit comments

Comments
 (0)