-
Notifications
You must be signed in to change notification settings - Fork 26
Add test script to validate USB HID #256
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 HID Validation | ||
|
|
||
| ## Overview | ||
|
|
||
| This shell script executes on the DUT (Device-Under-Test) and verifies enumeration of connected USB Human Interface Devices (HID). | ||
|
|
||
| --- | ||
|
|
||
| ## Setup | ||
|
|
||
| - Connect USB HID peripheral(s) to USB port(s) on DUT. | ||
| - Only applicable for USB ports that support Host Mode functionality. | ||
| - USB HID peripherals examples: Mouse, Keyboard, USB headset, etc. | ||
|
|
||
| --- | ||
|
|
||
| ## License | ||
|
|
||
| ``` | ||
| Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| SPDX-License-Identifier: BSD-3-Clause-Clear | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||
| #!/bin/sh | ||||
|
|
||||
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||||
| # SPDX-License-Identifier: BSD-3-Clause-Clear | ||||
|
|
||||
| # Validate USB HID device detection | ||||
| # Requires at least one USB HID peripheral (keyboard/mouse, etc.) connected to a USB Host port. | ||||
|
|
||||
| # Robustly find and source init_env | ||||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||||
| INIT_ENV="" | ||||
| SEARCH="$SCRIPT_DIR" | ||||
| while [ "$SEARCH" != "/" ]; do | ||||
| if [ -f "$SEARCH/init_env" ]; then | ||||
| INIT_ENV="$SEARCH/init_env" | ||||
| break | ||||
| fi | ||||
| SEARCH=$(dirname "$SEARCH") | ||||
| done | ||||
|
|
||||
| if [ -z "$INIT_ENV" ]; then | ||||
| echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 | ||||
| exit 1 | ||||
| fi | ||||
|
|
||||
| # Only source if not already loaded (idempotent) | ||||
| if [ -z "$__INIT_ENV_LOADED" ]; then | ||||
| # shellcheck disable=SC1090 | ||||
| . "$INIT_ENV" | ||||
| fi | ||||
| # Always source functestlib.sh, using $TOOLS exported by init_env | ||||
| # shellcheck disable=SC1090,SC1091 | ||||
| . "$TOOLS/functestlib.sh" | ||||
|
|
||||
| TESTNAME="usb_hid" | ||||
| test_path=$(find_test_case_by_name "$TESTNAME") | ||||
| cd "$test_path" || exit 1 | ||||
| # shellcheck disable=SC2034 | ||||
| res_file="./$TESTNAME.res" | ||||
|
|
||||
| log_info "-----------------------------------------------------------------------------------------" | ||||
| log_info "-------------------Starting $TESTNAME Testcase----------------------------" | ||||
| log_info "=== Test Initialization ===" | ||||
|
|
||||
| # Check if lsusb is installed | ||||
| check_dependencies lsusb grep | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you skip the test if dependencies are not met. similar to
|
||||
|
|
||||
| log_info "=== USB HID device Detection ===" | ||||
| hid_iface_count="$(lsusb -v 2>/dev/null | grep -i 'Human Interface Device' | wc -l)" | ||||
|
|
||||
| echo "lsusb -v HID descriptors:" | ||||
| lsusb -v 2>/dev/null | grep -i 'Human Interface Device' || true | ||||
|
|
||||
| echo "Number of HID interfaces found: $hid_iface_count" | ||||
|
|
||||
| if [ "$hid_iface_count" -gt 0 ]; then | ||||
| log_pass "$TESTNAME : Test Passed - USB HID interface(s) detected" | ||||
| echo "$TESTNAME PASS" > "$res_file" | ||||
| exit 0 | ||||
| else | ||||
| log_fail "$TESTNAME : Test Failed - No 'Human Interface Device' interface found" | ||||
| echo "$TESTNAME FAIL" > "$res_file" | ||||
| exit 1 | ||||
| fi | ||||
|
|
||||
| log_info "-------------------Completed $TESTNAME Testcase----------------------------" | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| metadata: | ||
| name: usb-hid | ||
| format: "Lava-Test Test Definition 1.0" | ||
| description: "This shell script executes on the DUT (Device-Under-Test) and verifies enumeration of connected USB Human Interface Devices (HID)." | ||
| os: | ||
| - linux | ||
| scope: | ||
| - functional | ||
|
|
||
| run: | ||
| steps: | ||
| - REPO_PATH=$PWD | ||
| - cd Runner/suites/Kernel/Baseport/usb_hid | ||
| - ./run.sh || true | ||
| - $REPO_PATH/Runner/utils/send-to-lava.sh usb_hid.res || true | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the readme with the steps