Skip to content

Commit a653bf3

Browse files
committed
Adding Scripts for Audio Playback and Audio Record for Public CI Testcases
Added Audio Playback Shell Script Added ReadMe for Audio Playback Added Audio Record Shell Script Added ReadMe for Audio Record Added YAML for Pre-merge LAVA plan to run AudioRecord and AudioPlayback Signed-off-by: Abhishek Bajaj <abbajaj@qti.qualcomm.com>
1 parent 8ba9498 commit a653bf3

File tree

5 files changed

+349
-0
lines changed

5 files changed

+349
-0
lines changed

Runner/plans/meta-ar-ci-premerge.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
metadata:
2+
format: Lava-Test Test Definition 1.0
3+
name: SmokeSanity
4+
description: "Pre-merge LAVA plan to run AudioRecord and AudioPlayback on every PR"
5+
maintainer:
6+
- abbajaj@qti.qualcomm.com
7+
os:
8+
- openembedded
9+
scope:
10+
- functional
11+
devices:
12+
- rb3gen2
13+
14+
run:
15+
steps:
16+
- cd Runner
17+
- $PWD/suites/Multimedia/Audio/AudioPlayback/run.sh || true
18+
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res || true
19+
- $PWD/suites/Multimedia/Audio/AudioRecord/run.sh || true
20+
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioRecord/AudioRecord.res || true
21+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Audio playback Validation Script for Qualcomm Linux based platform (Yocto)
2+
3+
## Overview
4+
5+
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.
6+
7+
## Features
8+
9+
- Decoding PCM clip
10+
- Compatible with Yocto-based root filesystem
11+
12+
## Prerequisites
13+
14+
Ensure the following components are present in the target Yocto build:
15+
16+
- `paplay` binary(available at /usr/bin)
17+
18+
## Directory Structure
19+
20+
```bash
21+
Runner/
22+
├──suites/
23+
├ ├── Multimedia/
24+
│ ├ ├── Audio/
25+
│ ├ ├ ├── AudioPlayback/
26+
│ ├ ├ ├ ├ └── run.sh
27+
├ ├ ├ ├ ├ └── Read_me.md
28+
```
29+
30+
## Usage
31+
32+
33+
Instructions
34+
35+
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.
36+
37+
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
38+
39+
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
40+
41+
Run a specific test using:
42+
---
43+
Quick Example
44+
```
45+
git clone <this-repo>
46+
cd <this-repo>
47+
scp -r common Runner user@target_device_ip:<Path in device>
48+
ssh user@target_device_ip
49+
cd <Path in device>/Runner && ./run-test.sh AudioPlayback
50+
```
51+
Sample Output:
52+
```
53+
sh-5.2# cd <Path in device>/Runner/ && ./run-test.sh AudioPlayback
54+
[Executing test case: AudioPlayback] 2025-05-28 19:01:59 -
55+
[INFO] 2025-05-28 19:01:59 - ------------------------------------------------------------
56+
[INFO] 2025-05-28 19:01:59 - ------------------- Starting AudioPlayback Testcase ------------
57+
[INFO] 2025-05-28 19:01:59 - Checking if dependency binary is available
58+
[INFO] 2025-05-28 19:01:59 - Playback clip present: AudioClips/yesterday_48KHz.wav
59+
[PASS] 2025-05-28 19:02:14 - Playback completed or timed out (ret=124) as expected.
60+
[PASS] 2025-05-28 19:02:14 - AudioPlayback : Test Passed
61+
[INFO] 2025-05-28 19:02:14 - See results/audioplayback/playback_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details
62+
[INFO] 2025-05-28 19:02:14 - ------------------- Completed AudioPlayback Testcase -------------
63+
[PASS] 2025-05-28 19:02:14 - AudioPlayback passed
64+
sh-5.2#
65+
```
66+
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res` directory.
67+
68+
69+
## Notes
70+
71+
- The script does not take any arguments.
72+
- It validates the presence of required libraries before executing tests.
73+
- If any critical tool is missing, the script exits with an error message.
74+
75+
## License
76+
77+
SPDX-License-Identifier: BSD-3-Clause-Clear
78+
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# --------- Robustly source init_env and functestlib.sh ----------
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20+
exit 1
21+
fi
22+
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
# shellcheck disable=SC1090,SC1091
28+
. "$TOOLS/functestlib.sh"
29+
# ---------------------------------------------------------------
30+
31+
TESTNAME="AudioPlayback"
32+
TESTBINARY="paplay"
33+
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/Pulse-Audio-Files-v1.0/AudioClips.tar.gz"
34+
PLAYBACK_CLIP="AudioClips/yesterday_48KHz.wav"
35+
AUDIO_DEVICE="low-latency0"
36+
LOGDIR="results/audioplayback"
37+
RESULT_FILE="$TESTNAME.res"
38+
39+
test_path=$(find_test_case_by_name "$TESTNAME")
40+
cd "$test_path" || exit 1
41+
42+
# Prepare logdir
43+
mkdir -p "$LOGDIR"
44+
chmod -R 777 "$LOGDIR"
45+
46+
log_info "------------------------------------------------------------"
47+
log_info "------------------- Starting $TESTNAME Testcase ------------"
48+
49+
log_info "Checking if dependency binary is available"
50+
check_dependencies "$TESTBINARY" pgrep grep timeout
51+
52+
# Download/extract audio if not present
53+
if [ ! -f "$PLAYBACK_CLIP" ]; then
54+
log_info "Audio clip not found, downloading..."
55+
extract_tar_from_url "$TAR_URL" || {
56+
log_fail "Failed to fetch/extract playback audio tarball"
57+
echo "$TESTNAME FAIL" > "$RESULT_FILE"
58+
exit 1
59+
}
60+
fi
61+
62+
if [ ! -f "$PLAYBACK_CLIP" ]; then
63+
log_fail "Playback clip $PLAYBACK_CLIP not found after extraction."
64+
echo "$TESTNAME : FAIL" > "$RESULT_FILE"
65+
exit 1
66+
fi
67+
68+
log_info "Playback clip present: $PLAYBACK_CLIP"
69+
70+
# --- Capture logs BEFORE playback (for debugging) ---
71+
dmesg > "$LOGDIR/dmesg_before.log"
72+
cp /var/log/syslog "$LOGDIR/syslog_before.log" 2>/dev/null
73+
74+
# --- Start the Playback, capture output ---
75+
timeout 15s paplay "$PLAYBACK_CLIP" -d "$AUDIO_DEVICE" > "$LOGDIR/playback_stdout.log" 2>&1
76+
ret=$?
77+
78+
# --- Capture logs AFTER playback (for debugging) ---
79+
dmesg > "$LOGDIR/dmesg_after.log"
80+
cp /var/log/syslog "$LOGDIR/syslog_after.log" 2>/dev/null
81+
82+
if [ "$ret" -eq 0 ] || [ "$ret" -eq 124 ] ; then
83+
log_pass "Playback completed or timed out (ret=$ret) as expected."
84+
log_pass "$TESTNAME : Test Passed"
85+
echo "$TESTNAME PASS" > "$RESULT_FILE"
86+
else
87+
log_fail "$TESTBINARY playback exited with error code $ret"
88+
log_fail "$TESTNAME : Test Failed"
89+
echo "$TESTNAME FAIL" > "$RESULT_FILE"
90+
fi
91+
92+
log_info "See $LOGDIR/playback_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details"
93+
log_info "------------------- Completed $TESTNAME Testcase -------------"
94+
exit 0
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Audio encode Validation Script for Qualcomm Linux based platform (Yocto)
2+
3+
## Overview
4+
5+
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.
6+
7+
## Features
8+
9+
- Encode PCM clip with --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0
10+
- Compatible with Yocto-based root filesystem
11+
12+
## Prerequisites
13+
14+
Ensure the following components are present in the target Yocto build:
15+
16+
- `parec` binary(available at /usr/bin)
17+
18+
## Directory Structure
19+
20+
```bash
21+
Runner/
22+
├──suites/
23+
├ ├── Multimedia/
24+
│ ├ ├── Audio/
25+
│ ├ ├ ├── AudioRecord/
26+
│ ├ ├ ├ ├ └── run.sh
27+
├ ├ ├ ├ ├ └── Read_me.md
28+
```
29+
30+
## Usage
31+
32+
33+
Instructions
34+
35+
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.
36+
37+
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
38+
39+
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
40+
41+
Run a specific test using:
42+
---
43+
Quick Example
44+
```
45+
git clone <this-repo>
46+
cd <this-repo>
47+
scp -r common Runner user@target_device_ip:<Path in device>
48+
ssh user@target_device_ip
49+
cd <Path in device>Runner && ./run-test.sh AudioRecord
50+
```
51+
52+
Sample Output:
53+
```
54+
sh-5.2# cd <Path in device>/Runner/ && ./run-test.sh AudioRecord
55+
[Executing test case: AudioRecord] 2025-05-28 19:03:33 -
56+
[INFO] 2025-05-28 19:03:33 - ------------------------------------------------------------
57+
[INFO] 2025-05-28 19:03:33 - ------------------- Starting AudioRecord Testcase ------------
58+
[INFO] 2025-05-28 19:03:33 - Checking if dependency binary is available
59+
[PASS] 2025-05-28 19:03:45 - Recording completed or timed out (ret=124) as expected and output file exists.
60+
[PASS] 2025-05-28 19:03:45 - AudioRecord : Test Passed
61+
[INFO] 2025-05-28 19:03:45 - See results/audiorecord/parec_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details
62+
[INFO] 2025-05-28 19:03:45 - ------------------- Completed AudioRecord Testcase -------------
63+
[PASS] 2025-05-28 19:03:45 - AudioRecord passed
64+
sh-5.2#
65+
```
66+
67+
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioRecord/AudioRecord.res` directory.
68+
69+
70+
## Notes
71+
72+
- The script does not take any arguments.
73+
- It validates the presence of required libraries before executing tests.
74+
- If any critical tool is missing, the script exits with an error message.
75+
76+
## License
77+
78+
SPDX-License-Identifier: BSD-3-Clause-Clear
79+
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# --------- Robustly source init_env and functestlib.sh ----------
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20+
exit 1
21+
fi
22+
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
# shellcheck disable=SC1090,SC1091
28+
. "$TOOLS/functestlib.sh"
29+
# ---------------------------------------------------------------
30+
31+
TESTNAME="AudioRecord"
32+
TESTBINARY="parec"
33+
RECORD_FILE="/tmp/rec1.wav"
34+
AUDIO_DEVICE="regular0"
35+
LOGDIR="results/audiorecord"
36+
RESULT_FILE="$TESTNAME.res"
37+
38+
test_path=$(find_test_case_by_name "$TESTNAME")
39+
cd "$test_path" || exit 1
40+
mkdir -p "$LOGDIR"
41+
chmod -R 777 "$LOGDIR"
42+
43+
log_info "------------------------------------------------------------"
44+
log_info "------------------- Starting $TESTNAME Testcase ------------"
45+
46+
log_info "Checking if dependency binary is available"
47+
check_dependencies "$TESTBINARY" pgrep timeout
48+
49+
# --- Capture logs BEFORE recording (for debugging) ---
50+
dmesg > "$LOGDIR/dmesg_before.log"
51+
cp /var/log/syslog "$LOGDIR/syslog_before.log" 2>/dev/null
52+
53+
# Remove old record file if present
54+
rm -f "$RECORD_FILE"
55+
56+
# --- Start recording ---
57+
timeout 12s "$TESTBINARY" --rate=48000 --format=s16le --channels=1 --file-format=wav "$RECORD_FILE" -d "$AUDIO_DEVICE" > "$LOGDIR/parec_stdout.log" 2>&1
58+
ret=$?
59+
60+
# --- Capture logs AFTER recording (for debugging) ---
61+
dmesg > "$LOGDIR/dmesg_after.log"
62+
cp /var/log/syslog "$LOGDIR/syslog_after.log" 2>/dev/null
63+
64+
# --- Evaluate result: pass only if process completed successfully and file is non-empty ---
65+
if ([ "$ret" -eq 0 ] || [ "$ret" -eq 124 ]) && [ -s "$RECORD_FILE" ]; then
66+
log_pass "Recording completed or timed out (ret=$ret) as expected and output file exists."
67+
log_pass "$TESTNAME : Test Passed"
68+
echo "$TESTNAME PASS" > "$RESULT_FILE"
69+
else
70+
log_fail "parec failed (status $ret) or recorded file missing/empty"
71+
log_fail "$TESTNAME : Test Failed"
72+
echo "$TESTNAME FAIL" > "$RESULT_FILE"
73+
fi
74+
75+
log_info "See $LOGDIR/parec_stdout.log, dmesg_before/after.log, syslog_before/after.log for debug details"
76+
log_info "------------------- Completed $TESTNAME Testcase -------------"
77+
exit 0

0 commit comments

Comments
 (0)