Skip to content

Add test script to validate USB UVC - #520

Open
achauras-qcom wants to merge 1 commit into
qualcomm-linux:mainfrom
achauras-qcom:feature/usb-uvc
Open

Add test script to validate USB UVC#520
achauras-qcom wants to merge 1 commit into
qualcomm-linux:mainfrom
achauras-qcom:feature/usb-uvc

Conversation

@achauras-qcom

Copy link
Copy Markdown
Contributor

The shell script verifies the enumeration of USB Video Class devices.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

The shell script verifies the enumeration of USB Video Class devices.

Signed-off-by: Aanchal Chaurasia <achauras@qti.qualcomm.com>
log_info "Number of /dev/video* nodes found: ${video_node_count:-0}"

# Pass if the number of /dev/video* nodes is at least the number of detected UVC devices
if [ "${video_node_count:-0}" -ge "$video_device_count" ] 2>/dev/null; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final result compares the total number of unique /dev/video* nodes with the total number of UVC devices. This does not prove that every UVC device has a node. For example, one device exposing two nodes and another exposing none produces 2 >= 2 and incorrectly passes.

Track validation per USB device and fail when any detected device has no associated video node. The sibling usb_msd/run.sh test demonstrates the expected per-device tracking pattern.

for v in "$intf"/video4linux/video*; do
[ -e "$v" ] || continue
node="/dev/$(basename "$v")"
if [ -e "$node" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sysfs may expose video4linux/video* before udev creates the corresponding /dev/video* node. Checking the node only once makes the test race device enumeration and can produce intermittent false failures. Reuse wait_for_path from Runner/utils/functestlib.sh with a bounded timeout, such as wait_for_path "$node" 5, before declaring the node missing.


# Check if dependencies are installed, else skip test
# Include all external utilities used by this script
deps_list="grep sed sort wc tr readlink head awk"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency declaration includes unused head and awk, while the script invokes external basename at line 127 without declaring it. Remove unused dependencies and either declare basename or replace it with shell parameter expansion.

Running this test on a DUT without a connected USB Video peripheral is expected to FAIL with the message: No 'USB Video Device' found.

---

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing whitespaces

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.

3 participants