Skip to content

Commit 5ab7e81

Browse files
authored
Merge pull request #33 from achauras-qcom/feature/usbhost
Add test script to validate USB Host mode
2 parents 73a2a03 + fd19823 commit 5ab7e81

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
```
2+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
SPDX-License-Identifier: BSD-3-Clause-Clear
4+
```
5+
6+
# USB Host Mode Validation
7+
8+
## Overview
9+
10+
This shell script executes on the DUT (Device-Under-Test) and verifies enumeration of connected USB devices.
11+
12+
---
13+
14+
## Setup
15+
16+
- Connect USB peripheral(s) to USB port(s) on DUT.
17+
- Only applicable for USB ports that support Host Mode functionality.
18+
- USB peripherals examples: Mass Storage devices (pendrives, SSD, hard drives, etc.), HID devices (Mouse, Keyboard, USB headset, USB camera, etc.)
19+
20+
---
21+
22+
## License
23+
24+
```
25+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
26+
SPDX-License-Identifier: BSD-3-Clause-Clear
27+
```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
#Setup requires at least one USB peripheral connected to USB port that supports Host mode function
7+
8+
# Import test suite definitions
9+
. "${PWD}"/init_env
10+
TESTNAME="USBHost"
11+
12+
#import test functions library
13+
. "${TOOLS}"/functestlib.sh
14+
test_path=$(find_test_case_by_name "$TESTNAME")
15+
log_info "-----------------------------------------------------------------------------------------"
16+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
17+
18+
log_info "Running USB Host enumeration test"
19+
20+
# Check if lsusb is installed
21+
check_dependencies lsusb
22+
23+
# Run lsusb and capture output
24+
usb_output=$(lsusb)
25+
device_count=$(echo "$usb_output" | wc -l)
26+
27+
# Filter out USB hubs
28+
non_hub_count=$(echo "$usb_output" | grep -vi "hub" | wc -l)
29+
30+
echo "Enumerated USB devices..."
31+
echo "$usb_output"
32+
33+
# Check if any USB devices were found
34+
if [ "$device_count" -eq 0 ]; then
35+
    log_fail "$TESTNAME : Test Failed - No USB devices found."
36+
    echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
37+
elif [ "$non_hub_count" -eq 0 ]; then
38+
    log_fail "$TESTNAME : Test Failed - Only USB hubs detected, no functional USB devices."
39+
    echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
40+
else
41+
    log_pass "$TESTNAME : Test Passed - $non_hub_count non-hub USB device(s) found."
42+
    echo "$TESTNAME PASS" > $test_path/$TESTNAME.res
43+
fi
44+
45+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

0 commit comments

Comments
 (0)