Skip to content

Commit 9e141bf

Browse files
committed
Resolves #229
Problem: AudioPlayback test was forcing network connections even when audio files were already present locally, causing tests to fail in offline environments. Solution: - Add --enable-network-download flag (opt-in, default: disabled) - Add audio_check_clips_available() to check files before network ops - Implement smart network gating: only connect if files missing AND flag enabled - Auto-enable network download when WiFi credentials provided via CLI - Remove SSID and PASSWORD parameters from AudioPlayback.yaml - Add AUDIO_CLIPS_BASE_DIR parameter for CI to provide custom clips location - Add --audio-clips-path CLI flag to run.sh for manual use - Update resolve_clip() in audio_common.sh to support custom base directory This allows CI to pre-stage audio clips at a custom location and provide the path via AUDIO_CLIPS_BASE_DIR parameter, eliminating the need for WiFi credentials in YAML configuration while preserving manual testing capabilities. Signed-off-by: Teja Swaroop Moida <tmoida@qti.qualcomm.com>
1 parent f680543 commit 9e141bf

File tree

4 files changed

+165
-67
lines changed

4 files changed

+165
-67
lines changed

Runner/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@ params:
1818
DMESG_SCAN: 1 # Scan dmesg for errors after playback, default: 1
1919
VERBOSE: 0 # Enable verbose logging, default: 0
2020
EXTRACT_AUDIO_ASSETS: true # Download/extract audio assets if missing, default: true
21-
SSID: "" # Wi-Fi SSID for network connection, default: unset
22-
PASSWORD: "" # Wi-Fi password for network connection, default: unset
21+
ENABLE_NETWORK_DOWNLOAD: false # Enable network download of missing audio files, default: false
22+
AUDIO_CLIPS_BASE_DIR: "" # Custom path to pre-staged audio clips (for CI), default: unset
2323
NET_PROBE_ROUTE_IP: "1.1.1.1" # IP used for route probing, default: 1.1.1.1
2424
NET_PING_HOST: "8.8.8.8" # Host used for ping reachability check, default: 8.8.8.8
2525

2626
run:
2727
steps:
2828
- REPO_PATH=$PWD
2929
- cd Runner/suites/Multimedia/Audio/AudioPlayback/
30-
- ./run.sh --backend "${AUDIO_BACKEND}" --sink "${SINK_CHOICE}" --format "${FORMAT}" --durations "${DURATIONS}" --loops "${LOOPS}" --timeout "${TIMEOUT}" --strict "${STRICT}" --ssid "${SSID}" --password "${PASSWORD}" || true
31-
- $REPO_PATH/Runner/utils/send-to-lava.sh AudioPlayback.res || true
30+
- |
31+
if [ -n "${AUDIO_CLIPS_BASE_DIR}" ]; then
32+
./run.sh --backend "${AUDIO_BACKEND}" --sink "${SINK_CHOICE}" --formats "${FORMATS}" --durations "${DURATIONS}" --loops "${LOOPS}" --timeout "${TIMEOUT}" --audio-clips-path "${AUDIO_CLIPS_BASE_DIR}" || true
33+
else
34+
./run.sh --backend "${AUDIO_BACKEND}" --sink "${SINK_CHOICE}" --formats "${FORMATS}" --durations "${DURATIONS}" --loops "${LOOPS}" --timeout "${TIMEOUT}" || true
35+
fi
36+
- $REPO_PATH/Runner/utils/send-to-lava.sh AudioPlayback.res || true

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

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This suite automates the validation of audio playback capabilities on Qualcomm L
99

1010
- Supports **PipeWire** and **PulseAudio** backends
1111
- Plays audio clips with configurable format, duration, and loop count
12+
- **Network operations are optional**: By default, no network connection is attempted. Use `--enable-network-download` to enable downloading missing audio files
1213
- Automatically downloads and extracts audio assets if missing
1314
- Validates playback using multiple evidence sources:
1415
- PipeWire/PulseAudio streaming state
@@ -91,6 +92,23 @@ SSID="MyNetwork" PASSWORD="MyPassword" ./run-test.sh AudioPlayback
9192
# Override network probe targets (useful in restricted networks)
9293
NET_PROBE_ROUTE_IP=192.168.1.1 NET_PING_HOST=192.168.1.254 ./run-test.sh AudioPlayback
9394
95+
# Run without network (requires local clips)
96+
./run.sh
97+
98+
# Enable network download for missing clips
99+
./run.sh --enable-network-download
100+
101+
# Provide WiFi credentials (auto-enables download)
102+
./run.sh --ssid "MyNetwork" --password "MyPassword"
103+
104+
# Offline mode with local clips only
105+
./run.sh --no-extract-assets
106+
107+
# CI workflow: Use pre-staged clips at custom location
108+
./run.sh --audio-clips-path /tmp/ci-audio-staging/AudioClips
109+
110+
# CI workflow: Via environment variable
111+
AUDIO_CLIPS_BASE_DIR="/tmp/ci-audio-staging/AudioClips" ./run-test.sh AudioPlayback
94112
95113
**Directly from Test Directory**
96114
cd Runner/suites/Multimedia/Audio/AudioPlayback
@@ -112,38 +130,43 @@ cd Runner/suites/Multimedia/Audio/AudioPlayback
112130
113131
114132
Environment Variables:
115-
Variable Description Default
116-
AUDIO_BACKEND Selects backend: pipewire or pulseaudio auto-detect
117-
SINK_CHOICE Playback sink: speakers or null speakers
118-
FORMATS Audio formats: e.g. wav wav
119-
DURATIONS Playback durations: short, medium, long short
120-
LOOPS Number of playback loops 1
121-
TIMEOUT Playback timeout per loop (e.g., 15s, 0=none) 0
122-
STRICT Enable strict mode (fail on any error) 0
123-
DMESG_SCAN Scan dmesg for errors after playback 1
124-
VERBOSE Enable verbose logging 0
125-
EXTRACT_AUDIO_ASSETS Download/extract audio assets if missing true
126-
JUNIT_OUT Path to write JUnit XML output unset
127-
SSID Wi-Fi SSID for network connection unset
128-
PASSWORD Wi-Fi password for network connection unset
129-
NET_PROBE_ROUTE_IP IP used for route probing (default: 1.1.1.1) 1.1.1.1
130-
NET_PING_HOST Host used for ping reachability check 8.8.8.8
133+
Variable Description Default
134+
AUDIO_BACKEND Selects backend: pipewire or pulseaudio auto-detect
135+
SINK_CHOICE Playback sink: speakers or null speakers
136+
FORMATS Audio formats: e.g. wav wav
137+
DURATIONS Playback durations: short, medium, long short
138+
LOOPS Number of playback loops 1
139+
TIMEOUT Playback timeout per loop (e.g., 15s, 0=none) 0
140+
STRICT Enable strict mode (fail on any error) 0
141+
DMESG_SCAN Scan dmesg for errors after playback 1
142+
VERBOSE Enable verbose logging 0
143+
EXTRACT_AUDIO_ASSETS Download/extract audio assets if missing true
144+
ENABLE_NETWORK_DOWNLOAD Enable network download of missing audio files false
145+
AUDIO_CLIPS_BASE_DIR Custom path to pre-staged audio clips (CI use) unset
146+
147+
JUNIT_OUT Path to write JUnit XML output unset
148+
SSID Wi-Fi SSID for network connection unset
149+
PASSWORD Wi-Fi password for network connection unset
150+
NET_PROBE_ROUTE_IP IP used for route probing (default: 1.1.1.1) 1.1.1.1
151+
NET_PING_HOST Host used for ping reachability check 8.8.8.8
131152
132153
133154
CLI Options
134-
Option Description
135-
--backend Select backend: pipewire or pulseaudio
136-
--sink Playback sink: speakers or null
137-
--formats Audio formats (space/comma separated): e.g. wav
138-
--durations Playback durations: short, medium, long
139-
--loops Number of playback loops
140-
--timeout Playback timeout per loop (e.g., 15s)
141-
--strict Enable strict mode
142-
--no-dmesg Disable dmesg scan
143-
--no-extract-assets Disable asset extraction
144-
--junit <file.xml> Write JUnit XML output
145-
--verbose Enable verbose logging
146-
--help Show usage instructions
155+
Option Description
156+
--backend Select backend: pipewire or pulseaudio
157+
--sink Playback sink: speakers or null
158+
--formats Audio formats (space/comma separated): e.g. wav
159+
--durations Playback durations: short, medium, long
160+
--loops Number of playback loops
161+
--timeout Playback timeout per loop (e.g., 15s)
162+
--strict Enable strict mode
163+
--no-dmesg Disable dmesg scan
164+
--no-extract-assets Disable asset extraction entirely (skips all asset operations)
165+
--enable-network-download Enable network operations to download missing audio files (default: disabled)
166+
audio-clips-path <path> Custom location for audio clips (for CI with pre-staged clips)
167+
--junit <file.xml> Write JUnit XML output
168+
--verbose Enable verbose logging
169+
--help Show usage instructions
147170
148171
```
149172

@@ -178,8 +201,10 @@ Diagnostic logs: dmesg snapshots, mixer dumps, playback logs per test case
178201
- The script validates the presence of required tools before executing tests; missing tools result in SKIP.
179202
- If any critical tool is missing, the script exits with an error message.
180203
- Logs include dmesg snapshots, mixer dumps, and playback logs.
181-
- Asset download requires network connectivity.
182-
- Pass Wi-Fi credentials via SSID and PASSWORD environment variables to enable network access for asset downloads and playback validation.
204+
- **Network operations are disabled by default**. Use `--enable-network-download` to download missing audio files.
205+
- Pass Wi-Fi credentials via `--ssid` and `--password` CLI flags (or SSID/PASSWORD environment variables) to auto-enable network download.
206+
- If audio clips are present locally, the test runs without any network operations (offline-capable).
207+
- If clips are missing and network download is disabled, the test will SKIP with a helpful message.
183208
- You can override default network probe targets using NET_PROBE_ROUTE_IP and NET_PING_HOST to avoid connectivity-related failures in restricted environments.
184209
- Evidence-based PASS/FAIL logic ensures reliability even if backend quirks occur.
185210

@@ -188,3 +213,4 @@ Diagnostic logs: dmesg snapshots, mixer dumps, playback logs per test case
188213
SPDX-License-Identifier: BSD-3-Clause-Clear
189214
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
190215

216+

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

Lines changed: 78 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ STRICT="${STRICT:-0}"
6767
DMESG_SCAN="${DMESG_SCAN:-1}"
6868
VERBOSE=0
6969
EXTRACT_AUDIO_ASSETS="${EXTRACT_AUDIO_ASSETS:-true}"
70+
ENABLE_NETWORK_DOWNLOAD="${ENABLE_NETWORK_DOWNLOAD:-false}" # Default: no network operations
71+
AUDIO_CLIPS_BASE_DIR="${AUDIO_CLIPS_BASE_DIR:-}" # Custom path for audio clips (CI use)
7072

7173
# Network bring-up knobs (match video behavior)
7274
if [ -z "${NET_STABILIZE_SLEEP:-}" ]; then
@@ -88,6 +90,8 @@ Usage: $0 [options]
8890
--durations "short|short medium|short medium long"
8991
--loops N
9092
--timeout SECS # set 0 to disable watchdog
93+
--enable-network-download
94+
--audio-clips-path PATH # Custom location for audio clips (CI use)
9195
--strict
9296
--no-dmesg
9397
--no-extract-assets
@@ -136,6 +140,14 @@ while [ $# -gt 0 ]; do
136140
EXTRACT_AUDIO_ASSETS=false
137141
shift
138142
;;
143+
--enable-network-download)
144+
ENABLE_NETWORK_DOWNLOAD=true
145+
shift
146+
;;
147+
--audio-clips-path)
148+
AUDIO_CLIPS_BASE_DIR="$2"
149+
shift 2
150+
;;
139151
--ssid)
140152
# shellcheck disable=SC2034
141153
SSID="$2"
@@ -161,6 +173,12 @@ while [ $# -gt 0 ]; do
161173
esac
162174
done
163175

176+
# Auto-enable network download if WiFi credentials provided
177+
if [ -n "$SSID" ] && [ -n "$PASSWORD" ]; then
178+
log_info "WiFi credentials provided, auto-enabling network download"
179+
ENABLE_NETWORK_DOWNLOAD=true
180+
fi
181+
164182
# Ensure we run from the testcase dir
165183
test_path="$(find_test_case_by_name "$TESTNAME" 2>/dev/null || echo "$SCRIPT_DIR")"
166184
if ! cd "$test_path"; then
@@ -178,7 +196,13 @@ else
178196
log_info "Platform Details: unknown"
179197
fi
180198

181-
log_info "Args: backend=${AUDIO_BACKEND:-auto} sink=$SINK_CHOICE loops=$LOOPS timeout=$TIMEOUT formats='$FORMATS' durations='$DURATIONS' strict=$STRICT dmesg=$DMESG_SCAN extract=$EXTRACT_AUDIO_ASSETS"
199+
# Export AUDIO_CLIPS_BASE_DIR for use by resolve_clip() in audio_common.sh
200+
if [ -n "$AUDIO_CLIPS_BASE_DIR" ]; then
201+
export AUDIO_CLIPS_BASE_DIR
202+
log_info "Using custom audio clips path: $AUDIO_CLIPS_BASE_DIR"
203+
fi
204+
205+
log_info "Args: backend=${AUDIO_BACKEND:-auto} sink=$SINK_CHOICE loops=$LOOPS timeout=$TIMEOUT formats='$FORMATS' durations='$DURATIONS' strict=$STRICT dmesg=$DMESG_SCAN extract=$EXTRACT_AUDIO_ASSETS network_download=$ENABLE_NETWORK_DOWNLOAD clips_path=${AUDIO_CLIPS_BASE_DIR:-default}"
182206

183207
# --- Rootfs minimum size check (mirror video policy) ---
184208
if [ "$TOP_LEVEL_RUN" -eq 1 ]; then
@@ -188,24 +212,40 @@ else
188212
fi
189213

190214
# --- Network preflight identical to video gating ---
215+
# --- Smart network gating: only connect if needed ---
191216
if [ "$TOP_LEVEL_RUN" -eq 1 ]; then
192217
if [ "${EXTRACT_AUDIO_ASSETS}" = "true" ]; then
193-
NET_RC="1"
194-
195-
if command -v check_network_status_rc >/dev/null 2>&1; then
196-
check_network_status_rc
197-
NET_RC="$?"
198-
elif command -v check_network_status >/dev/null 2>&1; then
199-
check_network_status >/dev/null 2>&1
200-
NET_RC="$?"
201-
fi
202-
203-
if [ "$NET_RC" -ne 0 ]; then
204-
video_step "" "Bring network online (Wi-Fi credentials if provided)"
205-
ensure_network_online || true
206-
sleep "${NET_STABILIZE_SLEEP}"
218+
# First check: Do we have all files we need?
219+
if audio_check_clips_available "$FORMATS" "$DURATIONS"; then
220+
log_info "All required audio clips present locally, skipping network operations"
207221
else
208-
sleep "${NET_STABILIZE_SLEEP}"
222+
# Files missing - check if network download is enabled
223+
if [ "${ENABLE_NETWORK_DOWNLOAD}" = "true" ]; then
224+
log_info "Audio clips missing, network download enabled - bringing network online"
225+
NET_RC="1"
226+
227+
if command -v check_network_status_rc >/dev/null 2>&1; then
228+
check_network_status_rc
229+
NET_RC="$?"
230+
elif command -v check_network_status >/dev/null 2>&1; then
231+
check_network_status >/dev/null 2>&1
232+
NET_RC="$?"
233+
fi
234+
235+
if [ "$NET_RC" -ne 0 ]; then
236+
video_step "" "Bring network online (Wi-Fi credentials if provided)"
237+
ensure_network_online || true
238+
sleep "${NET_STABILIZE_SLEEP}"
239+
else
240+
sleep "${NET_STABILIZE_SLEEP}"
241+
fi
242+
else
243+
log_skip "$TESTNAME SKIP - Required audio clips not found locally and network download disabled"
244+
log_info "To download audio clips, run with: --enable-network-download"
245+
log_info "Or manually download from: $AUDIO_TAR_URL"
246+
echo "$TESTNAME SKIP" >"$RES_FILE"
247+
exit 0
248+
fi
209249
fi
210250
fi
211251
else
@@ -326,22 +366,29 @@ for fmt in $FORMATS; do
326366
if [ "${EXTRACT_AUDIO_ASSETS}" = "true" ]; then
327367
if [ -f "$clip" ] && [ -s "$clip" ]; then
328368
CLIP_BYTES="$(wc -c < "$clip" 2>/dev/null || echo 0)"
329-
log_info "[$case_name] Clip already present: $clip (${CLIP_BYTES} bytes) — skipping fetch/extract."
369+
log_info "[$case_name] Using local clip: $clip (${CLIP_BYTES} bytes)"
330370
else
331-
log_info "[$case_name] Preparing assets for clip: $clip (not found locally)"
332-
log_info "[$case_name] Attempting fetch/extract from: $AUDIO_TAR_URL"
333-
334-
audio_ensure_clip_ready "$clip" "$AUDIO_TAR_URL"
335-
rc=$?
336-
337-
if [ "$rc" -eq 0 ] && [ -f "$clip" ]; then
338-
CLIP_BYTES="$(wc -c < "$clip" 2>/dev/null || echo 0)"
339-
log_info "[$case_name] Clip ready: $clip (${CLIP_BYTES} bytes)"
340-
fi
341-
342-
if [ "$rc" -eq 2 ] || [ "$rc" -eq 1 ]; then
343-
log_skip "[$case_name] SKIP: Required clip missing and network unavailable or fetch failed."
344-
echo "$case_name SKIP (clip missing)" >> "$LOGDIR/summary.txt"
371+
# Clip missing - check if network download is enabled
372+
if [ "${ENABLE_NETWORK_DOWNLOAD}" = "true" ]; then
373+
log_info "[$case_name] Clip missing, attempting download: $clip"
374+
log_info "[$case_name] Fetching from: $AUDIO_TAR_URL"
375+
376+
audio_ensure_clip_ready "$clip" "$AUDIO_TAR_URL"
377+
rc=$?
378+
379+
if [ "$rc" -eq 0 ] && [ -f "$clip" ]; then
380+
CLIP_BYTES="$(wc -c < "$clip" 2>/dev/null || echo 0)"
381+
log_info "[$case_name] Clip downloaded: $clip (${CLIP_BYTES} bytes)"
382+
else
383+
log_skip "[$case_name] SKIP: Clip download failed (rc=$rc)"
384+
echo "$case_name SKIP (download failed)" >> "$LOGDIR/summary.txt"
385+
skip=$((skip + 1))
386+
continue
387+
fi
388+
else
389+
log_skip "[$case_name] SKIP: Clip missing and network download disabled"
390+
log_info "[$case_name] Run with --enable-network-download to download missing clips"
391+
echo "$case_name SKIP (clip missing, no network)" >> "$LOGDIR/summary.txt"
345392
skip=$((skip + 1))
346393
continue
347394
fi

Runner/utils/audio_common.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ check_audio_daemon() {
3030

3131
# ---------- Assets / clips ----------
3232
resolve_clip() {
33-
fmt="$1"; dur="$2"; base="AudioClips"
33+
fmt="$1"; dur="$2"
34+
base="${AUDIO_CLIPS_BASE_DIR:-AudioClips}"
3435
case "$fmt:$dur" in
3536
wav:short|wav:medium|wav:long) printf '%s\n' "$base/yesterday_48KHz.wav" ;;
3637
*) printf '%s\n' "" ;;
@@ -735,3 +736,22 @@ alsa_pick_virtual_pcm() {
735736
done
736737
return 1
737738
}
739+
740+
741+
# Check if all required audio clips are available locally
742+
# Usage: audio_check_clips_available "$FORMATS" "$DURATIONS"
743+
# Returns: 0 if all clips present, 1 if any clip missing
744+
audio_check_clips_available() {
745+
formats="$1"
746+
durations="$2"
747+
748+
for fmt in $formats; do
749+
for dur in $durations; do
750+
clip="$(resolve_clip "$fmt" "$dur")"
751+
if [ -n "$clip" ] && [ ! -f "$clip" ]; then
752+
return 1 # At least one clip missing
753+
fi
754+
done
755+
done
756+
return 0 # All clips present
757+
}

0 commit comments

Comments
 (0)