Skip to content

Commit bf5e14a

Browse files
committed
Add test script to validate USB Host mode
The shell script verifies the enumeration of USB devices connected to DUT for testing USB Host mode functionality. Signed-off-by: Aanchal Chaurasia <[email protected]>
1 parent ec8d3f1 commit bf5e14a

File tree

1 file changed

+39
-0
lines changed
  • Runner/suites/Kernel/FunctionalArea/baseport/USBHost

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
# Import test suite definitions
3+
$(pwd)/init_env
4+
TESTNAME="USBHost"
5+
6+
#import test functions library
7+
. "$(dirname "$0")/../../utils/functestlib.sh"
8+
test_path=$(find_test_case_by_name "$TESTNAME")
9+
log_info "-----------------------------------------------------------------------------------------"
10+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
11+
12+
log_info "Running USB Host enumeration test"
13+
14+
# Check if lsusb is installed
15+
check_dependencies lsusb
16+
17+
# Run lsusb and capture output
18+
usb_output=$(lsusb)
19+
device_count=$(echo "$usb_output" | wc -l)
20+
21+
# Filter out USB hubs
22+
non_hub_count=$(echo "$usb_output" | grep -vi "hub" | wc -l)
23+
24+
echo "Enumerated USB devices..."
25+
echo "$usb_output"
26+
27+
# Check if any USB devices were found
28+
if [ "$device_count" -eq 0 ]; then
29+
    log_fail "$TESTNAME : Test Failed - No USB devices found."
30+
    echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
31+
elif [ "$non_hub_count" -eq 0 ]; then
32+
    log_fail "$TESTNAME : Test Failed - Only USB hubs detected, no functional USB devices."
33+
    echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
34+
else
35+
    log_pass "$TESTNAME : Test Passed - $non_hub_count non-hub USB device(s) found."
36+
    echo "$TESTNAME PASS" > $test_path/$TESTNAME.res
37+
fi
38+
39+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

0 commit comments

Comments
 (0)