-
Notifications
You must be signed in to change notification settings - Fork 27
Add test script to validate USB HID #259
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
base: main
Are you sure you want to change the base?
Conversation
b6c8c6e to
9ae698c
Compare
The shell script verifies the enumeration of USB Human Interface Devices. Signed-off-by: “Aanchal <[email protected]>
Added setup information and basic requirements. This informs the tester of the hardware setup requirement before starting test. Signed-off-by: “Aanchal <[email protected]>
Individual test definition is meant to be used for debugging the test script running in LAVA. Signed-off-by: “Aanchal <[email protected]>
9ae698c to
030a8d7
Compare
| # 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)" |
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.
Can this we replace a below to maintain parity with other scripts
SCRIPT_DIR="$( cd "$(dirname "$0")" || exit 1 pwd )"
| fi | ||
|
|
||
| # Only source if not already loaded (idempotent) | ||
| if [ -z "$__INIT_ENV_LOADED" ]; then |
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.
Should be ${__INIT_ENV_LOADED:-} to avoid unbound surprises.
| # Count interfaces with bInterfaceClass = 03 (HID) under /sys/bus/usb/devices | ||
| hid_iface_count=0 | ||
| log_info "=== USB HID device Detection ===" | ||
| hid_iface_count="$(cat /sys/bus/usb/devices/*/bInterfaceClass 2>/dev/null | grep -i '03' | wc -l)" |
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.
HID counting logic too loose.
- grep -i '03' matches any line containing 03 (rare but sloppy).
- cat | grep | wc pipeline can leave whitespace in wc output.
- Better: match exactly 03.
hid_iface_count="$(grep -h -x '03' /sys/bus/usb/devices/*/bInterfaceClass 2>/dev/null | wc -l | awk '{print $1}')"
| log_info "=== USB HID device Detection ===" | ||
| hid_iface_count="$(cat /sys/bus/usb/devices/*/bInterfaceClass 2>/dev/null | grep -i '03' | wc -l)" | ||
|
|
||
| printf "Number of HID interfaces found: $hid_iface_count" |
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.
use log_info
log_info "Number of HID interfaces found: $hid_iface_count"
| exit 1 | ||
| fi | ||
|
|
||
| log_info "-------------------Completed $TESTNAME Testcase----------------------------" |
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.
Remove it or move it before the final decision
| @@ -0,0 +1,37 @@ | |||
| ``` | |||
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.
SPDX header shouldn’t be in a fenced code block, our usual pattern is plain text at top (or as comments).
| @@ -0,0 +1,16 @@ | |||
| metadata: | |||
| name: usb-hid | |||
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.
usb-hid vs test folder/testname usb_hid. Prefer consistent naming.
| - 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 |
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.
we can remove || true from this setup
The shell script verifies the enumeration of USB Human Interface Devices connected to DUT.