Skip to content
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

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

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion checkbox-support/checkbox_support/scripts/run_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def _validate_insertion(self):
elif self.storage_type == "usb3" and self.device in [
"super_speed_usb",
"super_speed_gen1_usb",
"super_speed_plus_gen2x1_usb",
]:
logger.info("USB3 insertion test passed.")
else:
Expand Down Expand Up @@ -226,6 +227,7 @@ def _parse_journal_line(self, line_str):
"high_speed_usb": "new high-speed USB device",
"super_speed_usb": "new SuperSpeed USB device",
"super_speed_gen1_usb": "new SuperSpeed Gen 1 USB device",
"super_speed_plus_gen2x1_usb": "new SuperSpeed Plus Gen 2x1 USB device",
}

driver_log_dict = {
Expand All @@ -247,7 +249,7 @@ def _parse_journal_line(self, line_str):
).group(1)

# Look for insertion action
if "USB Mass Storage device detected" in line_str:
if "USB Mass Storage device detected" or "uas" in line_str:
self.action = "insertion"

# Look for removal action
Expand Down
21 changes: 21 additions & 0 deletions checkbox-support/checkbox_support/tests/test_run_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ def test_usb3_storage_validate_insertion(self):
USBStorage._validate_insertion(mock_usb_storage)
self.assertEqual(cm.exception.code, None)

def test_usb3_gen2x1_storage_validate_insertion(self):
mock_usb_storage = MagicMock()
mock_usb_storage.storage_type = "usb3"
mock_usb_storage.device = "super_speed_plus_gen2x1_usb"
mock_usb_storage.mounted_partition = "mounted_partition"
mock_usb_storage.action = "insertion"
mock_usb_storage.driver = "xhci_hcd"
with self.assertRaises(SystemExit) as cm:
USBStorage._validate_insertion(mock_usb_storage)
self.assertEqual(cm.exception.code, None)

def test_usb_storage_validate_insertion_wrong_usb_type(self):
mock_usb_storage = MagicMock()
mock_usb_storage.storage_type = "usb2"
Expand Down Expand Up @@ -285,6 +296,12 @@ def test_usb_storage_parse_journal_line(self):
USBStorage._parse_journal_line(mock_usb_storage, line_str)
self.assertEqual(mock_usb_storage.device, "super_speed_gen1_usb")

line_str = "new SuperSpeed Plus Gen 2x1 USB device"
USBStorage._parse_journal_line(mock_usb_storage, line_str)
self.assertEqual(
mock_usb_storage.device, "super_speed_plus_gen2x1_usb"
)

line_str = "new high-speed USB device number 1 using ehci_hcd"
USBStorage._parse_journal_line(mock_usb_storage, line_str)
self.assertEqual(mock_usb_storage.driver, "ehci_hcd")
Expand All @@ -297,6 +314,10 @@ def test_usb_storage_parse_journal_line(self):
USBStorage._parse_journal_line(mock_usb_storage, line_str)
self.assertEqual(mock_usb_storage.action, "insertion")

line_str = "kernel: scsi host0: uas"
USBStorage._parse_journal_line(mock_usb_storage, line_str)
self.assertEqual(mock_usb_storage.action, "insertion")

line_str = "USB disconnect, device"
USBStorage._parse_journal_line(mock_usb_storage, line_str)
self.assertEqual(mock_usb_storage.action, "removal")
Expand Down
Loading