Skip to content

Commit 7fbc036

Browse files
committed
Fix: AudioPlayback no longer requires network when clips exist
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 Signed-off-by: Teja Swaroop Moida <tmoida@qti.qualcomm.com>
1 parent f680543 commit 7fbc036

File tree

4 files changed

+143
-64
lines changed

4 files changed

+143
-64
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ 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+
ENABLE_NETWORK_DOWNLOAD: false # Enable network download of missing audio files, default: false
2122
SSID: "" # Wi-Fi SSID for network connection, default: unset
2223
PASSWORD: "" # Wi-Fi password for network connection, default: unset
2324
NET_PROBE_ROUTE_IP: "1.1.1.1" # IP used for route probing, default: 1.1.1.1
@@ -27,5 +28,10 @@ run:
2728
steps:
2829
- REPO_PATH=$PWD
2930
- 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
31+
- |
32+
if [ "${ENABLE_NETWORK_DOWNLOAD}" = "true" ]; then
33+
./run.sh --backend "${AUDIO_BACKEND}" --sink "${SINK_CHOICE}" --formats "${FORMATS}" --durations "${DURATIONS}" --loops "${LOOPS}" --timeout "${TIMEOUT}" --enable-network-download --ssid "${SSID}" --password "${PASSWORD}" || true
34+
else
35+
./run.sh --backend "${AUDIO_BACKEND}" --sink "${SINK_CHOICE}" --formats "${FORMATS}" --durations "${DURATIONS}" --loops "${LOOPS}" --timeout "${TIMEOUT}" --ssid "${SSID}" --password "${PASSWORD}" || true
36+
fi
37+
- $REPO_PATH/Runner/utils/send-to-lava.sh AudioPlayback.res || true

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

Lines changed: 50 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,18 @@ 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+
94107
95108
**Directly from Test Directory**
96109
cd Runner/suites/Multimedia/Audio/AudioPlayback
@@ -112,38 +125,41 @@ cd Runner/suites/Multimedia/Audio/AudioPlayback
112125
113126
114127
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
128+
Variable Description Default
129+
AUDIO_BACKEND Selects backend: pipewire or pulseaudio auto-detect
130+
SINK_CHOICE Playback sink: speakers or null speakers
131+
FORMATS Audio formats: e.g. wav wav
132+
DURATIONS Playback durations: short, medium, long short
133+
LOOPS Number of playback loops 1
134+
TIMEOUT Playback timeout per loop (e.g., 15s, 0=none) 0
135+
STRICT Enable strict mode (fail on any error) 0
136+
DMESG_SCAN Scan dmesg for errors after playback 1
137+
VERBOSE Enable verbose logging 0
138+
EXTRACT_AUDIO_ASSETS Download/extract audio assets if missing true
139+
ENABLE_NETWORK_DOWNLOAD Enable network download of missing audio files false
140+
141+
JUNIT_OUT Path to write JUnit XML output unset
142+
SSID Wi-Fi SSID for network connection unset
143+
PASSWORD Wi-Fi password for network connection unset
144+
NET_PROBE_ROUTE_IP IP used for route probing (default: 1.1.1.1) 1.1.1.1
145+
NET_PING_HOST Host used for ping reachability check 8.8.8.8
131146
132147
133148
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
149+
Option Description
150+
--backend Select backend: pipewire or pulseaudio
151+
--sink Playback sink: speakers or null
152+
--formats Audio formats (space/comma separated): e.g. wav
153+
--durations Playback durations: short, medium, long
154+
--loops Number of playback loops
155+
--timeout Playback timeout per loop (e.g., 15s)
156+
--strict Enable strict mode
157+
--no-dmesg Disable dmesg scan
158+
--no-extract-assets Disable asset extraction entirely (skips all asset operations)
159+
--enable-network-download Enable network operations to download missing audio files (default: disabled)
160+
--junit <file.xml> Write JUnit XML output
161+
--verbose Enable verbose logging
162+
--help Show usage instructions
147163
148164
```
149165

@@ -178,8 +194,10 @@ Diagnostic logs: dmesg snapshots, mixer dumps, playback logs per test case
178194
- The script validates the presence of required tools before executing tests; missing tools result in SKIP.
179195
- If any critical tool is missing, the script exits with an error message.
180196
- 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.
197+
- **Network operations are disabled by default**. Use `--enable-network-download` to download missing audio files.
198+
- Pass Wi-Fi credentials via `--ssid` and `--password` CLI flags (or SSID/PASSWORD environment variables) to auto-enable network download.
199+
- If audio clips are present locally, the test runs without any network operations (offline-capable).
200+
- If clips are missing and network download is disabled, the test will SKIP with a helpful message.
183201
- You can override default network probe targets using NET_PROBE_ROUTE_IP and NET_PING_HOST to avoid connectivity-related failures in restricted environments.
184202
- Evidence-based PASS/FAIL logic ensures reliability even if backend quirks occur.
185203

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

209+

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

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ 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
7071

7172
# Network bring-up knobs (match video behavior)
7273
if [ -z "${NET_STABILIZE_SLEEP:-}" ]; then
@@ -88,6 +89,7 @@ Usage: $0 [options]
8889
--durations "short|short medium|short medium long"
8990
--loops N
9091
--timeout SECS # set 0 to disable watchdog
92+
--enable-network-download
9193
--strict
9294
--no-dmesg
9395
--no-extract-assets
@@ -136,6 +138,10 @@ while [ $# -gt 0 ]; do
136138
EXTRACT_AUDIO_ASSETS=false
137139
shift
138140
;;
141+
--enable-network-download)
142+
ENABLE_NETWORK_DOWNLOAD=true
143+
shift
144+
;;
139145
--ssid)
140146
# shellcheck disable=SC2034
141147
SSID="$2"
@@ -161,6 +167,12 @@ while [ $# -gt 0 ]; do
161167
esac
162168
done
163169

170+
# Auto-enable network download if WiFi credentials provided
171+
if [ -n "$SSID" ] && [ -n "$PASSWORD" ]; then
172+
log_info "WiFi credentials provided, auto-enabling network download"
173+
ENABLE_NETWORK_DOWNLOAD=true
174+
fi
175+
164176
# Ensure we run from the testcase dir
165177
test_path="$(find_test_case_by_name "$TESTNAME" 2>/dev/null || echo "$SCRIPT_DIR")"
166178
if ! cd "$test_path"; then
@@ -178,7 +190,7 @@ else
178190
log_info "Platform Details: unknown"
179191
fi
180192

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"
193+
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"
182194

183195
# --- Rootfs minimum size check (mirror video policy) ---
184196
if [ "$TOP_LEVEL_RUN" -eq 1 ]; then
@@ -188,24 +200,40 @@ else
188200
fi
189201

190202
# --- Network preflight identical to video gating ---
203+
# --- Smart network gating: only connect if needed ---
191204
if [ "$TOP_LEVEL_RUN" -eq 1 ]; then
192205
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}"
206+
# First check: Do we have all files we need?
207+
if audio_check_clips_available "$FORMATS" "$DURATIONS"; then
208+
log_info "All required audio clips present locally, skipping network operations"
207209
else
208-
sleep "${NET_STABILIZE_SLEEP}"
210+
# Files missing - check if network download is enabled
211+
if [ "${ENABLE_NETWORK_DOWNLOAD}" = "true" ]; then
212+
log_info "Audio clips missing, network download enabled - bringing network online"
213+
NET_RC="1"
214+
215+
if command -v check_network_status_rc >/dev/null 2>&1; then
216+
check_network_status_rc
217+
NET_RC="$?"
218+
elif command -v check_network_status >/dev/null 2>&1; then
219+
check_network_status >/dev/null 2>&1
220+
NET_RC="$?"
221+
fi
222+
223+
if [ "$NET_RC" -ne 0 ]; then
224+
video_step "" "Bring network online (Wi-Fi credentials if provided)"
225+
ensure_network_online || true
226+
sleep "${NET_STABILIZE_SLEEP}"
227+
else
228+
sleep "${NET_STABILIZE_SLEEP}"
229+
fi
230+
else
231+
log_skip "$TESTNAME SKIP - Required audio clips not found locally and network download disabled"
232+
log_info "To download audio clips, run with: --enable-network-download"
233+
log_info "Or manually download from: $AUDIO_TAR_URL"
234+
echo "$TESTNAME SKIP" >"$RES_FILE"
235+
exit 0
236+
fi
209237
fi
210238
fi
211239
else
@@ -326,22 +354,29 @@ for fmt in $FORMATS; do
326354
if [ "${EXTRACT_AUDIO_ASSETS}" = "true" ]; then
327355
if [ -f "$clip" ] && [ -s "$clip" ]; then
328356
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."
357+
log_info "[$case_name] Using local clip: $clip (${CLIP_BYTES} bytes)"
330358
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"
359+
# Clip missing - check if network download is enabled
360+
if [ "${ENABLE_NETWORK_DOWNLOAD}" = "true" ]; then
361+
log_info "[$case_name] Clip missing, attempting download: $clip"
362+
log_info "[$case_name] Fetching from: $AUDIO_TAR_URL"
363+
364+
audio_ensure_clip_ready "$clip" "$AUDIO_TAR_URL"
365+
rc=$?
366+
367+
if [ "$rc" -eq 0 ] && [ -f "$clip" ]; then
368+
CLIP_BYTES="$(wc -c < "$clip" 2>/dev/null || echo 0)"
369+
log_info "[$case_name] Clip downloaded: $clip (${CLIP_BYTES} bytes)"
370+
else
371+
log_skip "[$case_name] SKIP: Clip download failed (rc=$rc)"
372+
echo "$case_name SKIP (download failed)" >> "$LOGDIR/summary.txt"
373+
skip=$((skip + 1))
374+
continue
375+
fi
376+
else
377+
log_skip "[$case_name] SKIP: Clip missing and network download disabled"
378+
log_info "[$case_name] Run with --enable-network-download to download missing clips"
379+
echo "$case_name SKIP (clip missing, no network)" >> "$LOGDIR/summary.txt"
345380
skip=$((skip + 1))
346381
continue
347382
fi

Runner/utils/audio_common.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,3 +735,22 @@ alsa_pick_virtual_pcm() {
735735
done
736736
return 1
737737
}
738+
739+
740+
# Check if all required audio clips are available locally
741+
# Usage: audio_check_clips_available "$FORMATS" "$DURATIONS"
742+
# Returns: 0 if all clips present, 1 if any clip missing
743+
audio_check_clips_available() {
744+
formats="$1"
745+
durations="$2"
746+
747+
for fmt in $formats; do
748+
for dur in $durations; do
749+
clip="$(resolve_clip "$fmt" "$dur")"
750+
if [ -n "$clip" ] && [ ! -f "$clip" ]; then
751+
return 1 # At least one clip missing
752+
fi
753+
done
754+
done
755+
return 0 # All clips present
756+
}

0 commit comments

Comments
 (0)