Skip to content

Commit fdf7037

Browse files
authored
Merge pull request qualcomm-linux#172 from tmoida/patch-1
Audio: Add Network Bring-Up and Fix SKIP Handling
2 parents 449ba39 + 703a6eb commit fdf7037

File tree

5 files changed

+296
-15
lines changed

5 files changed

+296
-15
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ This suite automates the validation of audio playback capabilities on Qualcomm L
77

88
## Features
99

10-
1110
- Supports **PipeWire** and **PulseAudio** backends
1211
- Plays audio clips with configurable format, duration, and loop count
1312
- Automatically downloads and extracts audio assets if missing
@@ -63,22 +62,45 @@ ssh user@target_device_ip
6362
6463
**Using Unified Runner**
6564
cd <Path in device>/Runner
65+
6666
# Run AudioPlayback using PipeWire (auto-detects backend if not specified)
6767
./run-test.sh AudioPlayback
68+
6869
# Force PulseAudio backend
6970
AUDIO_BACKEND=pulseaudio ./run-test.sh AudioPlayback
71+
7072
# Custom options via environment variables
7173
AUDIO_BACKEND=pipewire PLAYBACK_TIMEOUT=20s PLAYBACK_LOOPS=2 ./run-test.sh AudioPlayback
7274
75+
# Disable asset extraction (offline mode)
76+
EXTRACT_AUDIO_ASSETS=false ./run-test.sh AudioPlayback
77+
78+
# Provide Wi-Fi credentials for asset download
79+
SSID="MyNetwork" PASSWORD="MyPassword" ./run-test.sh AudioPlayback
80+
81+
# Override network probe targets (useful in restricted networks)
82+
NET_PROBE_ROUTE_IP=192.168.1.1 NET_PING_HOST=192.168.1.254 ./run-test.sh AudioPlayback
83+
84+
7385
**Directly from Test Directory**
7486
cd Runner/suites/Multimedia/Audio/AudioPlayback
7587
# Show usage/help
7688
./run.sh --help
89+
7790
# Run with PipeWire, 3 loops, 10s timeout, speakers sink
7891
./run.sh --backend pipewire --sink speakers --loops 3 --timeout 10s
92+
7993
# Run with PulseAudio, null sink, strict mode, verbose
8094
./run.sh --backend pulseaudio --sink null --strict --verbose
8195
96+
# Disable asset extraction (offline mode)
97+
./run.sh --no-extract-assets
98+
99+
# Provide JUnit output and disable dmesg scan
100+
./run.sh --junit results.xml --no-dmesg
101+
102+
103+
82104
Environment Variables:
83105
Variable Description Default
84106
AUDIO_BACKEND Selects backend: pipewire or pulseaudio auto-detect
@@ -92,6 +114,11 @@ DMESG_SCAN Scan dmesg for errors after playback 1
92114
VERBOSE Enable verbose logging 0
93115
EXTRACT_AUDIO_ASSETS Download/extract audio assets if missing true
94116
JUNIT_OUT Path to write JUnit XML output unset
117+
SSID Wi-Fi SSID for network connection unset
118+
PASSWORD Wi-Fi password for network connection unset
119+
NET_PROBE_ROUTE_IP IP used for route probing (default: 1.1.1.1) 1.1.1.1
120+
NET_PING_HOST Host used for ping reachability check 8.8.8.8
121+
95122
96123
CLI Options
97124
Option Description
@@ -142,6 +169,8 @@ Diagnostic logs: dmesg snapshots, mixer dumps, playback logs per test case
142169
- If any critical tool is missing, the script exits with an error message.
143170
- Logs include dmesg snapshots, mixer dumps, and playback logs.
144171
- Asset download requires network connectivity.
172+
- Pass Wi-Fi credentials via SSID and PASSWORD environment variables to enable network access for asset downloads and playback validation.
173+
- You can override default network probe targets using NET_PROBE_ROUTE_IP and NET_PING_HOST to avoid connectivity-related failures in restricted environments.
145174
- Evidence-based PASS/FAIL logic ensures reliability even if backend quirks occur.
146175

147176
## License

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,15 @@ for fmt in $FORMATS; do
175175
fi
176176

177177
if [ "${EXTRACT_AUDIO_ASSETS:-true}" = "true" ]; then
178-
ensure_playback_clip "$clip" || {
179-
log_warn "[$case_name] Clip missing and could not be fetched: $clip"
180-
echo "$case_name SKIP (clip missing)" >> "$LOGDIR/summary.txt"
181-
append_junit "$case_name" "0" "SKIP" "$logf"; skip=$((skip + 1)); continue
182-
}
178+
audio_ensure_clip_ready "$clip" "$AUDIO_TAR_URL"
179+
rc=$?
180+
if [ "$rc" -eq 2 ] || [ "$rc" -eq 1 ]; then
181+
log_skip "[$case_name] SKIP: Required clip missing and network unavailable or fetch failed."
182+
echo "$case_name SKIP (clip missing)" >> "$LOGDIR/summary.txt"
183+
append_junit "$case_name" "0" "SKIP" "$logf"
184+
skip=$((skip + 1))
185+
continue
186+
fi
183187
fi
184188

185189
i=1; ok_runs=0; last_elapsed=0
@@ -274,7 +278,9 @@ if [ -n "$JUNIT_OUT" ]; then
274278
log_info "Wrote JUnit: $JUNIT_OUT"
275279
fi
276280

277-
if [ "$suite_rc" -eq 0 ]; then
281+
if [ "$pass" -eq 0 ] && [ "$fail" -eq 0 ] && [ "$skip" -gt 0 ]; then
282+
log_skip "$TESTNAME SKIP"; echo "$TESTNAME SKIP" > "$RES_FILE"
283+
elif [ "$suite_rc" -eq 0 ]; then
278284
log_pass "$TESTNAME PASS"; echo "$TESTNAME PASS" > "$RES_FILE"
279285
else
280286
log_fail "$TESTNAME FAIL"; echo "$TESTNAME FAIL" > "$RES_FILE"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,26 @@ ssh user@target_device_ip
6363
6464
**Using Unified Runner**
6565
cd <Path in device>Runner
66+
6667
# Run Audiorecord using PipeWire (auto-detects backend if not specified)
6768
./run-test.sh Audiorecord
69+
6870
# Force PulseAudio backend
6971
AUDIO_BACKEND=pulseaudio ./run-test.sh Audiorecord
72+
7073
# Custom options via environment variables
7174
AUDIO_BACKEND=pipewire RECORD_TIMEOUT=20s RECORD_LOOPS=2 RECORD_VOLUME=0.5 ./run-test.sh Audiorecord
7275
76+
7377
**Directly from Test Directory**
7478
cd Runner/suites/Multimedia/Audio/Audiorecord
79+
7580
# Show usage/help
7681
./run.sh --help
82+
7783
# Run with PipeWire, 3 loops, 10s timeout, mic source
7884
./run.sh --backend pipewire --source mic --loops 3 --timeout 10s
85+
7986
# Run with PulseAudio, null source, strict mode, verbose
8087
./run.sh --backend pulseaudio --source null --strict --verbose
8188
@@ -93,6 +100,7 @@ DMESG_SCAN Scan dmesg for errors after recording 1
93100
VERBOSE Enable verbose logging 0
94101
JUNIT_OUT Path to write JUnit XML output unset
95102
103+
96104
CLI Options:
97105
Option Description
98106
--backend Select backend: pipewire or pulseaudio

Runner/utils/audio_common.sh

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,64 @@ resolve_clip() {
3737
esac
3838
}
3939

40-
ensure_playback_clip() {
41-
clip="$1"
42-
[ -f "$clip" ] && return 0
43-
if [ -n "$AUDIO_TAR_URL" ]; then
44-
log_info "Audio clip missing, extracting from $AUDIO_TAR_URL"
45-
extract_tar_from_url "$AUDIO_TAR_URL" || return 1
46-
fi
47-
[ -f "$clip" ]
40+
# audio_download_with_any <url> <outfile>
41+
audio_download_with_any() {
42+
url="$1"; out="$2"
43+
if command -v wget >/dev/null 2>&1; then
44+
wget -O "$out" "$url"
45+
elif command -v curl >/dev/null 2>&1; then
46+
curl -L --fail -o "$out" "$url"
47+
else
48+
log_error "No downloader (wget/curl) available to fetch $url"
49+
return 1
50+
fi
51+
}
52+
# audio_fetch_assets_from_url <url>
53+
# Prefer functestlib's extract_tar_from_url; otherwise download + extract.
54+
audio_fetch_assets_from_url() {
55+
url="$1"
56+
if command -v extract_tar_from_url >/dev/null 2>&1; then
57+
extract_tar_from_url "$url"
58+
return $?
59+
fi
60+
fname="$(basename "$url")"
61+
log_info "Fetching assets: $url"
62+
if ! audio_download_with_any "$url" "$fname"; then
63+
log_warn "Download failed: $url"
64+
return 1
65+
fi
66+
tar -xzf "$fname" >/dev/null 2>&1 || tar -xf "$fname" >/dev/null 2>&1 || {
67+
log_warn "Extraction failed: $fname"
68+
return 1
69+
}
70+
return 0
71+
}
72+
# audio_ensure_clip_ready <clip-path> [tarball-url]
73+
# Return codes:
74+
# 0 = clip exists/ready
75+
# 2 = network unavailable after attempts (caller should SKIP)
76+
# 1 = fetch/extract/downloader error (caller will also SKIP per your policy)
77+
audio_ensure_clip_ready() {
78+
clip="$1"
79+
url="${2:-${AUDIO_TAR_URL:-}}"
80+
[ -f "$clip" ] && return 0
81+
# Try once without forcing network (tarball may already be present)
82+
if [ -n "$url" ]; then
83+
audio_fetch_assets_from_url "$url" >/dev/null 2>&1 || true
84+
[ -f "$clip" ] && return 0
85+
fi
86+
# Bring network up and retry once
87+
if ! ensure_network_online; then
88+
log_warn "Network unavailable; cannot fetch audio assets for $clip"
89+
return 2
90+
fi
91+
if [ -n "$url" ]; then
92+
if audio_fetch_assets_from_url "$url" >/dev/null 2>&1; then
93+
[ -f "$clip" ] && return 0
94+
fi
95+
fi
96+
log_warn "Clip fetch/extract failed for $clip"
97+
return 1
4898
}
4999

50100
# ---------- dmesg + mixer dumps ----------

0 commit comments

Comments
 (0)