From 6c84528252440800795b28eb9f15f6d65c6cdbea Mon Sep 17 00:00:00 2001 From: Aanchal Chaurasia Date: Mon, 2 Feb 2026 03:46:10 +0530 Subject: [PATCH 1/3] Add test script to validate USB SSP The shell script verifies successful enumeration of connected USB Devices in SuperSpeed Plus (SSP). Signed-off-by: Aanchal Chaurasia --- Runner/suites/Kernel/Baseport/usb_ssp/run.sh | 113 +++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100755 Runner/suites/Kernel/Baseport/usb_ssp/run.sh diff --git a/Runner/suites/Kernel/Baseport/usb_ssp/run.sh b/Runner/suites/Kernel/Baseport/usb_ssp/run.sh new file mode 100755 index 00000000..f4b8d046 --- /dev/null +++ b/Runner/suites/Kernel/Baseport/usb_ssp/run.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Validate that at least one non-hub USB peripheral is enumerated at SuperSpeedPlus (>= 10000 Mb/s). +# This test ignores hubs and only considers actual USB devices. + +# Robustly find and source init_env +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +# Only source if not already loaded (idempotent) +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi +# Always source functestlib.sh, using $TOOLS exported by init_env +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="usb_ssp" +test_path=$(find_test_case_by_name "$TESTNAME") +cd "$test_path" || exit 1 +# shellcheck disable=SC2034 +res_file="./$TESTNAME.res" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" +log_info "=== Test Initialization ===" + +log_info "=== Detecting non-hub Superspeed Plus USB devices ===" + +# We rely on sysfs entries under /sys/bus/usb/devices for authoritative device speed. +# Criteria: +# - Only consider entries with bDeviceClass (device-level), skip interface-only entries. +# - Ignore hubs: device class 0x09 (9). +# - Consider a device SuperSpeedPlus if speed (Mb/s) is >= 10000. + +non_hub_count=0 +ssp_count=0 + +for d in /sys/bus/usb/devices/*; do + [ -d "$d" ] || continue + + # Must be a device (has bDeviceClass); skip interface/function entries like 1-1:1.0 + if [ ! -f "$d/bDeviceClass" ]; then + continue + fi + + class="$(tr -d '[:space:]' 2>/dev/null < "$d/bDeviceClass")" + case "$class" in + 09|9|0x09|0X09) # Hub device; ignore + continue + ;; + esac + + raw_speed="$(cat "$d/speed" 2>/dev/null || echo 0)" + speed_int="${raw_speed%%.*}" + case "$speed_int" in + ''|*[!0-9]*) + speed_int=0 + ;; + esac + + busnum="$(cat "$d/busnum" 2>/dev/null || echo "?")" + devnum="$(cat "$d/devnum" 2>/dev/null || echo "?")" + idVendor="$(cat "$d/idVendor" 2>/dev/null || echo "0000")" + idProduct="$(cat "$d/idProduct" 2>/dev/null || echo "0000")" + product="$(cat "$d/product" 2>/dev/null || true)" + [ -n "$product" ] || product="(unknown)" + + echo "Device: $busnum $devnum ${idVendor}:${idProduct} \"$product\" ${raw_speed}" + + non_hub_count=$((non_hub_count + 1)) + if [ "$speed_int" -ge 10000 ]; then + ssp_count=$((ssp_count + 1)) + fi +done + +echo "SuperSpeedPlus (>=10000 Mb/s) device count: $ssp_count" + +if [ "$non_hub_count" -eq 0 ]; then + log_fail "$TESTNAME : Test Failed - No non-hub USB peripherals detected. Only hubs or no devices present." + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +fi + +if [ "$ssp_count" -gt 0 ]; then + log_pass "$TESTNAME : Test Passed - $ssp_count SuperSpeedPlus device(s) found among $non_hub_count non-hub device(s)." + echo "$TESTNAME PASS" > "$res_file" + exit 0 +else + log_fail "$TESTNAME : Test Failed - No non-hub USB device enumerated at SuperSpeedPlus (>= 10000 Mb/s)." + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +fi + +log_info "-------------------Completed $TESTNAME Testcase----------------------------" From 3b518b6b2a56db5a0ac8c6baf1fce39d7396b7ce Mon Sep 17 00:00:00 2001 From: Aanchal Chaurasia Date: Mon, 2 Feb 2026 03:47:34 +0530 Subject: [PATCH 2/3] Add documentation for Runner/../usb_ssp/run.sh Added setup information and basic requirements. This informs the tester of the hardware setup requirement before starting test. Signed-off-by: Aanchal Chaurasia --- .../suites/Kernel/Baseport/usb_ssp/README.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Runner/suites/Kernel/Baseport/usb_ssp/README.md diff --git a/Runner/suites/Kernel/Baseport/usb_ssp/README.md b/Runner/suites/Kernel/Baseport/usb_ssp/README.md new file mode 100644 index 00000000..bd194e83 --- /dev/null +++ b/Runner/suites/Kernel/Baseport/usb_ssp/README.md @@ -0,0 +1,37 @@ +``` +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +SPDX-License-Identifier: BSD-3-Clause-Clear +``` + +# USB SuperSpeed Plus Validation + +## Overview + +This shell script executes on the DUT (Device-Under-Test) and verifies successful enumeration of connected USB Devices in SuperSpeed Plus (SSP). + +--- + +## Setup + +- Connect USB peripheral(s) to USB port(s) on DUT. +- Only applicable for USB ports that support Host Mode functionality. +- USB peripherals examples: Mass Storage devices (pendrives, SSD, hard drives, etc.), HID devices (Mouse, Keyboard, USB headset, USB camera, etc.) + +--- + +## Usage +### Instructions: +1. **Copy the test suite to the target device** using `scp` or any preferred method. +2. **Navigate to the test directory** on the target device. +3. **Run the test script** using the test runner or directly. + +--- + +### Quick Example +```bash +git clone +cd +scp -r common Runner user@target_device_ip: +ssh user@target_device_ip +cd /Runner && ./run-test.sh usb_ssp +``` From c33cfc2655083d8ad2087a5bb0c20ef67fb90931 Mon Sep 17 00:00:00 2001 From: Aanchal Chaurasia Date: Mon, 2 Feb 2026 03:48:33 +0530 Subject: [PATCH 3/3] Add test definition for usb_ssp Individual test definition is meant to be used for debugging the test script running in LAVA. Signed-off-by: Aanchal Chaurasia --- .../suites/Kernel/Baseport/usb_ssp/usb_ssp.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Runner/suites/Kernel/Baseport/usb_ssp/usb_ssp.yaml diff --git a/Runner/suites/Kernel/Baseport/usb_ssp/usb_ssp.yaml b/Runner/suites/Kernel/Baseport/usb_ssp/usb_ssp.yaml new file mode 100644 index 00000000..c99eb613 --- /dev/null +++ b/Runner/suites/Kernel/Baseport/usb_ssp/usb_ssp.yaml @@ -0,0 +1,16 @@ +metadata: + name: usb-ssp + format: "Lava-Test Test Definition 1.0" + description: "This shell script executes on the DUT (Device-Under-Test) and verifies successful enumeration of connected USB Devices in SuperSpeed Plus (SSP)." + os: + - linux + scope: + - functional + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Kernel/Baseport/usb_ssp + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh usb_ssp.res || true +