Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ metadata:
Audio record/playback validation using GStreamer (gst-launch-1.0).
Tests 10 scenarios: 4 encode (2 audiotestsrc + 2 pulsesrc) + 6 decode (4 playback + 2 OGG/MP3).
Supports WAV, FLAC, OGG, and MP3 formats with both synthetic audio (audiotestsrc) and hardware capture (pulsesrc).
Duration controlled via AUDIO_DURATION (default 10s): audiotestsrc uses num-buffers, pulsesrc uses timeout.
Duration controlled via AUDIO_DURATION (default 10s): audiotestsrc uses num-buffers calculated after argument parsing, pulsesrc uses timeout.
Uses AUDIO_SHARED_RECORDED_DIR for shared artifact storage across test runs.
os:
- linux
scope:
- functional

params:
AUDIO_TEST_MODE: "all"
AUDIO_TEST_NAME: ""
AUDIO_FORMATS: "wav,flac"
AUDIO_DURATION: "10"
AUDIO_GST_DEBUG: "2"

run:
steps:
- REPO_PATH="$PWD"
- cd Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/
- export AUDIO_TEST_MODE AUDIO_FORMATS AUDIO_DURATION AUDIO_GST_DEBUG
- ./run.sh --mode "${AUDIO_TEST_MODE}" --formats "${AUDIO_FORMATS}" --duration "${AUDIO_DURATION}" --gst-debug "${AUDIO_GST_DEBUG}" || true
- cd "$REPO_PATH/Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback"
- AUDIO_SHARED_RECORDED_DIR="${REPO_PATH%%/tests/*}/shared/audio-record-playback"
- export REPO_PATH AUDIO_SHARED_RECORDED_DIR AUDIO_TEST_MODE AUDIO_TEST_NAME AUDIO_FORMATS AUDIO_DURATION AUDIO_GST_DEBUG
- ./run.sh || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Audio_Record_Playback.res
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,39 @@ By default, logs are written relative to the script working directory:
playback_flac.log
playback_pulsesrc_wav.log
playback_pulsesrc_flac.log
recorded/ # Recorded audio files
record_wav.wav
record_flac.flac
record_pulsesrc_wav.wav
record_pulsesrc_flac.flac
dmesg/ # dmesg scan outputs (if available)
dmesg_errors.log
```

### Recorded Audio Artifacts

Recorded audio files are stored in a shared directory to enable artifact reuse across test runs:

**Local/Manual Runs** (fallback):
```
./logs/Audio_Record_Playback/recorded/
record_wav.wav
record_flac.flac
record_pulsesrc_wav.wav
record_pulsesrc_flac.flac
```

**CI/LAVA Runs** (shared path):
```
<repo_root>/shared/audio-record-playback/
record_wav.wav
record_flac.flac
record_pulsesrc_wav.wav
record_pulsesrc_flac.flac
```

The recorded artifact directory is determined by:
1. **Explicit override**: `AUDIO_SHARED_RECORDED_DIR` environment variable (if set)
2. **LAVA/tests detection**: Shared path derived from repository structure (if script path contains `/tests/`)
3. **Local fallback**: `./logs/Audio_Record_Playback/recorded/` (for manual runs)

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.

---

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

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

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

**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).

### Test Counting

- **Total tests**: 10 (when running with default wav,flac formats in all mode)
Expand Down
219 changes: 162 additions & 57 deletions Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ LOG_DIR="${SCRIPT_DIR}/logs"
OUTDIR="$LOG_DIR/$TESTNAME"
GST_LOG="$OUTDIR/gst.log"
DMESG_DIR="$OUTDIR/dmesg"
RECORDED_DIR="$OUTDIR/recorded"

mkdir -p "$OUTDIR" "$DMESG_DIR" "$RECORDED_DIR" >/dev/null 2>&1 || true
: >"$RES_FILE"
: >"$GST_LOG"

INIT_ENV=""
SEARCH="$SCRIPT_DIR"
while [ "$SEARCH" != "/" ]; do
Expand Down Expand Up @@ -80,6 +75,35 @@ fi
# shellcheck disable=SC1091
. "$TOOLS/lib_gstreamer.sh"

# Create required directories now that log functions are available
if ! mkdir -p "$OUTDIR" "$DMESG_DIR"; then
log_error "Failed to create required directories:"
log_error " OUTDIR=$OUTDIR"
log_error " DMESG_DIR=$DMESG_DIR"
echo "$TESTNAME FAIL" >"$RES_FILE" 2>/dev/null || true
exit 0
fi
: >"$RES_FILE"
: >"$GST_LOG"

# -------------------- Set up shared recorded directory --------------------
# Use gstreamer_shared_recorded_dir() as single source of truth for directory resolution
# Priority: 1) AUDIO_SHARED_RECORDED_DIR env var, 2) LAVA/tests shared path, 3) local fallback
if [ -n "${AUDIO_SHARED_RECORDED_DIR:-}" ]; then
RECORDED_DIR="$AUDIO_SHARED_RECORDED_DIR"
elif command -v gstreamer_shared_recorded_dir >/dev/null 2>&1; then
RECORDED_DIR="$(gstreamer_shared_recorded_dir "$SCRIPT_DIR" "$OUTDIR")"
else
RECORDED_DIR="$OUTDIR/recorded"
fi

# Create the recorded directory
if ! mkdir -p "$RECORDED_DIR"; then
log_error "Failed to create recorded directory: $RECORDED_DIR"
echo "$TESTNAME FAIL" >"$RES_FILE"
exit 0
fi

result="FAIL"
reason="unknown"
pass_count=0
Expand All @@ -89,17 +113,13 @@ total_tests=0

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

# Calculate num_buffers based on duration
# Formula: num_buffers = (sample_rate * duration) / samples_per_buffer
# Example: (44100 * 10) / 1024 = 430 buffers for 10 seconds
NUM_BUFFERS=$(( (SAMPLE_RATE * duration) / SAMPLES_PER_BUFFER ))

# Validate numeric parameters (only validate if explicitly set)
for param in AUDIO_DURATION AUDIO_GST_DEBUG GST_DEBUG_LEVEL; do
val=""
Expand Down Expand Up @@ -210,6 +230,16 @@ while [ $# -gt 0 ]; do
shift 2
;;

--test-name)
if [ $# -lt 2 ] || [ "${2#--}" != "$2" ]; then
log_warn "Missing/invalid value for --test-name"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
fi
[ -n "$2" ] && testName="$2"
shift 2
;;

-h|--help)
cat <<EOF
Usage: $0 [OPTIONS]
Expand Down Expand Up @@ -322,6 +352,30 @@ case "$duration" in
;;
esac

# Validate test name if provided
if [ -n "$testName" ]; then
case "$testName" in
record_wav|record_flac|record_pulsesrc_wav|record_pulsesrc_flac|\
playback_wav|playback_flac|playback_pulsesrc_wav|playback_pulsesrc_flac|\
playback_sample_ogg|playback_sample_mp3)
log_info "Test name: $testName (individual test mode)"
;;
*)
log_warn "Invalid --test-name '$testName'"
log_warn "Valid names: record_wav, record_flac, record_pulsesrc_wav, record_pulsesrc_flac,"
log_warn " playback_wav, playback_flac, playback_pulsesrc_wav, playback_pulsesrc_flac,"
log_warn " playback_sample_ogg, playback_sample_mp3"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
;;
esac
fi

# Calculate num_buffers based on final duration value
# Formula: num_buffers = (sample_rate * duration) / samples_per_buffer
# Example: (44100 * 10) / 1024 = 430 buffers for 10 seconds
NUM_BUFFERS=$(( (SAMPLE_RATE * duration) / SAMPLES_PER_BUFFER ))

# -------------------- Pre-checks --------------------
check_dependencies "gst-launch-1.0 gst-inspect-1.0 awk grep head sed tr stat find curl tar" >/dev/null 2>&1 || {
log_skip "Missing required tools (gst-launch-1.0, gst-inspect-1.0, awk, grep, head, sed, tr, stat, find, curl, tar)"
Expand All @@ -339,6 +393,7 @@ log_info "Audio params: sample_rate=${SAMPLE_RATE}Hz, samples_per_buffer=${SAMPL
log_info "Calculated num_buffers: $NUM_BUFFERS (for ${duration}s duration)"
log_info "GST debug: GST_DEBUG=$gstDebugLevel"
log_info "Logs: $OUTDIR"
log_info "Recorded artifact dir: $RECORDED_DIR"

# -------------------- Required element validation --------------------
check_required_elements() {
Expand Down Expand Up @@ -810,59 +865,109 @@ if ! check_required_elements; then
fi
log_info "Required GStreamer elements verified"

# Provision Test files for OGG/MP3 playback tests
provision_test_files

# Parse format list
formats=$(printf '%s' "$formatList" | tr ',' ' ')

# Run ALL record/encode tests first (4 tests total)
if [ "$testMode" = "all" ] || [ "$testMode" = "record" ]; then
log_info "=========================================="
log_info "RECORD TESTS"
log_info "=========================================="

# 1. Record with audiotestsrc (2 tests: wav, flac)
log_info "Recording with audiotestsrc..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_record_test "$fmt" || true
done

# 2. Record with pulsesrc HW (2 tests: wav, flac)
log_info "Recording with pulsesrc HW..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_record_pulsesrc_test "$fmt" || true
done
fi

# Run ALL playback/decode tests after recording (4 tests total)
if [ "$testMode" = "all" ] || [ "$testMode" = "playback" ]; then
# -------------------- Individual Test Mode --------------------
if [ -n "$testName" ]; then
# Only provision test files if running OGG/MP3 playback tests
case "$testName" in
playback_sample_ogg|playback_sample_mp3)
provision_test_files
;;
esac
log_info "=========================================="
log_info "PLAYBACK TESTS"
log_info "INDIVIDUAL TEST MODE: $testName"
log_info "=========================================="

# 3. Playback audiotestsrc recordings (2 tests: wav, flac)
log_info "Playing back audiotestsrc recordings..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_playback_test "$fmt" || true
done

# 4. Playback pulsesrc recordings (2 tests: wav, flac)
log_info "Playing back pulsesrc recordings..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_playback_pulsesrc_test "$fmt" || true
done

# 5. Playback Test files (2 tests: ogg, mp3)
log_info "Playing back Test files (OGG/MP3)..."
for fmt in ogg mp3; do
total_tests=$((total_tests + 1))
run_playback_ogg_mp3_test "$fmt" || true
done
total_tests=1

case "$testName" in
record_wav)
run_record_test "wav" || true
;;
record_flac)
run_record_test "flac" || true
;;
record_pulsesrc_wav)
run_record_pulsesrc_test "wav" || true
;;
record_pulsesrc_flac)
run_record_pulsesrc_test "flac" || true
;;
playback_wav)
run_playback_test "wav" || true
;;
playback_flac)
run_playback_test "flac" || true
;;
playback_pulsesrc_wav)
run_playback_pulsesrc_test "wav" || true
;;
playback_pulsesrc_flac)
run_playback_pulsesrc_test "flac" || true
;;
playback_sample_ogg)
run_playback_ogg_mp3_test "ogg" || true
;;
playback_sample_mp3)
run_playback_ogg_mp3_test "mp3" || true
;;
esac

# -------------------- Grouped Test Mode (Original) --------------------
else
# Run ALL record/encode tests first (4 tests total)
if [ "$testMode" = "all" ] || [ "$testMode" = "record" ]; then
log_info "=========================================="
log_info "RECORD TESTS"
log_info "=========================================="

# 1. Record with audiotestsrc (2 tests: wav, flac)
log_info "Recording with audiotestsrc..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_record_test "$fmt" || true
done

# 2. Record with pulsesrc HW (2 tests: wav, flac)
log_info "Recording with pulsesrc HW..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_record_pulsesrc_test "$fmt" || true
done
fi

# Run ALL playback/decode tests after recording (6 tests total)
if [ "$testMode" = "all" ] || [ "$testMode" = "playback" ]; then
# Provision test files only when running playback tests
provision_test_files

log_info "=========================================="
log_info "PLAYBACK TESTS"
log_info "=========================================="

# 3. Playback audiotestsrc recordings (2 tests: wav, flac)
log_info "Playing back audiotestsrc recordings..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_playback_test "$fmt" || true
done

# 4. Playback pulsesrc recordings (2 tests: wav, flac)
log_info "Playing back pulsesrc recordings..."
for fmt in $formats; do
total_tests=$((total_tests + 1))
run_playback_pulsesrc_test "$fmt" || true
done

# 5. Playback Test files (2 tests: ogg, mp3)
log_info "Playing back Test files (OGG/MP3)..."
for fmt in ogg mp3; do
total_tests=$((total_tests + 1))
run_playback_ogg_mp3_test "$fmt" || true
done
fi
fi

# -------------------- Dmesg error scan --------------------
Expand Down
Loading