canonical / checkbox

Checkbox is a testing framework used to validate device compatibility with Ubuntu Linux. It’s the testing tool developed for the purposes of the Ubuntu Certification program.
https://checkbox.readthedocs.io
GNU General Public License v3.0
33 stars 50 forks source link

Fix the insertion of USB3 Gen2x1 device could not being detected (Bugfix) #1438

Closed eugene-yujinwu closed 2 months ago

eugene-yujinwu commented 2 months ago

Description

We had a usb3 gen2x1 device which used to the type-c usb3 test. But it failed to be detected by checkbox when plug in. The Bug is: The hotplug of a usb-c disk works well but com.canonical.certification::usb-c/insert test failed #1437

The reason of this issue is that the new run_watcher didn't cover this type of usb3 device.

Resolved issues

We had a usb3 gen2x1 device which used to the type-c usb3 test. But it failed to be detected by checkbox when plug in. The Bug is: The hotplug of a usb-c disk works well but com.canonical.certification::usb-c/insert test failed #1437

The reason of this issue is that the new run_watcher didn't cover this type of usb3 device.

Documentation

Tests

Run the usb3-typec insert test: ==============[ Running job 3 / 3. Estimated time left: 0:00:30 ]=============== --------[ USB 3.0 storage device insertion detected on USB Type-C port ]-------- ID: com.canonical.certification::usb-c/insert Category: com.canonical.plainbox::usb Purpose:

This test will check that the system correctly detects the insertion of a USB 3.0 storage device in a USB Type-C connector. NOTE: Make sure the USB storage device has a partition before starting the test.

Steps:

  1. Commence the test.
  2. Connect a USB 3.0 storage device to a USB Type-C port.
  3. Do not unplug the device after the test.

Pick an action => press ENTER to continue c => add a comment s => skip this job q => save the session and quit [csq]: ... 8< -------------------------------------------------------------------------

INSERT NOW

Timeout: 30 seconds super_speed_plus_gen2x1_usb was inserted. Controller: xhci_hcd, Number: 54 usable partition: sda1 USB3 insertion test passed. cache file usb_insert_info is at: /var/tmp/checkbox-ng/sessions/checkbox-run-2024-08-29T03.21.05.session/session-share ------------------------------------------------------------------------- >8 --- Outcome: job passed Finalizing session that hasn't been submitted anywhere: checkbox-run-2024-08-29T03.21.05 ==================================[ Results ]=================================== ☑ : Collect information about supported types of USB ☑ : Hardware Manifest ☑ : USB 3.0 storage device insertion detected on USB Type-C port

Run the usb3 insert test with usb3 gen1 disk insert: ==============[ Running job 2 / 2. Estimated time left: 0:02:00 ]=============== -----------------[ USB 3.0 storage device insertion detected ]------------------ ID: com.canonical.certification::usb3/insert Category: com.canonical.plainbox::usb Purpose:

Check system can detect insertion of a USB 3.0 storage device. NOTE: Make sure the USB storage device has a partition before starting the test.

Steps:

  1. Press continue.
  2. Wait until the message "INSERT NOW" is displayed on the screen.
  3. Connect USB 3.0 storage device.

Pick an action => press ENTER to continue c => add a comment s => skip this job q => save the session and quit [csq]: ... 8< -------------------------------------------------------------------------

INSERT NOW

Timeout: 30 seconds super_speed_usb was inserted. Controller: xhci_hcd, Number: 53 usable partition: sda2 USB3 insertion test passed. cache file usb_insert_info is at: /var/tmp/checkbox-ng/sessions/checkbox-run-2024-08-29T02.49.03.session/session-share ------------------------------------------------------------------------- >8 --- Outcome: job passed Finalizing session that hasn't been submitted anywhere: checkbox-run-2024-08-29T02.49.03 ==================================[ Results ]=================================== ☑ : Collect information about supported types of USB ☑ : USB 3.0 storage device insertion detected

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 45.72%. Comparing base (d725523) to head (5a6aab7). Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ox-support/checkbox_support/scripts/run_watcher.py 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1438 +/- ## ========================================== - Coverage 45.72% 45.72% -0.01% ========================================== Files 367 367 Lines 39134 39134 Branches 6618 6618 ========================================== - Hits 17895 17894 -1 Misses 20565 20565 - Partials 674 675 +1 ``` | [Flag](https://app.codecov.io/gh/canonical/checkbox/pull/1438/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical) | Coverage Δ | | |---|---|---| | [checkbox-support](https://app.codecov.io/gh/canonical/checkbox/pull/1438/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical) | `59.69% <0.00%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

eugene-yujinwu commented 2 months ago

@pieqq , thank you for your quick review.

fernando79513 commented 2 months ago

Taking a look at this issue I saw that there is an error in the "insertion" condition. Explanation The line:

python Copy code if "USB Mass Storage device detected" or "uas" in line_str: does not work as intended because of the way Python evaluates conditional expressions. Here's what's happening step by step:

Expression Evaluation Order:

Python evaluates "USB Mass Storage device detected" first. Since non-empty strings are considered True in a boolean context, "USB Mass Storage device detected" evaluates to True. Therefore, the entire expression before the or operator is True.