[PATCH 1/4] tests/qtest/usb-hcd-uhci-test: Check whether "usb-storage" is available

Thomas Huth posted 4 patches 2 years, 6 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, John Snow <jsnow@redhat.com>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
[PATCH 1/4] tests/qtest/usb-hcd-uhci-test: Check whether "usb-storage" is available
Posted by Thomas Huth 2 years, 6 months ago
The "usb-storage" device might not have been compiled into the binary
(e.g. when compiling with "--without-default-devices"), so we have to
check first before using it.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/usb-hcd-uhci-test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/usb-hcd-uhci-test.c b/tests/qtest/usb-hcd-uhci-test.c
index 84ac2f3c1a..28751f53da 100644
--- a/tests/qtest/usb-hcd-uhci-test.c
+++ b/tests/qtest/usb-hcd-uhci-test.c
@@ -74,7 +74,9 @@ int main(int argc, char **argv)
     qtest_add_func("/uhci/pci/init", test_uhci_init);
     qtest_add_func("/uhci/pci/port1", test_port_1);
     qtest_add_func("/uhci/pci/hotplug", test_uhci_hotplug);
-    qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hotplug);
+    if (qtest_has_device("usb-storage")) {
+        qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hotplug);
+    }
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         qs = qtest_pc_boot("%s", cmd);
-- 
2.31.1
Re: [PATCH 1/4] tests/qtest/usb-hcd-uhci-test: Check whether "usb-storage" is available
Posted by Ani Sinha 2 years, 6 months ago

> On 25-May-2023, at 1:40 PM, Thomas Huth <thuth@redhat.com> wrote:
> 
> The "usb-storage" device might not have been compiled into the binary
> (e.g. when compiling with "--without-default-devices"), so we have to
> check first before using it.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Ani Sinha <anisinha@redhat.com>

> ---
> tests/qtest/usb-hcd-uhci-test.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/usb-hcd-uhci-test.c b/tests/qtest/usb-hcd-uhci-test.c
> index 84ac2f3c1a..28751f53da 100644
> --- a/tests/qtest/usb-hcd-uhci-test.c
> +++ b/tests/qtest/usb-hcd-uhci-test.c
> @@ -74,7 +74,9 @@ int main(int argc, char **argv)
>     qtest_add_func("/uhci/pci/init", test_uhci_init);
>     qtest_add_func("/uhci/pci/port1", test_port_1);
>     qtest_add_func("/uhci/pci/hotplug", test_uhci_hotplug);
> -    qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hotplug);
> +    if (qtest_has_device("usb-storage")) {
> +        qtest_add_func("/uhci/pci/hotplug/usb-storage", test_usb_storage_hotplug);
> +    }
> 
>     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
>         qs = qtest_pc_boot("%s", cmd);
> -- 
> 2.31.1
>