-
Notifications
You must be signed in to change notification settings - Fork 26
Add test script to validate USB MSD #265
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
The shell script verifies the enumeration of USB Mass Storage Devices. Signed-off-by: Aanchal Chaurasia <[email protected]>
Added setup information and basic requirements. This informs the tester of the hardware setup requirement before starting test. Signed-off-by: Aanchal Chaurasia <[email protected]>
Individual test definition is meant to be used for debugging the test script running in LAVA. Signed-off-by: Aanchal Chaurasia <[email protected]>
| # Requires at least one USB Mass Storage peripheral (USB flash drive, external HDD/SSD, 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.
let's have repo standard way..
SCRIPT_DIR="$(
cd "$(dirname "$0")" || exit 1
pwd
)"
| else | ||
| log_fail "$TESTNAME : Test Failed - No 'Mass Storage' interface found" | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| exit 1 |
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.
Exit 0 always so LAVA doesn’t stop the job unexpectedly
| 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.
| 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 or move above after PASS/ FAIL decision making.
| log_info "=== USB Mass Storage device Detection ===" | ||
| msd_iface_count="$(cat /sys/bus/usb/devices/*/bInterfaceClass 2>/dev/null | grep -i '08' | wc -l)" | ||
|
|
||
| printf "Number of MSD interfaces found: $msd_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 "Number of HID interfaces found: $msd_iface_count"
| - REPO_PATH=$PWD | ||
| - cd Runner/suites/Kernel/Baseport/usb_msd | ||
| - ./run.sh || true | ||
| - $REPO_PATH/Runner/utils/send-to-lava.sh usb_msd.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.
still uses || true for both run.sh and send-to-lava. Please remove error masking
| # Count interfaces with bInterfaceClass = 08 (MSD) under /sys/bus/usb/devices | ||
| msd_iface_count=0 | ||
| log_info "=== USB Mass Storage device Detection ===" | ||
| msd_iface_count="$(cat /sys/bus/usb/devices/*/bInterfaceClass 2>/dev/null | grep -i '08' | 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.
Counting bInterfaceClass=08 is OK for “device enumerated”, but it does not guarantee
usb-storage driver bound
block device appeared (/dev/sdX)
mountable storage exists
After class detection, verify block device presence via one of:
lsblk -ndo NAME,TRAN | grep -q ' usb' (if lsblk exists)
/sys/block/sd*/device + check it’s USB-backed
/sys/bus/usb/drivers/usb-storage/ entries (driver bound)
Even a best-effort optional check is valuable:
If tools missing → SKIP that sub-check, don’t fail the test.
The shell script verifies the enumeration of USB Mass Storage Devices connected to DUT.