Skip to content

Adding Scripts for Audio Playback and Audio Record for Public CI Testcases #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
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
21 changes: 21 additions & 0 deletions Runner/plans/meta-ar-ci-premerge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
metadata:
format: Lava-Test Test Definition 1.0
name: SmokeSanity
description: "Pre-merge LAVA plan to run AudioRecord and AudioPlayback on every PR"
maintainer:
- abbajaj@qti.qualcomm.com
os:
- openembedded
scope:
- functional
devices:
- rb3gen2

run:
steps:
- cd Runner
- $PWD/suites/Multimedia/Audio/AudioPlayback/run.sh || true
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res || true
- $PWD/suites/Multimedia/Audio/AudioRecord/run.sh || true
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioRecord/AudioRecord.res || true

78 changes: 78 additions & 0 deletions Runner/suites/Multimedia/Audio/AudioPlayback/Read_me.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Audio playback Validation Script for Qualcomm Linux based platform (Yocto)

## Overview

This script automates the validation of audio playback capabilities on the Qualcomm Linux based platform running a Yocto-based Linux system. It utilizes pulseaudio test app to decode wav file.

## Features

- Decoding PCM clip
- Compatible with Yocto-based root filesystem

## Prerequisites

Ensure the following components are present in the target Yocto build:

- `paplay` binary(available at /usr/bin)

## Directory Structure

```bash
Runner/
├──suites/
├ ├── Multimedia/
│ ├ ├── Audio/
│ ├ ├ ├── AudioPlayback/
│ ├ ├ ├ ├ └── run.sh
├ ├ ├ ├ ├ └── Read_me.md
```

## Usage


Instructions

1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.

2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.

3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.

Run a specific test using:
---
Quick Example
```
git clone <this-repo>
cd <this-repo>
scp -r common Runner user@target_device_ip:<Path in device>
ssh user@target_device_ip
cd <Path in device>/Runner && ./run-test.sh AudioPlayback
```
Sample Output:
```
sh-5.2# cd <Path in device>/Runner/ && ./run-test.sh AudioPlayback
[Executing test case: AudioPlayback] 2025-05-28 19:01:59 -
[INFO] 2025-05-28 19:01:59 - ------------------------------------------------------------
[INFO] 2025-05-28 19:01:59 - ------------------- Starting AudioPlayback Testcase ------------
[INFO] 2025-05-28 19:01:59 - Checking if dependency binary is available
[INFO] 2025-05-28 19:01:59 - Playback clip present: AudioClips/yesterday_48KHz.wav
[PASS] 2025-05-28 19:02:14 - Playback completed or timed out (ret=124) as expected.
[PASS] 2025-05-28 19:02:14 - AudioPlayback : Test Passed
[INFO] 2025-05-28 19:02:14 - See results/audioplayback/playback_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details
[INFO] 2025-05-28 19:02:14 - ------------------- Completed AudioPlayback Testcase -------------
[PASS] 2025-05-28 19:02:14 - AudioPlayback passed
sh-5.2#
```
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res` directory.


## Notes

- The script does not take any arguments.
- It validates the presence of required libraries before executing tests.
- If any critical tool is missing, the script exits with an error message.

## License

SPDX-License-Identifier: BSD-3-Clause-Clear
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
94 changes: 94 additions & 0 deletions Runner/suites/Multimedia/Audio/AudioPlayback/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# --------- Robustly source init_env and functestlib.sh ----------
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INIT_ENV=""
SEARCH="$SCRIPT_DIR"
while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then
INIT_ENV="$SEARCH/init_env"
break
fi
SEARCH=$(dirname "$SEARCH")
done

if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
exit 1
fi

if [ -z "$__INIT_ENV_LOADED" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
fi
# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"
# ---------------------------------------------------------------

TESTNAME="AudioPlayback"
TESTBINARY="paplay"
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/Pulse-Audio-Files-v1.0/AudioClips.tar.gz"
PLAYBACK_CLIP="AudioClips/yesterday_48KHz.wav"
AUDIO_DEVICE="low-latency0"
LOGDIR="results/audioplayback"
RESULT_FILE="$TESTNAME.res"

test_path=$(find_test_case_by_name "$TESTNAME")
cd "$test_path" || exit 1

# Prepare logdir
mkdir -p "$LOGDIR"
chmod -R 777 "$LOGDIR"

log_info "------------------------------------------------------------"
log_info "------------------- Starting $TESTNAME Testcase ------------"

log_info "Checking if dependency binary is available"
check_dependencies "$TESTBINARY" pgrep grep timeout

# Download/extract audio if not present
if [ ! -f "$PLAYBACK_CLIP" ]; then
log_info "Audio clip not found, downloading..."
extract_tar_from_url "$TAR_URL" || {
log_fail "Failed to fetch/extract playback audio tarball"
echo "$TESTNAME FAIL" > "$RESULT_FILE"
exit 1
}
fi

if [ ! -f "$PLAYBACK_CLIP" ]; then
log_fail "Playback clip $PLAYBACK_CLIP not found after extraction."
echo "$TESTNAME : FAIL" > "$RESULT_FILE"
exit 1
fi

log_info "Playback clip present: $PLAYBACK_CLIP"

# --- Capture logs BEFORE playback (for debugging) ---
dmesg > "$LOGDIR/dmesg_before.log"
cp /var/log/syslog "$LOGDIR/syslog_before.log" 2>/dev/null

# --- Start the Playback, capture output ---
timeout 15s paplay "$PLAYBACK_CLIP" -d "$AUDIO_DEVICE" > "$LOGDIR/playback_stdout.log" 2>&1
ret=$?

# --- Capture logs AFTER playback (for debugging) ---
dmesg > "$LOGDIR/dmesg_after.log"
cp /var/log/syslog "$LOGDIR/syslog_after.log" 2>/dev/null

if [ "$ret" -eq 0 ] || [ "$ret" -eq 124 ] ; then
log_pass "Playback completed or timed out (ret=$ret) as expected."
log_pass "$TESTNAME : Test Passed"
echo "$TESTNAME PASS" > "$RESULT_FILE"
else
log_fail "$TESTBINARY playback exited with error code $ret"
log_fail "$TESTNAME : Test Failed"
echo "$TESTNAME FAIL" > "$RESULT_FILE"
fi

log_info "See $LOGDIR/playback_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details"
log_info "------------------- Completed $TESTNAME Testcase -------------"
exit 0
79 changes: 79 additions & 0 deletions Runner/suites/Multimedia/Audio/AudioRecord/Read_me.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Audio encode Validation Script for Qualcomm Linux based platform (Yocto)

## Overview

This script automates the validation of audio encode capabilities on the Qualcomm Linux based platform running a Yocto-based Linux system. It utilizes pulseaudio test app to encode file.

## Features

- Encode PCM clip with --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0
- Compatible with Yocto-based root filesystem

## Prerequisites

Ensure the following components are present in the target Yocto build:

- `parec` binary(available at /usr/bin)

## Directory Structure

```bash
Runner/
├──suites/
├ ├── Multimedia/
│ ├ ├── Audio/
│ ├ ├ ├── AudioRecord/
│ ├ ├ ├ ├ └── run.sh
├ ├ ├ ├ ├ └── Read_me.md
```

## Usage


Instructions

1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.

2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.

3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.

Run a specific test using:
---
Quick Example
```
git clone <this-repo>
cd <this-repo>
scp -r common Runner user@target_device_ip:<Path in device>
ssh user@target_device_ip
cd <Path in device>Runner && ./run-test.sh AudioRecord
```

Sample Output:
```
sh-5.2# cd <Path in device>/Runner/ && ./run-test.sh AudioRecord
[Executing test case: AudioRecord] 2025-05-28 19:03:33 -
[INFO] 2025-05-28 19:03:33 - ------------------------------------------------------------
[INFO] 2025-05-28 19:03:33 - ------------------- Starting AudioRecord Testcase ------------
[INFO] 2025-05-28 19:03:33 - Checking if dependency binary is available
[PASS] 2025-05-28 19:03:45 - Recording completed or timed out (ret=124) as expected and output file exists.
[PASS] 2025-05-28 19:03:45 - AudioRecord : Test Passed
[INFO] 2025-05-28 19:03:45 - See results/audiorecord/parec_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details
[INFO] 2025-05-28 19:03:45 - ------------------- Completed AudioRecord Testcase -------------
[PASS] 2025-05-28 19:03:45 - AudioRecord passed
sh-5.2#
```

3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioRecord/AudioRecord.res` directory.


## Notes

- The script does not take any arguments.
- It validates the presence of required libraries before executing tests.
- If any critical tool is missing, the script exits with an error message.

## License

SPDX-License-Identifier: BSD-3-Clause-Clear
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
77 changes: 77 additions & 0 deletions Runner/suites/Multimedia/Audio/AudioRecord/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# --------- Robustly source init_env and functestlib.sh ----------
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INIT_ENV=""
SEARCH="$SCRIPT_DIR"
while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then
INIT_ENV="$SEARCH/init_env"
break
fi
SEARCH=$(dirname "$SEARCH")
done

if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
exit 1
fi

if [ -z "$__INIT_ENV_LOADED" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
fi
# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"
# ---------------------------------------------------------------

TESTNAME="AudioRecord"
TESTBINARY="parec"
RECORD_FILE="/tmp/rec1.wav"
AUDIO_DEVICE="regular0"
LOGDIR="results/audiorecord"
RESULT_FILE="$TESTNAME.res"

test_path=$(find_test_case_by_name "$TESTNAME")
cd "$test_path" || exit 1
mkdir -p "$LOGDIR"
chmod -R 777 "$LOGDIR"

log_info "------------------------------------------------------------"
log_info "------------------- Starting $TESTNAME Testcase ------------"

log_info "Checking if dependency binary is available"
check_dependencies "$TESTBINARY" pgrep timeout

# --- Capture logs BEFORE recording (for debugging) ---
dmesg > "$LOGDIR/dmesg_before.log"
cp /var/log/syslog "$LOGDIR/syslog_before.log" 2>/dev/null

# Remove old record file if present
rm -f "$RECORD_FILE"

# --- Start recording ---
timeout 12s "$TESTBINARY" --rate=48000 --format=s16le --channels=1 --file-format=wav "$RECORD_FILE" -d "$AUDIO_DEVICE" > "$LOGDIR/parec_stdout.log" 2>&1
ret=$?

# --- Capture logs AFTER recording (for debugging) ---
dmesg > "$LOGDIR/dmesg_after.log"
cp /var/log/syslog "$LOGDIR/syslog_after.log" 2>/dev/null

# --- Evaluate result: pass only if process completed successfully and file is non-empty ---
if ([ "$ret" -eq 0 ] || [ "$ret" -eq 124 ]) && [ -s "$RECORD_FILE" ]; then
log_pass "Recording completed or timed out (ret=$ret) as expected and output file exists."
log_pass "$TESTNAME : Test Passed"
echo "$TESTNAME PASS" > "$RESULT_FILE"
else
log_fail "parec failed (status $ret) or recorded file missing/empty"
log_fail "$TESTNAME : Test Failed"
echo "$TESTNAME FAIL" > "$RESULT_FILE"
fi

log_info "See $LOGDIR/parec_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details"
log_info "------------------- Completed $TESTNAME Testcase -------------"
exit 0
Loading