From 22c1eef512d585f0075f634edbc49fa641f7ca74 Mon Sep 17 00:00:00 2001 From: Abhishek Bajaj Date: Fri, 23 May 2025 19:35:37 +0530 Subject: [PATCH] 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 --- .../suites/Multimedia/Video/README_Video.md | 78 ++++++++++++++++ .../iris_v4l2_video_decode/h264Decoder.json | 20 +++++ .../Video/iris_v4l2_video_decode/run.sh | 23 +++-- .../iris_v4l2_video_encode/h264Encoder.json | 30 +++++++ .../Video/iris_v4l2_video_encode/run.sh | 23 +++-- Runner/utils/functestlib.sh | 89 +++++++++++++++++++ 6 files changed, 249 insertions(+), 14 deletions(-) create mode 100644 Runner/suites/Multimedia/Video/README_Video.md create mode 100644 Runner/suites/Multimedia/Video/iris_v4l2_video_decode/h264Decoder.json create mode 100644 Runner/suites/Multimedia/Video/iris_v4l2_video_encode/h264Encoder.json diff --git a/Runner/suites/Multimedia/Video/README_Video.md b/Runner/suites/Multimedia/Video/README_Video.md new file mode 100644 index 00000000..cbe5fe77 --- /dev/null +++ b/Runner/suites/Multimedia/Video/README_Video.md @@ -0,0 +1,78 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Iris V4L2 Video Test Scripts for Qualcomm Linux based platform (Yocto) + +## Overview + +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 + +## Features + +- V4L2 driver level test +- Encoding YUV to H264 bitstream +- Decoding H264 bitstream to YUV +- Compatible with Yocto-based root filesystem + +## Prerequisites + +Ensure the following components are present in the target Yocto build: + +- `iris_v4l2_test` (available in /usr/bin/) - this test app can be compiled from https://github.com/quic/v4l-video-test-app +- input json file for iris_v4l2_test app +- input bitstream for decode script +- input YUV for encode script +- Write access to root filesystem (for environment setup) + +## Directory Structure + +```bash +Runner/ +├── suites/ +│ ├── Multimedia/ +│ │ ├── Video/ +│ │ │ ├── iris_v4l2_video_encode/ +│ │ │ │ ├── H264Encoder.json +│ │ │ │ ├── run.sh +│ │ │ ├── iris_v4l2_video_decode/ +│ │ │ │ ├── H264Decoder.json +│ │ │ │ ├── run.sh +``` + +## Usage + +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. + +2. Verify Transfer: Ensure that the repo have been successfully copied to the /var directory on the target device. + +3. Run Scripts: Navigate to the /var directory on the target device and execute the scripts as needed. + +Run a specific test using: +--- +Quick Example +``` +git clone +cd +scp -r common Runner user@target_device_ip:/var +ssh user@target_device_ip +cd /var/Runner && ./run-test.sh iris_v4l2_video_encode +``` +Sample output: +``` +sh-5.2# cd /var/Runner && ./run-test.sh iris_v4l2_video_encode +[Executing test case: /var/Runner/suites/Multimedia/Video/iris_v4l2_video_encode] 1980-01-08 22:22:15 - +[INFO] 1980-01-08 22:22:15 - ----------------------------------------------------------------------------------------- +[INFO] 1980-01-08 22:22:15 - -------------------Starting iris_v4l2_video_encode Testcase---------------------------- +[INFO] 1980-01-08 22:22:15 - Checking if dependency binary is available +[PASS] 1980-01-08 22:22:15 - Test related dependencies are present. +... +[PASS] 1980-01-08 22:22:17 - iris_v4l2_video_encode : Test Passed +[INFO] 1980-01-08 22:22:17 - -------------------Completed iris_v4l2_video_encode Testcase---------------------------- +``` +3. Results will be available in the `Runner/suites/Multimedia/Video/` directory under each usecase folder. + +## 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. \ No newline at end of file diff --git a/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/h264Decoder.json b/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/h264Decoder.json new file mode 100644 index 00000000..2afb90f4 --- /dev/null +++ b/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/h264Decoder.json @@ -0,0 +1,20 @@ +{ + "ExecutionMode": "Sequential", + "TestCases": [ + { + "Name" : "Decoder Testcase", + "TestConfigs" : { + "Domain": "Decoder", + "InputPath": "./simple_AVC_720p_10fps_90frames.264", + "NumFrames": -1, + "CodecName": "AVC", + "PixelFormat": "NV12", + "Width": 1280, + "Height": 720, + "Outputpath": "./output_simple_nv12_720p_90frms.yuv", + "InputBufferCount": 16, + "OutputBufferCount": 16 + } + } + ] +} diff --git a/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh b/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh index 68be7d65..7b6beafe 100755 --- a/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh +++ b/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh @@ -1,25 +1,34 @@ #!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + # Import test suite definitions -/var/Runner/init_env -TESTNAME="video_decode" +# shellcheck source=../../../../init_env +. "${PWD}"/init_env +TESTNAME="iris_v4l2_video_decode" +TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/IRIS-Video-Files-v1.0/video_clips_iris.tar.gz" #import test functions library -. $TOOLS/functestlib.sh +# shellcheck source=../../../../utils/functestlib.sh +. "${TOOLS}"/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" log_info "Checking if dependency binary is available" check_dependencies iris_v4l2_test +extract_tar_from_url "$TAR_URL" # Run the first test -iris_v4l2_test --config /Video/DEC_AVC_NV12_BASIC_CFG.json --loglevel 15 >> video_dec.txt +iris_v4l2_test --config "${test_path}/h264Decoder.json" --loglevel 15 >> "${test_path}/video_dec.txt" -if grep -q "Test Passed" "video_dec.txt"; then +if grep -q "SUCCESS" "${test_path}/video_dec.txt"; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res" else log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res" fi + log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/h264Encoder.json b/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/h264Encoder.json new file mode 100644 index 00000000..4855b5bd --- /dev/null +++ b/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/h264Encoder.json @@ -0,0 +1,30 @@ +{ + "ExecutionMode": "Sequential", + "TestCases": [ + { + "Name" : "Encoder Testcase", + "TestConfigs" : { + "Domain": "Encoder", + "InputPath": "./simple_nv12_720p_90frms.yuv", + "NumFrames": -1, + "CodecName": "AVC", + "PixelFormat": "NV12", + "Width": 1280, + "Height": 720, + "Outputpath": "./output_simple_AVC_720p_10fps.h264", + "InputBufferCount": 32, + "OutputBufferCount": 32, + "OperatingRate": 10, + "FrameRate": 10, + "StaticControls": [ + {"Id": "Profile", "Vtype": "String", "Value": "BASELINE"}, + {"Id": "Level", "Vtype": "String", "Value": "5.0"}, + {"Id": "FrameRC", "Vtype": "Int", "Value": 1}, + {"Id": "BitRate", "Vtype": "Int", "Value": 18000000}, + {"Id": "BitRateMode", "Vtype": "String", "Value": "CBR"}, + {"Id": "PrefixHeaderMode", "Vtype": "String", "Value": "JOINED"} + ] + } + } + ] +} diff --git a/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh b/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh index ee63ef4f..bf4bd947 100755 --- a/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh +++ b/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh @@ -1,25 +1,34 @@ #!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + # Import test suite definitions -/var/Runner/init_env -TESTNAME="video_encode" +# shellcheck source=../../../../init_env +. "${PWD}"/init_env +TESTNAME="iris_v4l2_video_encode" +TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/IRIS-Video-Files-v1.0/video_clips_iris.tar.gz" #import test functions library -. $TOOLS/functestlib.sh +# shellcheck source=../../../../utils/functestlib.sh +. "${TOOLS}"/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" log_info "Checking if dependency binary is available" check_dependencies iris_v4l2_test +extract_tar_from_url "$TAR_URL" # Run the first test -iris_v4l2_test --config /Video/ENC_AVC_NV12_BASIC_CFG.json --loglevel 15 >> video_enc.txt +iris_v4l2_test --config "${test_path}/h264Encoder.json" --loglevel 15 >> "${test_path}/video_enc.txt" -if grep -q "Test Passed" "video_enc.txt"; then +if grep -q "SUCCESS" "${test_path}/video_enc.txt"; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res" else log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res" fi + log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/utils/functestlib.sh b/Runner/utils/functestlib.sh index ba9c624f..064485e2 100755 --- a/Runner/utils/functestlib.sh +++ b/Runner/utils/functestlib.sh @@ -91,3 +91,92 @@ functestlibdoc() done echo "Note, these functions will probably not work with >=32 CPUs" } + +# Function is to check for network connectivity status +check_network_status() { + echo "[INFO] Checking network connectivity..." + + # Get first active IPv4 address (excluding loopback) + ip_addr=$(ip -4 addr show scope global up | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1) + + if [ -n "$ip_addr" ]; then + echo "[PASS] Network is active. IP address: $ip_addr" + + if ping -c 1 -W 2 8.8.8.8 >/dev/null 2>&1; then + echo "[PASS] Internet is reachable." + return 0 + else + echo "[WARN] Network active but no internet access." + return 2 + fi + else + echo "[FAIL] No active network interface found." + return 1 + fi +} + +# If the tar file already exists,then function exit. Otherwise function to check the network connectivity and it will download tar from internet. +extract_tar_from_url() { + local url="$1" + local filename + local extracted_files + + # Extract the filename from the URL + filename=$(basename "$url") + if check_tar_file "$filename"; then + echo "[PASS] file already exists, Hence skipping downloading" + return 0 + fi + + check_network_status + network_status=$? + if [ $network_status -ne 0 ]; then + extract_tar_from_url "$TAR_URL" + fi + + # Download the file using wget + echo "[INFO] Downloading $url..." + wget -O "$filename" "$url" + + # Check if wget was successful + if [ $? -ne 0 ]; then + echo "[FAIL] Failed to download the file." + return 1 + fi + + # Extract the tar file + echo "[INFO] Extracting $filename..." + tar -xvf "$filename" + + # Check if tar was successful + if [ $? -ne 0 ]; then + echo "[FAIL] Failed to extract the file." + return 1 + fi + + # Check if any files were extracted + extracted_files=$(tar -tf "$filename") + if [ -z "$extracted_files" ]; then + echo "[FAIL] No files were extracted." + return 1 + else + echo "[PASS] Files extracted successfully:" + echo "[INFO] $extracted_files" + return 0 + fi +} + +# Function to check if a tar file exists +check_tar_file() { + local url="$1" + local filename + local extracted_files + + # Extract the filename from the URL + filename=$(basename "$url") + if [ -f "$filename" ]; then + return 0 + else + return 1 + fi +}