Skip to content

Commit 5d379ce

Browse files
abbajaj806mwasilew
authored andcommitted
Public CI Video Decode and Encode Shell Scripts.
Implemented shell scripts for public CI for Decode and Encode Scenarios. Added Video encode test script Added Video decode test script Added readme document for video validation Implemented Function for ActiveIP Implemented Function for wget pull resource Implemented Function for untar of resource Implemented Function to check if file is already present or not Signed-off-by: Abhishek Bajaj <[email protected]>
1 parent 377a8b4 commit 5d379ce

File tree

6 files changed

+249
-14
lines changed

6 files changed

+249
-14
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# Iris V4L2 Video Test Scripts for Qualcomm Linux based platform (Yocto)
5+
6+
## Overview
7+
8+
Video scripts automates the validation of video encoding and decoding capabilities on the Qualcomm Linux based platform running a Yocto-based Linux system. It utilizes iri_v4l2_test test app which is publicly available @https://github.com/quic/v4l-video-test-app
9+
10+
## Features
11+
12+
- V4L2 driver level test
13+
- Encoding YUV to H264 bitstream
14+
- Decoding H264 bitstream to YUV
15+
- Compatible with Yocto-based root filesystem
16+
17+
## Prerequisites
18+
19+
Ensure the following components are present in the target Yocto build:
20+
21+
- `iris_v4l2_test` (available in /usr/bin/) - this test app can be compiled from https://github.com/quic/v4l-video-test-app
22+
- input json file for iris_v4l2_test app
23+
- input bitstream for decode script
24+
- input YUV for encode script
25+
- Write access to root filesystem (for environment setup)
26+
27+
## Directory Structure
28+
29+
```bash
30+
Runner/
31+
├── suites/
32+
│ ├── Multimedia/
33+
│ │ ├── Video/
34+
│ │ │ ├── iris_v4l2_video_encode/
35+
│ │ │ │ ├── H264Encoder.json
36+
│ │ │ │ ├── run.sh
37+
│ │ │ ├── iris_v4l2_video_decode/
38+
│ │ │ │ ├── H264Decoder.json
39+
│ │ │ │ ├── run.sh
40+
```
41+
42+
## Usage
43+
44+
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.
45+
46+
2. Verify Transfer: Ensure that the repo have been successfully copied to the /var directory on the target device.
47+
48+
3. Run Scripts: Navigate to the /var directory on the target device and execute the scripts as needed.
49+
50+
Run a specific test using:
51+
---
52+
Quick Example
53+
```
54+
git clone <this-repo>
55+
cd <this-repo>
56+
scp -r common Runner user@target_device_ip:/var
57+
ssh user@target_device_ip
58+
cd /var/Runner && ./run-test.sh iris_v4l2_video_encode
59+
```
60+
Sample output:
61+
```
62+
sh-5.2# cd /var/Runner && ./run-test.sh iris_v4l2_video_encode
63+
[Executing test case: /var/Runner/suites/Multimedia/Video/iris_v4l2_video_encode] 1980-01-08 22:22:15 -
64+
[INFO] 1980-01-08 22:22:15 - -----------------------------------------------------------------------------------------
65+
[INFO] 1980-01-08 22:22:15 - -------------------Starting iris_v4l2_video_encode Testcase----------------------------
66+
[INFO] 1980-01-08 22:22:15 - Checking if dependency binary is available
67+
[PASS] 1980-01-08 22:22:15 - Test related dependencies are present.
68+
...
69+
[PASS] 1980-01-08 22:22:17 - iris_v4l2_video_encode : Test Passed
70+
[INFO] 1980-01-08 22:22:17 - -------------------Completed iris_v4l2_video_encode Testcase----------------------------
71+
```
72+
3. Results will be available in the `Runner/suites/Multimedia/Video/` directory under each usecase folder.
73+
74+
## Notes
75+
76+
- The script does not take any arguments.
77+
- It validates the presence of required libraries before executing tests.
78+
- If any critical tool is missing, the script exits with an error message.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"ExecutionMode": "Sequential",
3+
"TestCases": [
4+
{
5+
"Name" : "Decoder Testcase",
6+
"TestConfigs" : {
7+
"Domain": "Decoder",
8+
"InputPath": "./simple_AVC_720p_10fps_90frames.264",
9+
"NumFrames": -1,
10+
"CodecName": "AVC",
11+
"PixelFormat": "NV12",
12+
"Width": 1280,
13+
"Height": 720,
14+
"Outputpath": "./output_simple_nv12_720p_90frms.yuv",
15+
"InputBufferCount": 16,
16+
"OutputBufferCount": 16
17+
}
18+
}
19+
]
20+
}
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
26
# Import test suite definitions
3-
/var/Runner/init_env
4-
TESTNAME="video_decode"
7+
# shellcheck source=../../../../init_env
8+
. "${PWD}"/init_env
9+
TESTNAME="iris_v4l2_video_decode"
10+
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/IRIS-Video-Files-v1.0/video_clips_iris.tar.gz"
511

612
#import test functions library
7-
. $TOOLS/functestlib.sh
13+
# shellcheck source=../../../../utils/functestlib.sh
14+
. "${TOOLS}"/functestlib.sh
815
test_path=$(find_test_case_by_name "$TESTNAME")
916
log_info "-----------------------------------------------------------------------------------------"
1017
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
1118

1219
log_info "Checking if dependency binary is available"
1320
check_dependencies iris_v4l2_test
21+
extract_tar_from_url "$TAR_URL"
1422

1523
# Run the first test
16-
iris_v4l2_test --config /Video/DEC_AVC_NV12_BASIC_CFG.json --loglevel 15 >> video_dec.txt
24+
iris_v4l2_test --config "${test_path}/h264Decoder.json" --loglevel 15 >> "${test_path}/video_dec.txt"
1725

18-
if grep -q "Test Passed" "video_dec.txt"; then
26+
if grep -q "SUCCESS" "${test_path}/video_dec.txt"; then
1927
log_pass "$TESTNAME : Test Passed"
20-
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
28+
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
2129
else
2230
log_fail "$TESTNAME : Test Failed"
23-
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
31+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
2432
fi
33+
2534
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"ExecutionMode": "Sequential",
3+
"TestCases": [
4+
{
5+
"Name" : "Encoder Testcase",
6+
"TestConfigs" : {
7+
"Domain": "Encoder",
8+
"InputPath": "./simple_nv12_720p_90frms.yuv",
9+
"NumFrames": -1,
10+
"CodecName": "AVC",
11+
"PixelFormat": "NV12",
12+
"Width": 1280,
13+
"Height": 720,
14+
"Outputpath": "./output_simple_AVC_720p_10fps.h264",
15+
"InputBufferCount": 32,
16+
"OutputBufferCount": 32,
17+
"OperatingRate": 10,
18+
"FrameRate": 10,
19+
"StaticControls": [
20+
{"Id": "Profile", "Vtype": "String", "Value": "BASELINE"},
21+
{"Id": "Level", "Vtype": "String", "Value": "5.0"},
22+
{"Id": "FrameRC", "Vtype": "Int", "Value": 1},
23+
{"Id": "BitRate", "Vtype": "Int", "Value": 18000000},
24+
{"Id": "BitRateMode", "Vtype": "String", "Value": "CBR"},
25+
{"Id": "PrefixHeaderMode", "Vtype": "String", "Value": "JOINED"}
26+
]
27+
}
28+
}
29+
]
30+
}
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
26
# Import test suite definitions
3-
/var/Runner/init_env
4-
TESTNAME="video_encode"
7+
# shellcheck source=../../../../init_env
8+
. "${PWD}"/init_env
9+
TESTNAME="iris_v4l2_video_encode"
10+
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/IRIS-Video-Files-v1.0/video_clips_iris.tar.gz"
511

612
#import test functions library
7-
. $TOOLS/functestlib.sh
13+
# shellcheck source=../../../../utils/functestlib.sh
14+
. "${TOOLS}"/functestlib.sh
815
test_path=$(find_test_case_by_name "$TESTNAME")
916
log_info "-----------------------------------------------------------------------------------------"
1017
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
1118

1219
log_info "Checking if dependency binary is available"
1320
check_dependencies iris_v4l2_test
21+
extract_tar_from_url "$TAR_URL"
1422

1523
# Run the first test
16-
iris_v4l2_test --config /Video/ENC_AVC_NV12_BASIC_CFG.json --loglevel 15 >> video_enc.txt
24+
iris_v4l2_test --config "${test_path}/h264Encoder.json" --loglevel 15 >> "${test_path}/video_enc.txt"
1725

18-
if grep -q "Test Passed" "video_enc.txt"; then
26+
if grep -q "SUCCESS" "${test_path}/video_enc.txt"; then
1927
log_pass "$TESTNAME : Test Passed"
20-
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
28+
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
2129
else
2230
log_fail "$TESTNAME : Test Failed"
23-
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
31+
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
2432
fi
33+
2534
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

Runner/utils/functestlib.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,92 @@ functestlibdoc()
9191
done
9292
echo "Note, these functions will probably not work with >=32 CPUs"
9393
}
94+
95+
# Function is to check for network connectivity status
96+
check_network_status() {
97+
echo "[INFO] Checking network connectivity..."
98+
99+
# Get first active IPv4 address (excluding loopback)
100+
ip_addr=$(ip -4 addr show scope global up | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1)
101+
102+
if [ -n "$ip_addr" ]; then
103+
echo "[PASS] Network is active. IP address: $ip_addr"
104+
105+
if ping -c 1 -W 2 8.8.8.8 >/dev/null 2>&1; then
106+
echo "[PASS] Internet is reachable."
107+
return 0
108+
else
109+
echo "[WARN] Network active but no internet access."
110+
return 2
111+
fi
112+
else
113+
echo "[FAIL] No active network interface found."
114+
return 1
115+
fi
116+
}
117+
118+
# If the tar file already exists,then function exit. Otherwise function to check the network connectivity and it will download tar from internet.
119+
extract_tar_from_url() {
120+
local url="$1"
121+
local filename
122+
local extracted_files
123+
124+
# Extract the filename from the URL
125+
filename=$(basename "$url")
126+
if check_tar_file "$filename"; then
127+
echo "[PASS] file already exists, Hence skipping downloading"
128+
return 0
129+
fi
130+
131+
check_network_status
132+
network_status=$?
133+
if [ $network_status -ne 0 ]; then
134+
extract_tar_from_url "$TAR_URL"
135+
fi
136+
137+
# Download the file using wget
138+
echo "[INFO] Downloading $url..."
139+
wget -O "$filename" "$url"
140+
141+
# Check if wget was successful
142+
if [ $? -ne 0 ]; then
143+
echo "[FAIL] Failed to download the file."
144+
return 1
145+
fi
146+
147+
# Extract the tar file
148+
echo "[INFO] Extracting $filename..."
149+
tar -xvf "$filename"
150+
151+
# Check if tar was successful
152+
if [ $? -ne 0 ]; then
153+
echo "[FAIL] Failed to extract the file."
154+
return 1
155+
fi
156+
157+
# Check if any files were extracted
158+
extracted_files=$(tar -tf "$filename")
159+
if [ -z "$extracted_files" ]; then
160+
echo "[FAIL] No files were extracted."
161+
return 1
162+
else
163+
echo "[PASS] Files extracted successfully:"
164+
echo "[INFO] $extracted_files"
165+
return 0
166+
fi
167+
}
168+
169+
# Function to check if a tar file exists
170+
check_tar_file() {
171+
local url="$1"
172+
local filename
173+
local extracted_files
174+
175+
# Extract the filename from the URL
176+
filename=$(basename "$url")
177+
if [ -f "$filename" ]; then
178+
return 0
179+
else
180+
return 1
181+
fi
182+
}

0 commit comments

Comments
 (0)