Skip to content

Add test script to validate USB Host mode #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Runner/suites/Kernel/FunctionalArea/baseport/USBHost/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
```
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear
```

# USB Host Mode Validation

## Overview

This shell script executes on the DUT (Device-Under-Test) and verifies enumeration of connected USB devices.

---

## 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.)

---

## License

```
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear
```
45 changes: 45 additions & 0 deletions Runner/suites/Kernel/FunctionalArea/baseport/USBHost/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

#Setup requires at least one USB peripheral connected to USB port that supports Host mode function

# Import test suite definitions
. "${PWD}"/init_env
TESTNAME="USBHost"

#import test functions library
. "${TOOLS}"/functestlib.sh
test_path=$(find_test_case_by_name "$TESTNAME")
log_info "-----------------------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"

log_info "Running USB Host enumeration test"

# Check if lsusb is installed
check_dependencies lsusb

# Run lsusb and capture output
usb_output=$(lsusb)
device_count=$(echo "$usb_output" | wc -l)

# Filter out USB hubs
non_hub_count=$(echo "$usb_output" | grep -vi "hub" | wc -l)

echo "Enumerated USB devices..."
echo "$usb_output"

# Check if any USB devices were found
if [ "$device_count" -eq 0 ]; then
    log_fail "$TESTNAME : Test Failed - No USB devices found."
    echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
elif [ "$non_hub_count" -eq 0 ]; then
    log_fail "$TESTNAME : Test Failed - Only USB hubs detected, no functional USB devices."
    echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
else
    log_pass "$TESTNAME : Test Passed - $non_hub_count non-hub USB device(s) found."
    echo "$TESTNAME PASS" > $test_path/$TESTNAME.res
fi

log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Loading