Skip to content

Commit 4ede4ed

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 4ede4ed

File tree

1 file changed

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

1 file changed

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

0 commit comments

Comments
 (0)