Skip to content

Commit 37ac48e

Browse files
committed
Audio: improve record/playback tests using shared directory handling
- Use common recorded directory across audio tests - Update run.sh and YAML for consistent folder handling - Allow individual test execution - Address review feedback# This is the 1st commit message: Audio: fix/update record‑playback test to use shared recorded directory Signed-off-by: Nitin Nakka <nitinn@qti.qualcomm.com> addressed comments related to making common util for folder handling for video and audio Signed-off-by: Nitin Nakka <nitinn@qti.qualcomm.com> added individual test case run possibility for audio suite Signed-off-by: Nitin Nakka <nitinn@qti.qualcomm.com> Modified yaml file to handle common directory structure for files Signed-off-by: Nitin Nakka <nitinn@qti.qualcomm.com> Modified run sh file to handle common dir Signed-off-by: Nitin Nakka <nitinn@qti.qualcomm.com> Modified Audio scripts based on comments received Signed-off-by: nitinn <nitinn@qti.qualcomm.com> audio: address final review comments Signed-off-by: nitinn <nitinn@qti.qualcomm.com>
1 parent 613074a commit 37ac48e

4 files changed

Lines changed: 263 additions & 80 deletions

File tree

Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/Audio_Record_Playback.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@ metadata:
55
Audio record/playback validation using GStreamer (gst-launch-1.0).
66
Tests 10 scenarios: 4 encode (2 audiotestsrc + 2 pulsesrc) + 6 decode (4 playback + 2 OGG/MP3).
77
Supports WAV, FLAC, OGG, and MP3 formats with both synthetic audio (audiotestsrc) and hardware capture (pulsesrc).
8-
Duration controlled via AUDIO_DURATION (default 10s): audiotestsrc uses num-buffers, pulsesrc uses timeout.
8+
Duration controlled via AUDIO_DURATION (default 10s): audiotestsrc uses num-buffers calculated after argument parsing, pulsesrc uses timeout.
9+
Uses AUDIO_SHARED_RECORDED_DIR for shared artifact storage across test runs.
910
os:
1011
- linux
1112
scope:
1213
- functional
1314

1415
params:
1516
AUDIO_TEST_MODE: "all"
17+
AUDIO_TEST_NAME: ""
1618
AUDIO_FORMATS: "wav,flac"
1719
AUDIO_DURATION: "10"
1820
AUDIO_GST_DEBUG: "2"
1921

2022
run:
2123
steps:
2224
- REPO_PATH="$PWD"
23-
- cd Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/
24-
- export AUDIO_TEST_MODE AUDIO_FORMATS AUDIO_DURATION AUDIO_GST_DEBUG
25-
- ./run.sh --mode "${AUDIO_TEST_MODE}" --formats "${AUDIO_FORMATS}" --duration "${AUDIO_DURATION}" --gst-debug "${AUDIO_GST_DEBUG}" || true
25+
- cd "$REPO_PATH/Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback"
26+
- AUDIO_SHARED_RECORDED_DIR="${REPO_PATH%%/tests/*}/shared/audio-record-playback"
27+
- export REPO_PATH AUDIO_SHARED_RECORDED_DIR AUDIO_TEST_MODE AUDIO_TEST_NAME AUDIO_FORMATS AUDIO_DURATION AUDIO_GST_DEBUG
28+
- ./run.sh || true
2629
- $REPO_PATH/Runner/utils/send-to-lava.sh Audio_Record_Playback.res

Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,39 @@ By default, logs are written relative to the script working directory:
131131
playback_flac.log
132132
playback_pulsesrc_wav.log
133133
playback_pulsesrc_flac.log
134-
recorded/ # Recorded audio files
135-
record_wav.wav
136-
record_flac.flac
137-
record_pulsesrc_wav.wav
138-
record_pulsesrc_flac.flac
139134
dmesg/ # dmesg scan outputs (if available)
140135
dmesg_errors.log
141136
```
142137

138+
### Recorded Audio Artifacts
139+
140+
Recorded audio files are stored in a shared directory to enable artifact reuse across test runs:
141+
142+
**Local/Manual Runs** (fallback):
143+
```
144+
./logs/Audio_Record_Playback/recorded/
145+
record_wav.wav
146+
record_flac.flac
147+
record_pulsesrc_wav.wav
148+
record_pulsesrc_flac.flac
149+
```
150+
151+
**CI/LAVA Runs** (shared path):
152+
```
153+
<repo_root>/shared/audio-record-playback/
154+
record_wav.wav
155+
record_flac.flac
156+
record_pulsesrc_wav.wav
157+
record_pulsesrc_flac.flac
158+
```
159+
160+
The recorded artifact directory is determined by:
161+
1. **Explicit override**: `AUDIO_SHARED_RECORDED_DIR` environment variable (if set)
162+
2. **LAVA/tests detection**: Shared path derived from repository structure (if script path contains `/tests/`)
163+
3. **Local fallback**: `./logs/Audio_Record_Playback/recorded/` (for manual runs)
164+
165+
This ensures that in CI/LAVA environments, recorded artifacts are placed in a shared location accessible across multiple test runs, while local/manual runs use a simple local directory.
166+
143167
---
144168

145169
## Dependencies
@@ -537,14 +561,19 @@ fi
537561
The test supports these environment variables (can be set in LAVA job definition):
538562

539563
- `AUDIO_TEST_MODE` - Test mode (all/record/playback) (default: all)
564+
- `AUDIO_TEST_NAME` - Individual test name for single test execution (optional)
540565
- `AUDIO_FORMATS` - Comma-separated format list (default: `wav,flac`)
541566
- `AUDIO_DURATION` - Recording duration in seconds (default: 10)
542567
- `RUNTIMESEC` - Alternative to AUDIO_DURATION (for backward compatibility)
543568
- `AUDIO_GST_DEBUG` - GStreamer debug level (default: 2)
544569
- `GST_DEBUG_LEVEL` - Alternative to AUDIO_GST_DEBUG
570+
- `AUDIO_SHARED_RECORDED_DIR` - Shared directory for recorded audio artifacts (optional)
571+
- `REPO_PATH` - Repository root path (set by YAML, used for path resolution)
545572

546573
**Priority order for duration**: `AUDIO_DURATION` > `RUNTIMESEC` > default (10)
547574

575+
**Shared Artifact Directory**: The test uses `AUDIO_SHARED_RECORDED_DIR` to store recorded audio files in a shared location across multiple test runs. If not set, the test will automatically determine the appropriate directory based on the environment (LAVA vs local).
576+
548577
### Test Counting
549578

550579
- **Total tests**: 10 (when running with default wav,flac formats in all mode)

Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/run.sh

Lines changed: 162 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ LOG_DIR="${SCRIPT_DIR}/logs"
4646
OUTDIR="$LOG_DIR/$TESTNAME"
4747
GST_LOG="$OUTDIR/gst.log"
4848
DMESG_DIR="$OUTDIR/dmesg"
49-
RECORDED_DIR="$OUTDIR/recorded"
5049

51-
mkdir -p "$OUTDIR" "$DMESG_DIR" "$RECORDED_DIR" >/dev/null 2>&1 || true
52-
: >"$RES_FILE"
53-
: >"$GST_LOG"
54-
5550
INIT_ENV=""
5651
SEARCH="$SCRIPT_DIR"
5752
while [ "$SEARCH" != "/" ]; do
@@ -80,6 +75,35 @@ fi
8075
# shellcheck disable=SC1091
8176
. "$TOOLS/lib_gstreamer.sh"
8277

78+
# Create required directories now that log functions are available
79+
if ! mkdir -p "$OUTDIR" "$DMESG_DIR"; then
80+
log_error "Failed to create required directories:"
81+
log_error " OUTDIR=$OUTDIR"
82+
log_error " DMESG_DIR=$DMESG_DIR"
83+
echo "$TESTNAME FAIL" >"$RES_FILE" 2>/dev/null || true
84+
exit 0
85+
fi
86+
: >"$RES_FILE"
87+
: >"$GST_LOG"
88+
89+
# -------------------- Set up shared recorded directory --------------------
90+
# Use gstreamer_shared_recorded_dir() as single source of truth for directory resolution
91+
# Priority: 1) AUDIO_SHARED_RECORDED_DIR env var, 2) LAVA/tests shared path, 3) local fallback
92+
if [ -n "${AUDIO_SHARED_RECORDED_DIR:-}" ]; then
93+
RECORDED_DIR="$AUDIO_SHARED_RECORDED_DIR"
94+
elif command -v gstreamer_shared_recorded_dir >/dev/null 2>&1; then
95+
RECORDED_DIR="$(gstreamer_shared_recorded_dir "$SCRIPT_DIR" "$OUTDIR")"
96+
else
97+
RECORDED_DIR="$OUTDIR/recorded"
98+
fi
99+
100+
# Create the recorded directory
101+
if ! mkdir -p "$RECORDED_DIR"; then
102+
log_error "Failed to create recorded directory: $RECORDED_DIR"
103+
echo "$TESTNAME FAIL" >"$RES_FILE"
104+
exit 0
105+
fi
106+
83107
result="FAIL"
84108
reason="unknown"
85109
pass_count=0
@@ -89,17 +113,13 @@ total_tests=0
89113

90114
# -------------------- Defaults (LAVA env vars -> defaults; CLI overrides) --------------------
91115
testMode="${AUDIO_TEST_MODE:-all}"
116+
testName="${AUDIO_TEST_NAME:-}"
92117
formatList="${AUDIO_FORMATS:-wav,flac}"
93118
duration="${AUDIO_DURATION:-${RUNTIMESEC:-10}}"
94119
gstDebugLevel="${AUDIO_GST_DEBUG:-${GST_DEBUG_LEVEL:-2}}"
95120
clipUrl="${AUDIO_CLIP_URL:-https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/GST-Audio-Files-v1.0/audio_clips_gst.tar.gz}"
96121
clipPath="${AUDIO_CLIP_PATH:-}"
97122

98-
# Calculate num_buffers based on duration
99-
# Formula: num_buffers = (sample_rate * duration) / samples_per_buffer
100-
# Example: (44100 * 10) / 1024 = 430 buffers for 10 seconds
101-
NUM_BUFFERS=$(( (SAMPLE_RATE * duration) / SAMPLES_PER_BUFFER ))
102-
103123
# Validate numeric parameters (only validate if explicitly set)
104124
for param in AUDIO_DURATION AUDIO_GST_DEBUG GST_DEBUG_LEVEL; do
105125
val=""
@@ -210,6 +230,16 @@ while [ $# -gt 0 ]; do
210230
shift 2
211231
;;
212232

233+
--test-name)
234+
if [ $# -lt 2 ] || [ "${2#--}" != "$2" ]; then
235+
log_warn "Missing/invalid value for --test-name"
236+
echo "$TESTNAME SKIP" >"$RES_FILE"
237+
exit 0
238+
fi
239+
[ -n "$2" ] && testName="$2"
240+
shift 2
241+
;;
242+
213243
-h|--help)
214244
cat <<EOF
215245
Usage: $0 [OPTIONS]
@@ -322,6 +352,30 @@ case "$duration" in
322352
;;
323353
esac
324354

355+
# Validate test name if provided
356+
if [ -n "$testName" ]; then
357+
case "$testName" in
358+
record_wav|record_flac|record_pulsesrc_wav|record_pulsesrc_flac|\
359+
playback_wav|playback_flac|playback_pulsesrc_wav|playback_pulsesrc_flac|\
360+
playback_sample_ogg|playback_sample_mp3)
361+
log_info "Test name: $testName (individual test mode)"
362+
;;
363+
*)
364+
log_warn "Invalid --test-name '$testName'"
365+
log_warn "Valid names: record_wav, record_flac, record_pulsesrc_wav, record_pulsesrc_flac,"
366+
log_warn " playback_wav, playback_flac, playback_pulsesrc_wav, playback_pulsesrc_flac,"
367+
log_warn " playback_sample_ogg, playback_sample_mp3"
368+
echo "$TESTNAME SKIP" >"$RES_FILE"
369+
exit 0
370+
;;
371+
esac
372+
fi
373+
374+
# Calculate num_buffers based on final duration value
375+
# Formula: num_buffers = (sample_rate * duration) / samples_per_buffer
376+
# Example: (44100 * 10) / 1024 = 430 buffers for 10 seconds
377+
NUM_BUFFERS=$(( (SAMPLE_RATE * duration) / SAMPLES_PER_BUFFER ))
378+
325379
# -------------------- Pre-checks --------------------
326380
check_dependencies "gst-launch-1.0 gst-inspect-1.0 awk grep head sed tr stat find curl tar" >/dev/null 2>&1 || {
327381
log_skip "Missing required tools (gst-launch-1.0, gst-inspect-1.0, awk, grep, head, sed, tr, stat, find, curl, tar)"
@@ -339,6 +393,7 @@ log_info "Audio params: sample_rate=${SAMPLE_RATE}Hz, samples_per_buffer=${SAMPL
339393
log_info "Calculated num_buffers: $NUM_BUFFERS (for ${duration}s duration)"
340394
log_info "GST debug: GST_DEBUG=$gstDebugLevel"
341395
log_info "Logs: $OUTDIR"
396+
log_info "Recorded artifact dir: $RECORDED_DIR"
342397

343398
# -------------------- Required element validation --------------------
344399
check_required_elements() {
@@ -810,59 +865,109 @@ if ! check_required_elements; then
810865
fi
811866
log_info "Required GStreamer elements verified"
812867

813-
# Provision Test files for OGG/MP3 playback tests
814-
provision_test_files
815-
816868
# Parse format list
817869
formats=$(printf '%s' "$formatList" | tr ',' ' ')
818870

819-
# Run ALL record/encode tests first (4 tests total)
820-
if [ "$testMode" = "all" ] || [ "$testMode" = "record" ]; then
821-
log_info "=========================================="
822-
log_info "RECORD TESTS"
823-
log_info "=========================================="
824-
825-
# 1. Record with audiotestsrc (2 tests: wav, flac)
826-
log_info "Recording with audiotestsrc..."
827-
for fmt in $formats; do
828-
total_tests=$((total_tests + 1))
829-
run_record_test "$fmt" || true
830-
done
831-
832-
# 2. Record with pulsesrc HW (2 tests: wav, flac)
833-
log_info "Recording with pulsesrc HW..."
834-
for fmt in $formats; do
835-
total_tests=$((total_tests + 1))
836-
run_record_pulsesrc_test "$fmt" || true
837-
done
838-
fi
839-
840-
# Run ALL playback/decode tests after recording (4 tests total)
841-
if [ "$testMode" = "all" ] || [ "$testMode" = "playback" ]; then
871+
# -------------------- Individual Test Mode --------------------
872+
if [ -n "$testName" ]; then
873+
# Only provision test files if running OGG/MP3 playback tests
874+
case "$testName" in
875+
playback_sample_ogg|playback_sample_mp3)
876+
provision_test_files
877+
;;
878+
esac
842879
log_info "=========================================="
843-
log_info "PLAYBACK TESTS"
880+
log_info "INDIVIDUAL TEST MODE: $testName"
844881
log_info "=========================================="
845-
846-
# 3. Playback audiotestsrc recordings (2 tests: wav, flac)
847-
log_info "Playing back audiotestsrc recordings..."
848-
for fmt in $formats; do
849-
total_tests=$((total_tests + 1))
850-
run_playback_test "$fmt" || true
851-
done
852-
853-
# 4. Playback pulsesrc recordings (2 tests: wav, flac)
854-
log_info "Playing back pulsesrc recordings..."
855-
for fmt in $formats; do
856-
total_tests=$((total_tests + 1))
857-
run_playback_pulsesrc_test "$fmt" || true
858-
done
859882

860-
# 5. Playback Test files (2 tests: ogg, mp3)
861-
log_info "Playing back Test files (OGG/MP3)..."
862-
for fmt in ogg mp3; do
863-
total_tests=$((total_tests + 1))
864-
run_playback_ogg_mp3_test "$fmt" || true
865-
done
883+
total_tests=1
884+
885+
case "$testName" in
886+
record_wav)
887+
run_record_test "wav" || true
888+
;;
889+
record_flac)
890+
run_record_test "flac" || true
891+
;;
892+
record_pulsesrc_wav)
893+
run_record_pulsesrc_test "wav" || true
894+
;;
895+
record_pulsesrc_flac)
896+
run_record_pulsesrc_test "flac" || true
897+
;;
898+
playback_wav)
899+
run_playback_test "wav" || true
900+
;;
901+
playback_flac)
902+
run_playback_test "flac" || true
903+
;;
904+
playback_pulsesrc_wav)
905+
run_playback_pulsesrc_test "wav" || true
906+
;;
907+
playback_pulsesrc_flac)
908+
run_playback_pulsesrc_test "flac" || true
909+
;;
910+
playback_sample_ogg)
911+
run_playback_ogg_mp3_test "ogg" || true
912+
;;
913+
playback_sample_mp3)
914+
run_playback_ogg_mp3_test "mp3" || true
915+
;;
916+
esac
917+
918+
# -------------------- Grouped Test Mode (Original) --------------------
919+
else
920+
# Run ALL record/encode tests first (4 tests total)
921+
if [ "$testMode" = "all" ] || [ "$testMode" = "record" ]; then
922+
log_info "=========================================="
923+
log_info "RECORD TESTS"
924+
log_info "=========================================="
925+
926+
# 1. Record with audiotestsrc (2 tests: wav, flac)
927+
log_info "Recording with audiotestsrc..."
928+
for fmt in $formats; do
929+
total_tests=$((total_tests + 1))
930+
run_record_test "$fmt" || true
931+
done
932+
933+
# 2. Record with pulsesrc HW (2 tests: wav, flac)
934+
log_info "Recording with pulsesrc HW..."
935+
for fmt in $formats; do
936+
total_tests=$((total_tests + 1))
937+
run_record_pulsesrc_test "$fmt" || true
938+
done
939+
fi
940+
941+
# Run ALL playback/decode tests after recording (6 tests total)
942+
if [ "$testMode" = "all" ] || [ "$testMode" = "playback" ]; then
943+
# Provision test files only when running playback tests
944+
provision_test_files
945+
946+
log_info "=========================================="
947+
log_info "PLAYBACK TESTS"
948+
log_info "=========================================="
949+
950+
# 3. Playback audiotestsrc recordings (2 tests: wav, flac)
951+
log_info "Playing back audiotestsrc recordings..."
952+
for fmt in $formats; do
953+
total_tests=$((total_tests + 1))
954+
run_playback_test "$fmt" || true
955+
done
956+
957+
# 4. Playback pulsesrc recordings (2 tests: wav, flac)
958+
log_info "Playing back pulsesrc recordings..."
959+
for fmt in $formats; do
960+
total_tests=$((total_tests + 1))
961+
run_playback_pulsesrc_test "$fmt" || true
962+
done
963+
964+
# 5. Playback Test files (2 tests: ogg, mp3)
965+
log_info "Playing back Test files (OGG/MP3)..."
966+
for fmt in ogg mp3; do
967+
total_tests=$((total_tests + 1))
968+
run_playback_ogg_mp3_test "$fmt" || true
969+
done
970+
fi
866971
fi
867972

868973
# -------------------- Dmesg error scan --------------------

0 commit comments

Comments
 (0)