Skip to content

Conversation

@achauras-qcom
Copy link
Contributor

The shell script verifies the enumeration of USB Mass Storage Devices connected to DUT.

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

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

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
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.

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

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

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.

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