Skip to content

Commit 1282816

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 Signed-off-by: Abhishek Bajaj <[email protected]>
1 parent 8ba9498 commit 1282816

File tree

4 files changed

+367
-0
lines changed

4 files changed

+367
-0
lines changed
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+
# Import test suite definitions
7+
# shellcheck source=../../../../init_env
8+
. "${PWD}"/init_env
9+
TESTNAME="AudioPlayback"
10+
TESTBINARY="paplay"
11+
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/Pulse-Audio-Files-v1.0/AudioClips.tar.gz"
12+
13+
# Global variable to hold PIDs to be killed at the end of the test
14+
KILLPID=""
15+
16+
# Import test functions
17+
# shellcheck source=../../../../utils/functestlib.sh
18+
. "${TOOLS}"/functestlib.sh
19+
test_path=$(find_test_case_by_name "$TESTNAME")
20+
21+
log_info "--------------------------------------------------------------------------"
22+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
23+
24+
log_info "Checking if dependency binary is available"
25+
check_dependencies "$TESTBINARY"
26+
27+
extract_tar_from_url "$TAR_URL"
28+
29+
lscontent=$(ls "${PWD}"/AudioClips)
30+
case "$lscontent" in
31+
*yesterday_48KHz.wav*) log_info "Playback clip downloaded" ;;
32+
*) log_info "Playback clip not downloaded" ;;
33+
esac
34+
35+
# Prepare environment
36+
mkdir -p results/audiotestresult
37+
chmod -R 777 results/audiotestresult
38+
39+
# Start logs
40+
dmesg -C
41+
tail -f /var/log/syslog > results/audiotestresult/syslog_log.txt &
42+
KILLPID="$KILLPID $!"
43+
44+
dmesg -w > results/audiotestresult/dmesg_log.txt &
45+
KILLPID="$KILLPID $!"
46+
47+
# Start the Playback
48+
paplay "${PWD}"/AudioClips/yesterday_48KHz.wav -d low-latency0 &
49+
PID=$!
50+
KILLPID="$KILLPID $!"
51+
sleep 10
52+
53+
# Check whether playback started
54+
if [ -z "$PID" ]; then
55+
log_info "Fail to start the test binary $TESTBINARY"
56+
exit 1
57+
else
58+
log_info "Test Binary $TESTBINARY is running successfully"
59+
fi
60+
61+
check_audio_pid_alive() {
62+
log_info "Checking if audio process with PID $1 is alive"
63+
local pid="$1"
64+
local result_file="results/audiotestresult/stdout.txt"
65+
pgrep -af "$TESTBINARY" | head -1 | tee "$result_file"
66+
67+
if grep -q "$pid" "$result_file"; then
68+
log_info "Successfully audio playback completed"
69+
return 0
70+
else
71+
log_info "Fail to start audio playback"
72+
return 1
73+
fi
74+
}
75+
76+
# Final status, Print overall test result
77+
log_info "=== Overall Audio Test Validation Result ==="
78+
if check_audio_pid_alive "$PID"; then
79+
log_pass "$TESTNAME : Test Passed"
80+
echo "$TESTNAME : PASS" > "$test_path/$TESTNAME.res"
81+
else
82+
log_fail "$TESTNAME : Test Failed"
83+
echo "$TESTNAME : FAIL" > "$test_path/$TESTNAME.res"
84+
fi
85+
86+
# Clean up
87+
log_info "Clean up the old PID by Killing the process"
88+
for id in $KILLPID; do
89+
log_info "$id"
90+
kill -9 "$id" >/dev/null 2>&1
91+
sleep 1
92+
done
93+
94+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Audio enccode Validation Script for RB3 Gen2 (Yocto)
2+
3+
## Overview
4+
5+
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.
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+
├ ├ ├ ├ ├ └── audio_test.txt
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 the /var directory on the target device.
36+
37+
2. Verify Transfer: Ensure that the repo have been successfully copied to the /var directory on the target device.
38+
39+
3. Run Scripts: Navigate to the /var directory 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:/var
48+
ssh user@target_device_ip
49+
cd /var/Runner && ./run-test.sh AudioRecord
50+
```
51+
52+
Sample Output:
53+
```
54+
sh-5.2# cd /var/Runner && ./run-test.sh AudioRecord
55+
[Executing test case: /var/Runner/suites/Multimedia/Audio/AudioRecord] 1980-01-08 18:13:16 -
56+
[INFO] 1980-01-08 18:13:16 - --------------------------------------------------------------------------
57+
[INFO] 1980-01-08 18:13:16 - -------------------Starting audio_record_test Testcase----------------------------
58+
[INFO] 1980-01-08 18:13:16 - Checking if dependency binary is available
59+
[PASS] 1980-01-08 18:13:16 - Test related dependencies are present.
60+
/var/Runner/suites/Multimedia/Audio/AudioRecord/run.sh: line 44: [-z: command not found
61+
[INFO] 1980-01-08 18:13:28 - Test Binary parec is running successfully
62+
[INFO] 1980-01-08 18:13:28 - === Overall Audio Test Validation Result ===
63+
[INFO] 1980-01-08 18:13:28 - Param 26917541
64+
2691777 pts/0 S+ 0:00 parec --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0
65+
[INFO] 1980-01-08 18:13:28 - Successfully audio record completed
66+
[PASS] 1980-01-08 18:13:28 - audio_record_test : Test Passed
67+
[INFO] 1980-01-08 18:13:28 - Clean up the old PID by Killing the process
68+
[INFO] 1980-01-08 18:13:28 - 2691773
69+
/var/Runner/suites/Multimedia/Audio/AudioRecord/run.sh: line 80: 2691773 Killed tail -f /var/log/syslog > results/audiotestresult/syslog_log.txt
70+
[INFO] 1980-01-08 18:13:29 - 2691774
71+
/var/Runner/suites/Multimedia/Audio/AudioRecord/run.sh: line 80: 2691774 Killed dmesg -w > results/audiotestresult/dmesg_log.txt
72+
[INFO] 1980-01-08 18:13:30 - 2691777
73+
/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
74+
[PASS] 1980-01-08 18:13:31 - audio_record_test : Recorded clip available
75+
[INFO] 1980-01-08 18:13:31 - -------------------Completed audio_record_test Testcase----------------------------
76+
sh-5.2#
77+
```
78+
79+
3. Results will be available in the `Runner/suites/Multimedia/Audio/AudioRecord/audio_test.txt` directory.
80+
81+
82+
## Notes
83+
84+
- The script does not take any arguments.
85+
- It validates the presence of required libraries before executing tests.
86+
- If any critical tool is missing, the script exits with an error message.
87+
88+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# Import test suite definitions
7+
# shellcheck source=../../../../init_env
8+
. "${PWD}"/init_env
9+
TESTNAME="AudioRecord"
10+
TESTBINARY="parec"
11+
12+
# Global variable to hold PIDs to be killed at the end of the test
13+
KILLPID=""
14+
15+
# Import test functions
16+
# shellcheck source=../../../../utils/functestlib.sh
17+
. "${TOOLS}"/functestlib.sh
18+
test_path=$(find_test_case_by_name "$TESTNAME")
19+
20+
log_info "--------------------------------------------------------------------------"
21+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
22+
23+
log_info "Checking if dependency binary is available"
24+
check_dependencies "$TESTBINARY"
25+
26+
# Prepare environment
27+
mkdir -p results/audiotestresult
28+
chmod -R 777 results/audiotestresult
29+
30+
# Start logs
31+
dmesg -C
32+
tail -f /var/log/syslog > results/audiotestresult/syslog_log.txt &
33+
KILLPID="$KILLPID $!"
34+
35+
dmesg -w > results/audiotestresult/dmesg_log.txt &
36+
KILLPID="$KILLPID $!"
37+
38+
# Start the recording
39+
rm -rf /tmp/rec1.wav
40+
sleep 2
41+
parec --rate=48000 --format=s16le --channels=1 --file-format=wav /tmp/rec1.wav -d regular0 &
42+
PID=$!
43+
KILLPID="$KILLPID $!"
44+
sleep 10
45+
46+
# Check whether recording started
47+
if [ -z "$PID" ]; then
48+
log_info "Fail to start the test binary $TESTBINARY"
49+
exit 1
50+
else
51+
log_info "Test Binary $TESTBINARY is running successfully"
52+
fi
53+
54+
check_audio_pid_alive() {
55+
log_info "Checking if process $1 is alive"
56+
local result_file="results/audiotestresult/stdout.txt"
57+
if pgrep -f "$TESTBINARY" > "$result_file"; then
58+
log_info "Successfully audio record completed"
59+
return 0
60+
else
61+
log_info "Fail to start audio record"
62+
return 1
63+
fi
64+
}
65+
66+
# Final status, Print overall test result
67+
log_info "=== Overall Audio Test Validation Result ==="
68+
if check_audio_pid_alive "$PID"; then
69+
log_pass "$TESTNAME : Test Passed"
70+
echo "$TESTNAME : PASS" > "$test_path/$TESTNAME.res"
71+
else
72+
log_fail "$TESTNAME : Test Failed"
73+
echo "$TESTNAME : FAIL" > "$test_path/$TESTNAME.res"
74+
fi
75+
76+
# Clean up
77+
log_info "Clean up the old PID by Killing the process"
78+
for id in $KILLPID; do
79+
log_info "$id"
80+
kill -9 "$id" >/dev/null 2>&1
81+
sleep 1
82+
done
83+
84+
if [ -f /tmp/rec1.wav ]; then
85+
log_pass "$TESTNAME : Recorded clip available"
86+
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
87+
else
88+
log_fail "$TESTNAME : Recorded clip not available"
89+
echo "$TESTNAME : FAIL" > "$test_path/$TESTNAME.res"
90+
fi
91+
92+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

0 commit comments

Comments
 (0)