Skip to content

Commit bb71f9f

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 <[email protected]>
1 parent 8ba9498 commit bb71f9f

File tree

5 files changed

+376
-0
lines changed

5 files changed

+376
-0
lines changed

Runner/plans/AudioCI_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+
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
18+
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioPlayback/AudioPlayback.res || true
19+
- $PWD/suites/Multimedia/Audio/AudioRecord/run.sh
20+
- $PWD/utils/send-to-lava.sh $PWD/suites/Multimedia/Audio/AudioRecord/AudioRecord.res || true
21+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# Audio playback Validation Script for Qualcomm Linux based platform (Yocto)
5+
6+
## Overview
7+
8+
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.
9+
10+
## Features
11+
12+
- Decoding PCM clip
13+
- Compatible with Yocto-based root filesystem
14+
15+
## Prerequisites
16+
17+
Ensure the following components are present in the target Yocto build:
18+
19+
- `paplay` binary(available at /usr/bin)
20+
21+
## Directory Structure
22+
23+
```bash
24+
Runner/
25+
├──suites/
26+
├ ├── Multimedia/
27+
│ ├ ├── Audio/
28+
│ ├ ├ ├── AudioPlayback/
29+
│ ├ ├ ├ ├ └── run.sh
30+
├ ├ ├ ├ ├ └── yesterday_48KHz.wav
31+
├ ├ ├ ├ ├ └── audio_test.txt
32+
```
33+
34+
## Usage
35+
36+
37+
Instructions
38+
39+
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 the /var directory on the target device.
40+
41+
2. Verify Transfer: Ensure that the repo have been successfully copied to the /var directory on the target device.
42+
43+
3. Run Scripts: Navigate to the /var directory on the target device and execute the scripts as needed.
44+
45+
Run a specific test using:
46+
---
47+
Quick Example
48+
```
49+
git clone <this-repo>
50+
cd <this-repo>
51+
scp -r common Runner user@target_device_ip:/var
52+
ssh user@target_device_ip
53+
cd /var/Runner && ./run-test.sh AudioPlayback
54+
```
55+
Sample Output:
56+
```
57+
sh-5.2# cd /var/Runner && ./run-test.sh AudioPlayback
58+
[Executing test case: /var/Runner/suites/Multimedia/Audio/AudioPlayback] 1980-01-08 18:11:49 -
59+
[INFO] 1980-01-08 18:11:49 - --------------------------------------------------------------------------
60+
[INFO] 1980-01-08 18:11:49 - -------------------Starting audio_playback_test Testcase----------------------------
61+
[INFO] 1980-01-08 18:11:49 - Checking if dependency binary is available
62+
[PASS] 1980-01-08 18:11:49 - Test related dependencies are present.
63+
[INFO] Checking network connectivity...
64+
[FAIL] No active network interface found.
65+
[INFO] Downloading https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/Pulse-Audio-Files-v1.0/AudioClips.tar.gz...
66+
[INFO] 1980-01-08 18:11:49 - Playback clip downloaded
67+
/var/Runner/suites/Multimedia/Audio/AudioPlayback/run.sh: line 50: [-z: command not found
68+
[INFO] 1980-01-08 18:11:59 - Test Binary paplay is running successfully
69+
[INFO] 1980-01-08 18:11:59 - === Overall Audio Test Validation Result ===
70+
[INFO] 1980-01-08 18:11:59 - Param 26916561
71+
2691687 pts/0 S+ 0:00 paplay ./suites/Multimedia/Audio/AudioPlayback/yesterday_48KHz.wav -d low-latency0
72+
[INFO] 1980-01-08 18:11:59 - Successfully audio playback completed
73+
[PASS] 1980-01-08 18:11:59 - audio_playback_test : Test Passed
74+
[INFO] 1980-01-08 18:11:59 - Clean up the old PID by Killing the process
75+
[INFO] 1980-01-08 18:11:59 - 2691685
76+
/var/Runner/suites/Multimedia/Audio/AudioPlayback/run.sh: line 86: 2691685 Killed tail -f /var/log/syslog > results/audiotestresult/syslog_log.txt
77+
[INFO] 1980-01-08 18:12:00 - 2691686
78+
/var/Runner/suites/Multimedia/Audio/AudioPlayback/run.sh: line 86: 2691686 Killed dmesg -w > results/audiotestresult/dmesg_log.txt
79+
[INFO] 1980-01-08 18:12:01 - 2691687
80+
/var/Runner/suites/Multimedia/Audio/AudioPlayback/run.sh: line 86: 2691687 Killed paplay ./suites/Multimedia/Audio/AudioPlayback/yesterday_48KHz.wav -d low-latency0
81+
[INFO] 1980-01-08 18:12:02 - -------------------Completed audio_playback_test Testcase----------------------------
82+
sh-5.2#
83+
```
84+
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioPlayback/audio_test.txt` directory.
85+
86+
87+
## Notes
88+
89+
- The script does not take any arguments.
90+
- It validates the presence of required libraries before executing tests.
91+
- If any critical tool is missing, the script exits with an error message.
92+
93+
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: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# Audio encode Validation Script for Qualcomm Linux based platform (Yocto)
5+
6+
## Overview
7+
8+
This script automates the validation of audio encode capabilities on the Qualcomm RB3 Gen2 platform running a Yocto-based Linux system. It utilizes pulseaudio test app to encode file.
9+
10+
## Features
11+
12+
- Encode PCM clip with --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0
13+
- Compatible with Yocto-based root filesystem
14+
15+
## Prerequisites
16+
17+
Ensure the following components are present in the target Yocto build:
18+
19+
- `parec` binary(available at /usr/bin)
20+
21+
## Directory Structure
22+
23+
```bash
24+
Runner/
25+
├──suites/
26+
├ ├── Multimedia/
27+
│ ├ ├── Audio/
28+
│ ├ ├ ├── AudioRecord/
29+
│ ├ ├ ├ ├ └── run.sh
30+
├ ├ ├ ├ ├ └── audio_test.txt
31+
```
32+
33+
## Usage
34+
35+
36+
Instructions
37+
38+
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 the /var directory on the target device.
39+
40+
2. Verify Transfer: Ensure that the repo have been successfully copied to the /var directory on the target device.
41+
42+
3. Run Scripts: Navigate to the /var directory on the target device and execute the scripts as needed.
43+
44+
Run a specific test using:
45+
---
46+
Quick Example
47+
```
48+
git clone <this-repo>
49+
cd <this-repo>
50+
scp -r common Runner user@target_device_ip:/var
51+
ssh user@target_device_ip
52+
cd /var/Runner && ./run-test.sh AudioRecord
53+
```
54+
55+
Sample Output:
56+
```
57+
sh-5.2# cd /var/Runner && ./run-test.sh AudioRecord
58+
[Executing test case: /var/Runner/suites/Multimedia/Audio/AudioRecord] 1980-01-08 18:13:16 -
59+
[INFO] 1980-01-08 18:13:16 - --------------------------------------------------------------------------
60+
[INFO] 1980-01-08 18:13:16 - -------------------Starting audio_record_test Testcase----------------------------
61+
[INFO] 1980-01-08 18:13:16 - Checking if dependency binary is available
62+
[PASS] 1980-01-08 18:13:16 - Test related dependencies are present.
63+
/var/Runner/suites/Multimedia/Audio/AudioRecord/run.sh: line 44: [-z: command not found
64+
[INFO] 1980-01-08 18:13:28 - Test Binary parec is running successfully
65+
[INFO] 1980-01-08 18:13:28 - === Overall Audio Test Validation Result ===
66+
[INFO] 1980-01-08 18:13:28 - Param 26917541
67+
2691777 pts/0 S+ 0:00 parec --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0
68+
[INFO] 1980-01-08 18:13:28 - Successfully audio record completed
69+
[PASS] 1980-01-08 18:13:28 - audio_record_test : Test Passed
70+
[INFO] 1980-01-08 18:13:28 - Clean up the old PID by Killing the process
71+
[INFO] 1980-01-08 18:13:28 - 2691773
72+
/var/Runner/suites/Multimedia/Audio/AudioRecord/run.sh: line 80: 2691773 Killed tail -f /var/log/syslog > results/audiotestresult/syslog_log.txt
73+
[INFO] 1980-01-08 18:13:29 - 2691774
74+
/var/Runner/suites/Multimedia/Audio/AudioRecord/run.sh: line 80: 2691774 Killed dmesg -w > results/audiotestresult/dmesg_log.txt
75+
[INFO] 1980-01-08 18:13:30 - 2691777
76+
/var/Runner/suites/Multimedia/Audio/AudioRecord/run.sh: line 80: 2691777 Killed parec --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0
77+
[PASS] 1980-01-08 18:13:31 - audio_record_test : Recorded clip available
78+
[INFO] 1980-01-08 18:13:31 - -------------------Completed audio_record_test Testcase----------------------------
79+
sh-5.2#
80+
```
81+
82+
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioRecord/audio_test.txt` directory.
83+
84+
85+
## Notes
86+
87+
- The script does not take any arguments.
88+
- It validates the presence of required libraries before executing tests.
89+
- If any critical tool is missing, the script exits with an error message.
90+
91+
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)