All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/12] qtests vs. default devices
@ 2023-02-13 21:07 Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 01/12] tests/qtest: Skip PXE tests for missing devices Fabiano Rosas
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

I based this on master this time, the Kconfig series might take
longer.

patch 4 - changed conditional to use the same style as surrounding
          code;

v2:

patch 3 - fixed typo s/PCIE_ROOT/PCIE_PORT and dropped runtime check;

patch 4 - dropped runtime check and added a dep on CONFIG_VIRTIO_SERIAL;

patch 7 - added skip messages and folded look_for_device_builtin into
          has_device_builtin;

patch 9 - dropped runtime check;

v1:
https://lore.kernel.org/r/20230206150416.4604-1-farosas@suse.de

Most of our tests assume the presence of default devices. When
building --without-default-devices or with individual CONFIGs
disabled, several tests fail.

I went through them one by one and did local changes to skip or avoid
including tests that require devices that are missing. With these
initial changes, 'make check' now passes for the
--without-default-devices build for x86 and arm.

However, the approach of making local changes seems hard to maintain:
every time a CONFIG changes from 'y' to 'n' a test might break and all
new tests need to remember to check before adding devices, which some
tests add several.

So the last patch in the series provides an alternative: Parse the
command line at qtest_init and skip the test if devices are
missing. Individual tests would have to check 'if (!qts)' and
bail. Seems a bit heavy-weight, but it would mean we don't have to put
a qtest_has_device check for every device in every test.

Based on: <20230206140809.26028-1-farosas@suse.de>
[PATCH 00/10] Kconfig vs. default devices
https://lore.kernel.org/r/20230206140809.26028-1-farosas@suse.de

Fabiano Rosas (12):
  tests/qtest: Skip PXE tests for missing devices
  tests/qtest: Do not run lsi53c895a test if device is not present
  tests/qtest: Add dependence on PCIE_PORT for virtio-net-failover.c
  tests/qtest: Don't build virtio-serial-test.c if device not present
  tests/qtest: hd-geo-test: Check for missing devices
  tests/qtest: Fix coding style in device-plug-test.c
  tests/qtest: Skip unplug tests that use missing devices
  tests/qtest: drive_del-test: Skip tests that require missing devices
  tests/qtest: Check for devices in bios-tables-test
  tests/qtest: Do not include hexloader-test if loader device is not
    present
  tests/qemu-iotests: Require virtio-scsi-pci
  tests/qtest: bios-tables-test: Skip if missing configs

 tests/qemu-iotests/186             |  1 +
 tests/qtest/bios-tables-test.c     | 75 ++++++++++++++++++++++++++++--
 tests/qtest/device-plug-test.c     | 41 ++++++++++++----
 tests/qtest/drive_del-test.c       | 65 ++++++++++++++++++++++++++
 tests/qtest/fuzz-lsi53c895a-test.c |  4 ++
 tests/qtest/hd-geo-test.c          | 38 +++++++++------
 tests/qtest/meson.build            | 17 +++++--
 tests/qtest/pxe-test.c             |  4 ++
 8 files changed, 214 insertions(+), 31 deletions(-)

-- 
2.35.3



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3 01/12] tests/qtest: Skip PXE tests for missing devices
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 02/12] tests/qtest: Do not run lsi53c895a test if device is not present Fabiano Rosas
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

Check if the devices we're trying to add are present in the QEMU
binary. They could have been removed from the build via Kconfig or the
--without-default-devices option.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/pxe-test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/qtest/pxe-test.c b/tests/qtest/pxe-test.c
index 52f0b5c67c..62b6eef464 100644
--- a/tests/qtest/pxe-test.c
+++ b/tests/qtest/pxe-test.c
@@ -108,6 +108,10 @@ static void test_batch(const testdef_t *tests, bool ipv6)
         const testdef_t *test = &tests[i];
         char *testname;
 
+        if (!qtest_has_device(test->model)) {
+            continue;
+        }
+
         testname = g_strdup_printf("pxe/ipv4/%s/%s",
                                    test->machine, test->model);
         qtest_add_data_func(testname, test, test_pxe_ipv4);
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 02/12] tests/qtest: Do not run lsi53c895a test if device is not present
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 01/12] tests/qtest: Skip PXE tests for missing devices Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 03/12] tests/qtest: Add dependence on PCIE_PORT for virtio-net-failover.c Fabiano Rosas
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Alexander Bulekov, Paolo Bonzini, Bandan Das,
	Stefan Hajnoczi, Darren Kenny, Qiuhao Li, Fam Zheng,
	Laurent Vivier

The tests are built once for all the targets, so as long as one QEMU
binary is built with CONFIG_LSI_SCSI_PCI=y, this test will
run. However some binaries might not include the device. So check this
again in runtime.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/fuzz-lsi53c895a-test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/qtest/fuzz-lsi53c895a-test.c b/tests/qtest/fuzz-lsi53c895a-test.c
index 392a7ae7ed..a9254b455d 100644
--- a/tests/qtest/fuzz-lsi53c895a-test.c
+++ b/tests/qtest/fuzz-lsi53c895a-test.c
@@ -112,6 +112,10 @@ static void test_lsi_do_dma_empty_queue(void)
 
 int main(int argc, char **argv)
 {
+    if (!qtest_has_device("lsi53c895a")) {
+        return 0;
+    }
+
     g_test_init(&argc, &argv, NULL);
 
     qtest_add_func("fuzz/lsi53c895a/lsi_do_dma_empty_queue",
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 03/12] tests/qtest: Add dependence on PCIE_PORT for virtio-net-failover.c
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 01/12] tests/qtest: Skip PXE tests for missing devices Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 02/12] tests/qtest: Do not run lsi53c895a test if device is not present Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 04/12] tests/qtest: Don't build virtio-serial-test.c if device not present Fabiano Rosas
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

This test depends on the presence of the pcie-root-port device. Add a
build time dependency.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index e97616d327..5c8b031ce0 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -73,7 +73,8 @@ qtests_i386 = \
   (config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] : []) +                 \
   (config_host.has_key('CONFIG_POSIX') and                                                  \
    config_all_devices.has_key('CONFIG_ACPI_ERST') ? ['erst-test'] : []) +                   \
-  (config_all_devices.has_key('CONFIG_VIRTIO_NET') and                                      \
+  (config_all_devices.has_key('CONFIG_PCIE_PORT') and                                       \
+   config_all_devices.has_key('CONFIG_VIRTIO_NET') and                                      \
    config_all_devices.has_key('CONFIG_Q35') and                                             \
    config_all_devices.has_key('CONFIG_VIRTIO_PCI') and                                      \
    slirp.found() ? ['virtio-net-failover'] : []) +                                          \
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 04/12] tests/qtest: Don't build virtio-serial-test.c if device not present
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (2 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 03/12] tests/qtest: Add dependence on PCIE_PORT for virtio-net-failover.c Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-14  7:57   ` Thomas Huth
  2023-02-13 21:07 ` [PATCH v3 05/12] tests/qtest: hd-geo-test: Check for missing devices Fabiano Rosas
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

The virtconsole device might not be present in the QEMU build that is
being tested.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qtest/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 5c8b031ce0..84cd07bbb9 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -255,10 +255,14 @@ qos_test_ss.add(
   'virtio-net-test.c',
   'virtio-rng-test.c',
   'virtio-scsi-test.c',
-  'virtio-serial-test.c',
   'virtio-iommu-test.c',
   'vmxnet3-test.c',
 )
+
+if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL')
+  qos_test_ss.add(files('virtio-serial-test.c'))
+endif
+
 if config_host.has_key('CONFIG_POSIX')
   qos_test_ss.add(files('e1000e-test.c'))
 endif
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 05/12] tests/qtest: hd-geo-test: Check for missing devices
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (3 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 04/12] tests/qtest: Don't build virtio-serial-test.c if device not present Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 06/12] tests/qtest: Fix coding style in device-plug-test.c Fabiano Rosas
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

Don't include tests that require devices not available in the QEMU
binary.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/hd-geo-test.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
index 4a7628077b..5aa258a2b3 100644
--- a/tests/qtest/hd-geo-test.c
+++ b/tests/qtest/hd-geo-test.c
@@ -1090,30 +1090,42 @@ int main(int argc, char **argv)
         qtest_add_func("hd-geo/override/ide", test_override_ide);
         if (qtest_has_device("lsi53c895a")) {
             qtest_add_func("hd-geo/override/scsi", test_override_scsi);
-            qtest_add_func("hd-geo/override/scsi_2_controllers",
-                           test_override_scsi_2_controllers);
+            if (qtest_has_device("virtio-scsi-pci")) {
+                qtest_add_func("hd-geo/override/scsi_2_controllers",
+                               test_override_scsi_2_controllers);
+            }
         }
-        qtest_add_func("hd-geo/override/virtio_blk", test_override_virtio_blk);
         qtest_add_func("hd-geo/override/zero_chs", test_override_zero_chs);
-        qtest_add_func("hd-geo/override/scsi_hot_unplug",
-                       test_override_scsi_hot_unplug);
-        qtest_add_func("hd-geo/override/virtio_hot_unplug",
-                       test_override_virtio_hot_unplug);
+        if (qtest_has_device("virtio-scsi-pci")) {
+            qtest_add_func("hd-geo/override/scsi_hot_unplug",
+                           test_override_scsi_hot_unplug);
+        }
+        if (qtest_has_device("virtio-blk-pci")) {
+            qtest_add_func("hd-geo/override/virtio_hot_unplug",
+                           test_override_virtio_hot_unplug);
+            qtest_add_func("hd-geo/override/virtio_blk",
+                           test_override_virtio_blk);
+        }
 
         if (qtest_has_machine("q35")) {
             qtest_add_func("hd-geo/override/sata", test_override_sata);
-            qtest_add_func("hd-geo/override/virtio_blk_q35",
-                           test_override_virtio_blk_q35);
             qtest_add_func("hd-geo/override/zero_chs_q35",
                            test_override_zero_chs_q35);
             if (qtest_has_device("lsi53c895a")) {
                 qtest_add_func("hd-geo/override/scsi_q35",
                                test_override_scsi_q35);
             }
-            qtest_add_func("hd-geo/override/scsi_hot_unplug_q35",
-                           test_override_scsi_hot_unplug_q35);
-            qtest_add_func("hd-geo/override/virtio_hot_unplug_q35",
-                           test_override_virtio_hot_unplug_q35);
+            if (qtest_has_device("virtio-scsi-pci")) {
+                qtest_add_func("hd-geo/override/scsi_hot_unplug_q35",
+                               test_override_scsi_hot_unplug_q35);
+            }
+            if (qtest_has_device("virtio-blk-pci")) {
+                qtest_add_func("hd-geo/override/virtio_hot_unplug_q35",
+                               test_override_virtio_hot_unplug_q35);
+                qtest_add_func("hd-geo/override/virtio_blk_q35",
+                               test_override_virtio_blk_q35);
+            }
+
         }
     } else {
         g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; "
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 06/12] tests/qtest: Fix coding style in device-plug-test.c
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (4 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 05/12] tests/qtest: hd-geo-test: Check for missing devices Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 07/12] tests/qtest: Skip unplug tests that use missing devices Fabiano Rosas
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

We should not mix declarations and statements in QEMU code.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/device-plug-test.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index 5a6afa2b57..4f92617335 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -64,6 +64,7 @@ static void process_device_remove(QTestState *qtest, const char *id)
 
 static void test_pci_unplug_request(void)
 {
+    QTestState *qtest;
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
@@ -71,8 +72,8 @@ static void test_pci_unplug_request(void)
         machine_addition = "-machine pc";
     }
 
-    QTestState *qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
-                                    machine_addition);
+    qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
+                        machine_addition);
 
     process_device_remove(qtest, "dev0");
 
@@ -94,6 +95,7 @@ static void test_q35_pci_unplug_request(void)
 
 static void test_pci_unplug_json_request(void)
 {
+    QTestState *qtest;
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
@@ -101,7 +103,7 @@ static void test_pci_unplug_json_request(void)
         machine_addition = "-machine pc";
     }
 
-    QTestState *qtest = qtest_initf(
+    qtest = qtest_initf(
         "%s -device \"{'driver': 'virtio-mouse-pci', 'id': 'dev0'}\"",
         machine_addition);
 
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 07/12] tests/qtest: Skip unplug tests that use missing devices
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (5 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 06/12] tests/qtest: Fix coding style in device-plug-test.c Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 08/12] tests/qtest: drive_del-test: Skip tests that require " Fabiano Rosas
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/device-plug-test.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index 4f92617335..01cecd6e20 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -68,6 +68,11 @@ static void test_pci_unplug_request(void)
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
+    if (!qtest_has_device("virtio-mouse-pci")) {
+        g_test_skip("Device virtio-mouse-pci not available");
+        return;
+    }
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         machine_addition = "-machine pc";
     }
@@ -82,11 +87,17 @@ static void test_pci_unplug_request(void)
 
 static void test_q35_pci_unplug_request(void)
 {
+    QTestState *qtest;
+
+    if (!qtest_has_device("virtio-mouse-pci")) {
+        g_test_skip("Device virtio-mouse-pci not available");
+        return;
+    }
 
-    QTestState *qtest = qtest_initf("-machine q35 "
-                                    "-device pcie-root-port,id=p1 "
-                                    "-device pcie-pci-bridge,bus=p1,id=b1 "
-                                    "-device virtio-mouse-pci,bus=b1,id=dev0");
+    qtest = qtest_initf("-machine q35 "
+                        "-device pcie-root-port,id=p1 "
+                        "-device pcie-pci-bridge,bus=p1,id=b1 "
+                        "-device virtio-mouse-pci,bus=b1,id=dev0");
 
     process_device_remove(qtest, "dev0");
 
@@ -99,6 +110,11 @@ static void test_pci_unplug_json_request(void)
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
+    if (!qtest_has_device("virtio-mouse-pci")) {
+        g_test_skip("Device virtio-mouse-pci not available");
+        return;
+    }
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         machine_addition = "-machine pc";
     }
@@ -114,6 +130,7 @@ static void test_pci_unplug_json_request(void)
 
 static void test_q35_pci_unplug_json_request(void)
 {
+    QTestState *qtest;
     const char *port = "-device \"{'driver': 'pcie-root-port', "
                                   "'id': 'p1'}\"";
 
@@ -125,8 +142,12 @@ static void test_q35_pci_unplug_json_request(void)
                                     "'bus': 'b1', "
                                     "'id': 'dev0'}\"";
 
-    QTestState *qtest = qtest_initf("-machine q35 %s %s %s",
-                                    port, bridge, device);
+    if (!qtest_has_device("virtio-mouse-pci")) {
+        g_test_skip("Device virtio-mouse-pci not available");
+        return;
+    }
+
+    qtest = qtest_initf("-machine q35 %s %s %s", port, bridge, device);
 
     process_device_remove(qtest, "dev0");
 
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 08/12] tests/qtest: drive_del-test: Skip tests that require missing devices
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (6 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 07/12] tests/qtest: Skip unplug tests that use missing devices Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 09/12] tests/qtest: Check for devices in bios-tables-test Fabiano Rosas
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/drive_del-test.c | 65 ++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 9a750395a9..8a6f3ac963 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -16,6 +16,8 @@
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qlist.h"
 
+static const char *qvirtio_get_dev_type(void);
+
 static bool look_for_drive0(QTestState *qts, const char *command, const char *key)
 {
     QDict *response;
@@ -40,6 +42,19 @@ static bool look_for_drive0(QTestState *qts, const char *command, const char *ke
     return found;
 }
 
+/*
+ * This covers the possible absence of a device due to QEMU build
+ * options.
+ */
+static bool has_device_builtin(const char *dev)
+{
+    gchar *device = g_strdup_printf("%s-%s", dev, qvirtio_get_dev_type());
+    bool rc = qtest_has_device(device);
+
+    g_free(device);
+    return rc;
+}
+
 static bool has_drive(QTestState *qts)
 {
     return look_for_drive0(qts, "query-block", "device");
@@ -208,6 +223,11 @@ static void test_drive_del_device_del(void)
 {
     QTestState *qts;
 
+    if (!has_device_builtin("virtio-scsi")) {
+        g_test_skip("Device virtio-scsi is not available");
+        return;
+    }
+
     /* Start with a drive used by a device that unplugs instantaneously */
     qts = qtest_initf("-drive if=none,id=drive0,file=null-co://,"
                       "file.read-zeroes=on,format=raw"
@@ -232,6 +252,11 @@ static void test_cli_device_del(void)
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         machine_addition = "-machine pc";
     }
@@ -256,6 +281,11 @@ static void test_cli_device_del_q35(void)
 {
     QTestState *qts;
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     /*
      * -drive/-device and device_del.  Start with a drive used by a
      * device that unplugs after reset.
@@ -277,6 +307,11 @@ static void test_empty_device_del(void)
 {
     QTestState *qts;
 
+    if (!has_device_builtin("virtio-scsi")) {
+        g_test_skip("Device virtio-scsi is not available");
+        return;
+    }
+
     /* device_del with no drive plugged.  */
     qts = qtest_initf("-device virtio-scsi-%s -device scsi-cd,id=dev0",
                       qvirtio_get_dev_type());
@@ -291,6 +326,11 @@ static void test_device_add_and_del(void)
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         machine_addition = "-machine pc";
     }
@@ -330,6 +370,11 @@ static void test_device_add_and_del_q35(void)
 {
     QTestState *qts;
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     /*
      * -drive/device_add and device_del.  Start with a drive used by a
      * device that unplugs after reset.
@@ -352,6 +397,11 @@ static void test_drive_add_device_add_and_del(void)
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         machine_addition = "-machine pc";
     }
@@ -374,6 +424,11 @@ static void test_drive_add_device_add_and_del_q35(void)
 {
     QTestState *qts;
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
                      "-device pcie-pci-bridge,bus=p1,id=b1");
 
@@ -395,6 +450,11 @@ static void test_blockdev_add_device_add_and_del(void)
     const char *arch = qtest_get_arch();
     const char *machine_addition = "";
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
         machine_addition = "-machine pc";
     }
@@ -417,6 +477,11 @@ static void test_blockdev_add_device_add_and_del_q35(void)
 {
     QTestState *qts;
 
+    if (!has_device_builtin("virtio-blk")) {
+        g_test_skip("Device virtio-blk is not available");
+        return;
+    }
+
     qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
                      "-device pcie-pci-bridge,bus=p1,id=b1");
 
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 09/12] tests/qtest: Check for devices in bios-tables-test
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (7 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 08/12] tests/qtest: drive_del-test: Skip tests that require " Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 10/12] tests/qtest: Do not include hexloader-test if loader device is not present Fabiano Rosas
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Michael S. Tsirkin, Igor Mammedov, Ani Sinha

Do not include tests that require devices that are not available in
the QEMU build.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
---
 tests/qtest/bios-tables-test.c | 75 ++++++++++++++++++++++++++++++++--
 1 file changed, 71 insertions(+), 4 deletions(-)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index d8c8cda58e..d29a4e47af 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -1008,6 +1008,12 @@ static void test_acpi_q35_multif_bridge(void)
         .machine = MACHINE_Q35,
         .variant = ".multi-bridge",
     };
+
+    if (!qtest_has_device("pcie-root-port")) {
+        g_test_skip("Device pcie-root-port is not available");
+        goto out;
+    }
+
     test_vm_prepare("-S"
         " -device virtio-balloon,id=balloon0,addr=0x4.0x2"
         " -device pcie-root-port,id=rp0,multifunction=on,"
@@ -1043,6 +1049,7 @@ static void test_acpi_q35_multif_bridge(void)
     /* check that reboot/reset doesn't change any ACPI tables  */
     qtest_qmp_send(data.qts, "{'execute':'system_reset' }");
     process_acpi_tables(&data);
+out:
     free_test_data(&data);
 }
 
@@ -1396,6 +1403,11 @@ static void test_acpi_tcg_dimm_pxm(const char *machine)
 {
     test_data data;
 
+    if (!qtest_has_device("nvdimm")) {
+        g_test_skip("Device nvdimm is not available");
+        return;
+    }
+
     memset(&data, 0, sizeof(data));
     data.machine = machine;
     data.variant = ".dimmpxm";
@@ -1444,6 +1456,11 @@ static void test_acpi_virt_tcg_memhp(void)
         .scan_len = 256ULL * 1024 * 1024,
     };
 
+    if (!qtest_has_device("nvdimm")) {
+        g_test_skip("Device nvdimm is not available");
+        goto out;
+    }
+
     data.variant = ".memhp";
     test_acpi_one(" -machine nvdimm=on"
                   " -cpu cortex-a57"
@@ -1457,7 +1474,7 @@ static void test_acpi_virt_tcg_memhp(void)
                   " -device pc-dimm,id=dimm0,memdev=ram2,node=0"
                   " -device nvdimm,id=dimm1,memdev=nvm0,node=1",
                   &data);
-
+out:
     free_test_data(&data);
 
 }
@@ -1475,6 +1492,11 @@ static void test_acpi_microvm_tcg(void)
 {
     test_data data;
 
+    if (!qtest_has_device("virtio-blk-device")) {
+        g_test_skip("Device virtio-blk-device is not available");
+        return;
+    }
+
     test_acpi_microvm_prepare(&data);
     test_acpi_one(" -machine microvm,acpi=on,ioapic2=off,rtc=off",
                   &data);
@@ -1485,6 +1507,11 @@ static void test_acpi_microvm_usb_tcg(void)
 {
     test_data data;
 
+    if (!qtest_has_device("virtio-blk-device")) {
+        g_test_skip("Device virtio-blk-device is not available");
+        return;
+    }
+
     test_acpi_microvm_prepare(&data);
     data.variant = ".usb";
     test_acpi_one(" -machine microvm,acpi=on,ioapic2=off,usb=on,rtc=off",
@@ -1496,6 +1523,11 @@ static void test_acpi_microvm_rtc_tcg(void)
 {
     test_data data;
 
+    if (!qtest_has_device("virtio-blk-device")) {
+        g_test_skip("Device virtio-blk-device is not available");
+        return;
+    }
+
     test_acpi_microvm_prepare(&data);
     data.variant = ".rtc";
     test_acpi_one(" -machine microvm,acpi=on,ioapic2=off,rtc=on",
@@ -1507,6 +1539,11 @@ static void test_acpi_microvm_pcie_tcg(void)
 {
     test_data data;
 
+    if (!qtest_has_device("virtio-blk-device")) {
+        g_test_skip("Device virtio-blk-device is not available");
+        return;
+    }
+
     test_acpi_microvm_prepare(&data);
     data.variant = ".pcie";
     data.tcg_only = true; /* need constant host-phys-bits */
@@ -1519,6 +1556,11 @@ static void test_acpi_microvm_ioapic2_tcg(void)
 {
     test_data data;
 
+    if (!qtest_has_device("virtio-blk-device")) {
+        g_test_skip("Device virtio-blk-device is not available");
+        return;
+    }
+
     test_acpi_microvm_prepare(&data);
     data.variant = ".ioapic2";
     test_acpi_one(" -machine microvm,acpi=on,ioapic2=on,rtc=off",
@@ -1558,6 +1600,12 @@ static void test_acpi_virt_tcg_pxb(void)
         .ram_start = 0x40000000ULL,
         .scan_len = 128ULL * 1024 * 1024,
     };
+
+    if (!qtest_has_device("pcie-root-port")) {
+        g_test_skip("Device pcie-root-port is not available");
+        goto out;
+    }
+
     /*
      * While using -cdrom, the cdrom would auto plugged into pxb-pcie,
      * the reason is the bus of pxb-pcie is also root bus, it would lead
@@ -1576,7 +1624,7 @@ static void test_acpi_virt_tcg_pxb(void)
                   " -cpu cortex-a57"
                   " -device pxb-pcie,bus_nr=128",
                   &data);
-
+out:
     free_test_data(&data);
 }
 
@@ -1764,6 +1812,12 @@ static void test_acpi_microvm_acpi_erst(void)
     gchar *params;
     test_data data;
 
+    if (!qtest_has_device("virtio-blk-device")) {
+        g_test_skip("Device virtio-blk-device is not available");
+        g_free(tmp_path);
+        return;
+    }
+
     test_acpi_microvm_prepare(&data);
     data.variant = ".pcie";
     data.tcg_only = true; /* need constant host-phys-bits */
@@ -1824,6 +1878,11 @@ static void test_acpi_q35_viot(void)
         .variant = ".viot",
     };
 
+    if (!qtest_has_device("virtio-iommu")) {
+        g_test_skip("Device virtio-iommu is not available");
+        goto out;
+    }
+
     /*
      * To keep things interesting, two buses bypass the IOMMU.
      * VIOT should only describes the other two buses.
@@ -1834,6 +1893,7 @@ static void test_acpi_q35_viot(void)
                   "-device pxb-pcie,bus_nr=0x20,id=pcie.200,bus=pcie.0,bypass_iommu=on "
                   "-device pxb-pcie,bus_nr=0x30,id=pcie.300,bus=pcie.0",
                   &data);
+out:
     free_test_data(&data);
 }
 
@@ -1894,8 +1954,10 @@ static void test_acpi_virt_viot(void)
         .scan_len = 128ULL * 1024 * 1024,
     };
 
-    test_acpi_one("-cpu cortex-a57 "
-                  "-device virtio-iommu-pci", &data);
+    if (qtest_has_device("virtio-iommu")) {
+        test_acpi_one("-cpu cortex-a57 "
+                       "-device virtio-iommu-pci", &data);
+    }
     free_test_data(&data);
 }
 
@@ -2004,6 +2066,11 @@ static void test_acpi_microvm_oem_fields(void)
     test_data data;
     char *args;
 
+    if (!qtest_has_device("virtio-blk-device")) {
+        g_test_skip("Device virtio-blk-device is not available");
+        return;
+    }
+
     test_acpi_microvm_prepare(&data);
 
     args = test_acpi_create_args(&data,
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 10/12] tests/qtest: Do not include hexloader-test if loader device is not present
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (8 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 09/12] tests/qtest: Check for devices in bios-tables-test Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 11/12] tests/qemu-iotests: Require virtio-scsi-pci Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 12/12] tests/qtest: bios-tables-test: Skip if missing configs Fabiano Rosas
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 84cd07bbb9..dbe3b1fcc9 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -197,11 +197,11 @@ qtests_arm = \
   (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) +         \
   (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \
   (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
+  (config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \
   ['arm-cpu-features',
    'microbit-test',
    'test-arm-mptimer',
-   'boot-serial-test',
-   'hexloader-test']
+   'boot-serial-test']
 
 # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
 qtests_aarch64 = \
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 11/12] tests/qemu-iotests: Require virtio-scsi-pci
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (9 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 10/12] tests/qtest: Do not include hexloader-test if loader device is not present Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  2023-02-13 21:07 ` [PATCH v3 12/12] tests/qtest: bios-tables-test: Skip if missing configs Fabiano Rosas
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Kevin Wolf, Hanna Reitz, qemu-block

Check that virtio-scsi-pci is present in the QEMU build before running
the tests.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qemu-iotests/186 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
index 072e54e62b..eaf13c7a33 100755
--- a/tests/qemu-iotests/186
+++ b/tests/qemu-iotests/186
@@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto file fuse
 _require_drivers null-co
+_require_devices virtio-scsi-pci
 
 if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
     _notrun "Requires a PC machine"
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 12/12] tests/qtest: bios-tables-test: Skip if missing configs
  2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
                   ` (10 preceding siblings ...)
  2023-02-13 21:07 ` [PATCH v3 11/12] tests/qemu-iotests: Require virtio-scsi-pci Fabiano Rosas
@ 2023-02-13 21:07 ` Fabiano Rosas
  11 siblings, 0 replies; 14+ messages in thread
From: Fabiano Rosas @ 2023-02-13 21:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Laurent Vivier, Paolo Bonzini

If we build with --without-default-devices, CONFIG_HPET and
CONFIG_PARALLEL are set to N, which makes the respective devices go
missing from acpi tables.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/meson.build | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index dbe3b1fcc9..222e1892fb 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -78,7 +78,9 @@ qtests_i386 = \
    config_all_devices.has_key('CONFIG_Q35') and                                             \
    config_all_devices.has_key('CONFIG_VIRTIO_PCI') and                                      \
    slirp.found() ? ['virtio-net-failover'] : []) +                                          \
-  (unpack_edk2_blobs ? ['bios-tables-test'] : []) +                                         \
+  (unpack_edk2_blobs and                                                                    \
+   config_all_devices.has_key('CONFIG_HPET') and                                            \
+   config_all_devices.has_key('CONFIG_PARALLEL') ? ['bios-tables-test'] : []) +             \
   qtests_pci +                                                                              \
   qtests_cxl +                                                                              \
   ['fdc-test',
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 04/12] tests/qtest: Don't build virtio-serial-test.c if device not present
  2023-02-13 21:07 ` [PATCH v3 04/12] tests/qtest: Don't build virtio-serial-test.c if device not present Fabiano Rosas
@ 2023-02-14  7:57   ` Thomas Huth
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Huth @ 2023-02-14  7:57 UTC (permalink / raw)
  To: Fabiano Rosas, qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini

On 13/02/2023 22.07, Fabiano Rosas wrote:
> The virtconsole device might not be present in the QEMU build that is
> being tested.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>   tests/qtest/meson.build | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index 5c8b031ce0..84cd07bbb9 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -255,10 +255,14 @@ qos_test_ss.add(
>     'virtio-net-test.c',
>     'virtio-rng-test.c',
>     'virtio-scsi-test.c',
> -  'virtio-serial-test.c',
>     'virtio-iommu-test.c',
>     'vmxnet3-test.c',
>   )
> +
> +if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL')
> +  qos_test_ss.add(files('virtio-serial-test.c'))
> +endif
> +
>   if config_host.has_key('CONFIG_POSIX')
>     qos_test_ss.add(files('e1000e-test.c'))
>   endif

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-02-14  7:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 21:07 [PATCH v3 00/12] qtests vs. default devices Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 01/12] tests/qtest: Skip PXE tests for missing devices Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 02/12] tests/qtest: Do not run lsi53c895a test if device is not present Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 03/12] tests/qtest: Add dependence on PCIE_PORT for virtio-net-failover.c Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 04/12] tests/qtest: Don't build virtio-serial-test.c if device not present Fabiano Rosas
2023-02-14  7:57   ` Thomas Huth
2023-02-13 21:07 ` [PATCH v3 05/12] tests/qtest: hd-geo-test: Check for missing devices Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 06/12] tests/qtest: Fix coding style in device-plug-test.c Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 07/12] tests/qtest: Skip unplug tests that use missing devices Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 08/12] tests/qtest: drive_del-test: Skip tests that require " Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 09/12] tests/qtest: Check for devices in bios-tables-test Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 10/12] tests/qtest: Do not include hexloader-test if loader device is not present Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 11/12] tests/qemu-iotests: Require virtio-scsi-pci Fabiano Rosas
2023-02-13 21:07 ` [PATCH v3 12/12] tests/qtest: bios-tables-test: Skip if missing configs Fabiano Rosas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.