Skip to content

Commit 2a87401

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 2a87401

File tree

1 file changed

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

1 file changed

+45
-0
lines changed
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)