Skip to contentSkip to conversation

tests/qtest/usb-hcd-xhci-test: Check availability of devices before using them

PATCH In review Thomas Huth 2 participants 2 messages Aug 22, 2023 – Aug 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/qtest/usb-hcd-xhci-test: Check availability of devices before using them

The "usb-uas" and "usb-ccid" might not be compiled into the QEMU binary, so let's better check first whether they are available.

---
 tests/qtest/usb-hcd-xhci-test.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/qtest/usb-hcd-xhci-test.c +6 -2
index 10ef9d2a91..80bc039446 100644
@@ -56,8 +56,12 @@ int main(int argc, char **argv)
 
     qtest_add_func("/xhci/pci/init", test_xhci_init);
     qtest_add_func("/xhci/pci/hotplug", test_xhci_hotplug);
-    qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
-    qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug);
+    if (qtest_has_device("usb-uas")) {
+        qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug);
+    }
+    if (qtest_has_device("usb-ccid")) {
+        qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug);
+    }
 
     qtest_start("-device nec-usb-xhci,id=xhci"
                 " -drive id=drive0,if=none,file=null-co://,"
Signature · 1 line
2.39.3