diff --git a/Runner/suites/Multimedia/CDSP/fastrpc_test/README_CDSP.md b/Runner/suites/Multimedia/CDSP/fastrpc_test/README_CDSP.md deleted file mode 100644 index 5ac6b850..00000000 --- a/Runner/suites/Multimedia/CDSP/fastrpc_test/README_CDSP.md +++ /dev/null @@ -1,81 +0,0 @@ -# FastRPC Test Scripts for Qualcomm Linux based platform (Yocto) - -## Overview - -CDSP scripts demonstrates the usage of FastRPC (Fast Remote Procedure Call) to offload computations to different DSP (Digital Signal Processor) domains. The test application supports multiple examples, including a simple calculator service, a HAP example, and a multithreading example. This test app is publicly available https://github.com/quic/fastrpc - -## Features - -- Simple Calculator Service -- HAP example -- Multithreading Example - -## Prerequisites - -Ensure the following components are present in the target Yocto build (at usr/share/bin/): - -- this test app can be compiled from https://github.com/quic/fastrpc -- `fastrpc_test` : The compiled test application. -- `android Directory` : Contains shared libraries for the Android platform. -- `linux Directory` : Contains shared libraries for the Linux platform. -- `v68 Directory` : Contains skeletons for the v68 architecture version. -- Write access to root filesystem (for environment setup) - -## Directory Structure - -```bash -Runner/ -├── suites/ -│ ├── Multimedia/ -│ │ ├── CDSP/ -│ │ │ ├── fastrpc_test/ -│ │ │ │ ├── run.sh - -``` - -## Usage - - -Instructions - -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. - -2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device. - -3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed. - -Run a specific test using: ---- -Quick Example -``` -git clone -cd -scp -r Runner user@target_device_ip: -ssh user@target_device_ip -cd /Runner && ./run-test.sh -``` -Sample output: -``` -sh-5.2# cd //Runner && ./run-test.sh fastrpc_test -[Executing test case: //Runner/suites/Multimedia/CDSP/fastrpc_test] 1980-01-06 01:33:25 - -[INFO] 1980-01-06 01:33:25 - ----------------------------------------------------------------------------------------- -[INFO] 1980-01-06 01:33:25 - -------------------Starting fastrpc_test Testcase---------------------------- -[INFO] 1980-01-06 01:33:25 - Checking if dependency binary is available -[PASS] 1980-01-06 01:33:25 - Test related dependencies are present. -... -[PASS] 1980-01-06 01:33:27 - fastrpc_test : Test Passed -[INFO] 1980-01-06 01:33:27 - -------------------Completed fastrpc_test Testcase---------------------------- -``` - -4. Results will be available in the `Runner/suites/Multimedia/CDSP/` directory. - -## 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. - -## License - -SPDX-License-Identifier: BSD-3-Clause-Clear -Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. \ No newline at end of file diff --git a/Runner/suites/Multimedia/CDSP/fastrpc_test/fastrpc_test_README.md b/Runner/suites/Multimedia/CDSP/fastrpc_test/fastrpc_test_README.md new file mode 100644 index 00000000..f4427ede --- /dev/null +++ b/Runner/suites/Multimedia/CDSP/fastrpc_test/fastrpc_test_README.md @@ -0,0 +1,126 @@ +# FastRPC Test Script for Qualcomm Linux-based Platforms (Yocto) + +## Overview + +The **fastrpc_test** runner validates FastRPC (Fast Remote Procedure Call) on Qualcomm targets, offloading work to DSP domains (e.g., **CDSP**). +It wraps the public [fastrpc test application](https://github.com/quic/fastrpc) with **robust logging, parameter control, and CI-friendly output**. + +Supported capabilities: +- Auto-detect architecture from SoC ID. +- Multiple iterations and optional timeouts. +- Precise control over where the binary and assets live via `--bin-dir` and `--assets-dir`. +- Unbuffered output via `stdbuf` or `script` when available (falls back gracefully). + +## Features + +- **Calculator**, **HAP**, and **Multithreading** examples (as provided by `fastrpc_test`) +- CI-ready logs with timestamps and per-iteration results +- Parameterized control (`--arch`, `--repeat`, `--timeout`, `--bin-dir`, `--assets-dir`, `--verbose`) +- Auto-detection fallback for binary and assets +- Silent directory scan (no noisy `ls` dumps) + +## Prerequisites + +Have these on the target (or specify paths with the flags below): + +- `fastrpc_test` binary (from [github.com/quic/fastrpc](https://github.com/quic/fastrpc)) +- A **parent directory** that contains a `linux/` subfolder with the required libraries (often alongside the binary), and architecture folders such as `v68`, `v73`, `v75`. +- Optional but recommended: + - `stdbuf` **or** `script` (for unbuffered stdout/stderr) + - `timeout` (GNU coreutils) for wall-clock limiting; the script provides a portable fallback if missing. + +## Directory Structure + +```bash +Runner/ +├── suites/ +│ ├── Multimedia/ +│ │ ├── CDSP/ +│ │ │ ├── fastrpc_test/ +│ │ │ │ ├── run.sh +│ │ │ │ ├── fastrpc_test_README.md +``` + +## Usage + +### Script arguments + +``` +Usage: run.sh [OPTIONS] + +Options: + --arch Architecture (auto-detected from SoC if omitted) + --bin-dir Directory that contains the 'fastrpc_test' binary + --assets-dir Directory that CONTAINS 'linux/' (libs/assets parent) + --repeat Number of iterations (default: 1) + --timeout Timeout per run (no timeout if omitted) + --verbose Extra logging for CI debugging + --help Show this help + +Binary & assets resolution (in order): + Binary: 1) --bin-dir 2) $PATH (command -v fastrpc_test) + Assets: 1) --assets-dir + 2) (if provided) + 3) directory of resolved binary + 4) directory of this run.sh + 5) common locations: /usr/share/bin, /usr/share/fastrpc, /opt/fastrpc +The test executes FROM the assets directory so 'fastrpc_test' can find deps. +``` + +### Quick start + +```bash +# If fastrpc_test is already in PATH and assets are discoverable: +./run.sh --repeat 3 --timeout 60 +``` + +### Common scenarios + +```bash +# 1) Binary in a custom folder; assets are alongside it (i.e., that folder has linux/) +./run.sh --bin-dir /opt/qcom/fastrpc --repeat 5 + +# 2) Binary in PATH; assets somewhere else +./run.sh --assets-dir /opt/qcom/fastrpc_assets --timeout 45 + +# 3) Both explicitly provided (most deterministic) +./run.sh --bin-dir /opt/qcom/fastrpc/bin --assets-dir /opt/qcom/fastrpc --arch v75 --repeat 10 --timeout 30 --verbose + +# 4) Force architecture (skip SoC autodetect) +./run.sh --arch v68 +``` + +### Sample output (trimmed) + +``` +[INFO] 2025-08-13 09:12:01 - -------------------Starting fastrpc_test Testcase---------------------------- +[INFO] 2025-08-13 09:12:01 - Buffering: stdbuf -oL -eL | Timeout: 60 sec | Arch: v68 +[INFO] 2025-08-13 09:12:01 - Resolved binary: /usr/bin/fastrpc_test +[INFO] 2025-08-13 09:12:01 - Assets dir: /usr/bin (linux/ expected here) +[INFO] 2025-08-13 09:12:01 - Running iter1/3 | start: 2025-08-13T09:12:01Z | cmd: fastrpc_test -d 3 -U 1 -t linux -a v68 +... fastrpc_test output ... +[PASS] 2025-08-13 09:12:05 - iter1: pattern matched +[INFO] 2025-08-13 09:12:05 - Running iter2/3 | start: ... +... +[FAIL] 2025-08-13 09:12:15 - fastrpc_test : Test Failed (2/3) | logs: ./logs_fastrpc_test_20250813-091201 +``` + +## CI debugging aids + +- Per-iteration logs: `logs_fastrpc_test_/iterN.out` (+ `iterN.rc`) +- Summary result file: `fastrpc_test.res` (`PASS` / `FAIL`) +- Verbose mode: adds environment, resolutions, and timing details +- Graceful fallbacks when `stdbuf`, `script`, or `timeout` are missing +- Silent scan (no directory spam) during auto-detection + +## Notes + +- If `--arch` is omitted, the script maps `/sys/devices/soc0/soc_id` to a known arch (defaulting to `v68` when unknown). +- If `fastrpc_test` isn’t in `PATH`, use `--bin-dir` or add it to `PATH`. +- If you see `Error resolving path .../linux: No such file or directory`, point `--assets-dir` to the **parent** directory that actually contains a `linux/` subfolder. +- The script changes working directory to the resolved **assets** dir before invoking `fastrpc_test`, which is required for the binary to locate its shared libs/skeletons. + +## License + +SPDX-License-Identifier: BSD-3-Clause-Clear +Copyright (c) Qualcomm Technologies, Inc. diff --git a/Runner/suites/Multimedia/CDSP/fastrpc_test/run.sh b/Runner/suites/Multimedia/CDSP/fastrpc_test/run.sh index e524434d..ae95fdf3 100755 --- a/Runner/suites/Multimedia/CDSP/fastrpc_test/run.sh +++ b/Runner/suites/Multimedia/CDSP/fastrpc_test/run.sh @@ -1,5 +1,4 @@ #!/bin/sh - # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. # SPDX-License-Identifier: BSD-3-Clause-Clear @@ -29,51 +28,245 @@ fi # --------------------------------------------------------------- TESTNAME="fastrpc_test" -test_path=$(find_test_case_by_name "$TESTNAME") +RESULT_FILE="$TESTNAME.res" + +# Defaults +REPEAT=1 +TIMEOUT="" +ARCH="" +BIN_DIR="" # optional: where fastrpc_test lives +ASSETS_DIR="" # optional: parent containing linux/ etc +VERBOSE=0 + +usage() { + cat < Architecture (auto-detected if omitted) + --bin-dir Directory containing 'fastrpc_test' binary + --assets-dir Directory that CONTAINS 'linux/' (run from here if present) + --repeat Number of test repetitions (default: 1) + --timeout Timeout for each run (no timeout if omitted) + --verbose Extra logging for CI debugging + --help Show this help + +Notes: +- If --bin-dir is omitted, 'fastrpc_test' must be on PATH. +- If --assets-dir is omitted or lacks 'linux/', we run from the binary's dir. +- Uses stdbuf/script if available for unbuffered output; otherwise runs plain. +EOF +} + +# Parse arguments +while [ $# -gt 0 ]; do + case "$1" in + --arch) ARCH="$2"; shift 2 ;; + --bin-dir) BIN_DIR="$2"; shift 2 ;; + --assets-dir) ASSETS_DIR="$2"; shift 2 ;; + --repeat) REPEAT="$2"; shift 2 ;; + --timeout) TIMEOUT="$2"; shift 2 ;; + --verbose) VERBOSE=1; shift ;; # actively used below + --help) usage; exit 0 ;; + *) echo "[ERROR] Unknown argument: $1" >&2; usage; exit 1 ;; + esac +done + +# ---------- Validation ---------- +case "$REPEAT" in *[!0-9]*|"") log_error "Invalid --repeat: $REPEAT"; echo "$TESTNAME : FAIL" >"$RESULT_FILE"; exit 1 ;; esac +if [ -n "$TIMEOUT" ]; then + case "$TIMEOUT" in *[!0-9]*|"") log_error "Invalid --timeout: $TIMEOUT"; echo "$TESTNAME : FAIL" >"$RESULT_FILE"; exit 1 ;; esac +fi + +test_path="$(find_test_case_by_name "$TESTNAME")" cd "$test_path" || exit 1 log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" -RESULT_FILE="$TESTNAME.res" -log_info "Checking if dependency binary is available" -export PATH=$PATH:/usr/share/bin -check_dependencies fastrpc_test grep stdbuf - -# Step 1: Read the SoC ID -soc=$(cat /sys/devices/soc0/soc_id) - -# Step 2: Determine the architecture based on SoC ID -case "$soc" in - 498) - architecture="v68" - ;; - 676|534) - architecture="v73" - ;; - 606) - architecture="v75" - ;; - *) - echo "Unknown SoC ID: $soc" - exit 1 - ;; -esac +# Small debug helper +log_debug() { [ "$VERBOSE" -eq 1 ] && log_info "[debug] $*"; } -# Step 3: Execute the command with the architecture -output=$(stdbuf -oL -eL sh -c "cd /usr/share/bin && ./fastrpc_test -d 3 -U 1 -t linux -a \"$architecture\"") +# ---------- Locate binary ---------- +if [ -n "$BIN_DIR" ]; then + FASTBIN="$BIN_DIR/fastrpc_test" + if [ ! -x "$FASTBIN" ]; then + log_fail "fastrpc_test not executable at: $FASTBIN" + echo "$TESTNAME : FAIL" > "$RESULT_FILE" + exit 1 + fi +else + if ! FASTBIN="$(command -v fastrpc_test 2>/dev/null)"; then + log_fail "'fastrpc_test' binary not found on PATH (or use --bin-dir)." + echo "$TESTNAME : FAIL" > "$RESULT_FILE" + exit 1 + fi +fi +BINDIR="$(dirname "$FASTBIN")" +log_info "Binary: $FASTBIN" + +# ---------- Arch detection if needed ---------- +if [ -z "$ARCH" ]; then + soc="$(cat /sys/devices/soc0/soc_id 2>/dev/null || echo "unknown")" + case "$soc" in + 498) ARCH="v68" ;; + 676|534) ARCH="v73" ;; + 606) ARCH="v75" ;; + *) log_warn "Unknown SoC ID: $soc; defaulting to 'v68'"; ARCH="v68" ;; + esac +fi -echo $output +# ---------- Buffering tool availability ---------- +HAVE_STDBUF=0; command -v stdbuf >/dev/null 2>&1 && HAVE_STDBUF=1 +HAVE_SCRIPT=0; command -v script >/dev/null 2>&1 && HAVE_SCRIPT=1 +HAVE_TIMEOUT=0; command -v timeout >/dev/null 2>&1 && HAVE_TIMEOUT=1 -# Check if the output contains the desired string -if echo "$output" | grep -q "All tests completed successfully"; then - log_pass "$TESTNAME : Test Passed" +buf_label="none" +if [ $HAVE_STDBUF -eq 1 ]; then + buf_label="stdbuf -oL -eL" +elif [ $HAVE_SCRIPT -eq 1 ]; then + buf_label="script -q" +fi + +# ---------- Assets directory resolution ---------- +RESOLVED_RUN_DIR="" +if [ -n "$ASSETS_DIR" ]; then + # Use user-provided assets dir if it exists; prefer it if it has linux/ + if [ -d "$ASSETS_DIR" ]; then + RESOLVED_RUN_DIR="$ASSETS_DIR" + if [ ! -d "$ASSETS_DIR/linux" ]; then + log_debug "--assets-dir provided but no 'linux/' inside: $ASSETS_DIR (continuing anyway)" + else + log_info "Using --assets-dir: $ASSETS_DIR (expects: $ASSETS_DIR/linux)" + fi + else + log_warn "--assets-dir not found: $ASSETS_DIR (falling back to binary dir)" + fi +fi + +if [ -z "$RESOLVED_RUN_DIR" ]; then + if [ -d "$BINDIR/linux" ]; then + RESOLVED_RUN_DIR="$BINDIR" + elif [ -d "$SCRIPT_DIR/linux" ]; then + RESOLVED_RUN_DIR="$SCRIPT_DIR" + else + # Last resort: run from the binary directory + RESOLVED_RUN_DIR="$BINDIR" + fi +fi + +# Quiet note if linux/ missing (don’t spam CI output) +[ -d "$RESOLVED_RUN_DIR/linux" ] || log_debug "No 'linux/' under run dir: $RESOLVED_RUN_DIR (binary may still work)" + +# ---------- Timeout wrapper (portable fallback) ---------- +run_with_timeout() { + # Usage: run_with_timeout -- [args...] + tmo="$1"; shift + [ "$1" = "--" ] && shift + if [ -n "$tmo" ] && [ $HAVE_TIMEOUT -eq 1 ]; then + timeout "$tmo" "$@" + return $? + fi + + if [ -z "$tmo" ]; then + "$@" + return $? + fi + + # Fallback: crude timeout using a watcher + ( + setsid "$@" & + child=$! + ( + sleep "$tmo" + if kill -0 "$child" 2>/dev/null; then + # shellcheck disable=SC2046 + kill -TERM -$(ps -o pgid= "$child" | tr -d ' ') 2>/dev/null + fi + ) & + watcher=$! + wait "$child"; rc=$? + kill "$watcher" 2>/dev/null + exit $rc + ) + return $? +} + +# ---------- Logging root ---------- +TS="$(date +%Y%m%d-%H%M%S)" +LOG_ROOT="./logs_${TESTNAME}_${TS}" +mkdir -p "$LOG_ROOT" || { log_error "Cannot create $LOG_ROOT"; echo "$TESTNAME : FAIL" >"$RESULT_FILE"; exit 1; } + +tmo_label="none"; [ -n "$TIMEOUT" ] && tmo_label="${TIMEOUT}s" +log_info "Arch: $ARCH | Repeats: $REPEAT | Timeout: $tmo_label | Buffering: $buf_label" +log_debug "Run dir: $RESOLVED_RUN_DIR | PATH=$PATH" + +# ---------- Run loop ---------- +PASS_COUNT=0 +i=1 +while [ "$i" -le "$REPEAT" ]; do + iter_tag="iter$i" + iter_log="$LOG_ROOT/${iter_tag}.out" + iter_rc="$LOG_ROOT/${iter_tag}.rc" + iso_now="$(date -u +%Y-%m-%dT%H:%M:%SZ)" + + log_info "Running $iter_tag/$REPEAT | start: $iso_now | dir: $RESOLVED_RUN_DIR" + + # Execute from the chosen directory so binary can discover local deps + if [ $HAVE_STDBUF -eq 1 ]; then + ( + cd "$RESOLVED_RUN_DIR" || exit 127 + run_with_timeout "$TIMEOUT" -- stdbuf -oL -eL "$FASTBIN" -d 3 -U 1 -t linux -a "$ARCH" + ) >"$iter_log" 2>&1 + rc=$? + elif [ $HAVE_SCRIPT -eq 1 ]; then + ( + cd "$RESOLVED_RUN_DIR" || exit 127 + if [ -n "$TIMEOUT" ] && [ $HAVE_TIMEOUT -eq 1 ]; then + script -q -c "timeout $TIMEOUT \"$FASTBIN\" -d 3 -U 1 -t linux -a \"$ARCH\"" /dev/null + else + script -q -c "\"$FASTBIN\" -d 3 -U 1 -t linux -a \"$ARCH\"" /dev/null + fi + ) >"$iter_log" 2>&1 + rc=$? + else + ( + cd "$RESOLVED_RUN_DIR" || exit 127 + run_with_timeout "$TIMEOUT" -- "$FASTBIN" -d 3 -U 1 -t linux -a "$ARCH" + ) >"$iter_log" 2>&1 + rc=$? + fi + + printf '%s\n' "$rc" >"$iter_rc" + + # Stream the iteration output to console (compact) + if [ -s "$iter_log" ]; then + echo "----- $iter_tag output begin -----" + cat "$iter_log" + echo "----- $iter_tag output end -----" + fi + + if [ "$rc" -ne 0 ]; then + log_fail "$iter_tag: fastrpc_test exited $rc (see $iter_log)" + fi + + if grep -q "All tests completed successfully" "$iter_log"; then + PASS_COUNT=$((PASS_COUNT+1)) + log_pass "$iter_tag: success" + else + log_warn "$iter_tag: success pattern not found" + fi + + i=$((i+1)) +done + +# ---------- Finalize ---------- +if [ "$PASS_COUNT" -eq "$REPEAT" ]; then + log_pass "$TESTNAME : Test Passed ($PASS_COUNT/$REPEAT)" echo "$TESTNAME : PASS" > "$RESULT_FILE" exit 0 else - log_fail "$TESTNAME : Test Failed" + log_fail "$TESTNAME : Test Failed ($PASS_COUNT/$REPEAT)" echo "$TESTNAME : FAIL" > "$RESULT_FILE" exit 1 fi - -log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file