diff mbox series

[RFC,v2,14/29] tests/acceptance: Use 'device' tags to check availability in QEMU binary

Message ID 20200129212345.20547-15-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/acceptance/virtio_seg_max_adjust: Restrict it to Linux/X86 | expand

Commit Message

Philippe Mathieu-Daudé Jan. 29, 2020, 9:23 p.m. UTC
We already use the 'device' tag in Avocado tests.
If any of the requested device is not available in the QEMU binary,
the tests will be cancelled (skipped).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
RFC because I'm not certain, we might want to find bugs where
    a device is missing in the built binary...
---
 tests/acceptance/avocado_qemu/__init__.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 53ec8512d1..44062aea56 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -20,6 +20,7 @@  SRC_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..', '..')
 sys.path.append(os.path.join(SRC_ROOT_DIR, 'python'))
 
 from qemu.binutils import binary_get_arch
+from qemu.binutils import binary_get_devices
 from qemu.binutils import binary_get_machines
 from qemu.binutils import binary_get_version
 from qemu.machine import QEMUMachine
@@ -158,6 +159,16 @@  class Test(avocado.Test):
             if self.machine not in binary_get_machines(self.qemu_bin):
                 self.cancel(fmt.format(self.machine))
 
+        # Verify devices
+        self.devices = self.tags.get('device', [])
+        bin_devices = binary_get_devices(self.qemu_bin)
+        logger.debug('devices: {}'.format(self.devices))
+        fmt = "Test expects device '{}' which is missing from QEMU binary"
+        for dev in self.devices:
+            logger.debug(dev)
+            if dev not in bin_devices:
+                self.cancel(fmt.format(dev))
+
     def _new_vm(self, *args):
         vm = QEMUMachine(self.qemu_bin, sock_dir=tempfile.mkdtemp())
         if args: