Skip to content

Conversation

@achauras-qcom
Copy link
Contributor

The shell script verifies the enumeration of USB Human Interface Devices connected to DUT.

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]>
# 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)"
Copy link
Contributor

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
Copy link
Contributor

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)"
Copy link
Contributor

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"
Copy link
Contributor

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----------------------------"
Copy link
Contributor

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 @@
```
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants