diff mbox series

[v2,20/29] tests/acceptance/virtio_check_params: Skip test if arch is not supported

Message ID 20200129212345.20547-21-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
Refactor the X86 specific code. If we run this test on an
architecture which is not explicitly supported, the test
will be cancelled (skipped).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/acceptance/virtio_check_params.py | 37 +++++++++++++++----------
 1 file changed, 23 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/tests/acceptance/virtio_check_params.py b/tests/acceptance/virtio_check_params.py
index ad736bcda3..8752e25f08 100755
--- a/tests/acceptance/virtio_check_params.py
+++ b/tests/acceptance/virtio_check_params.py
@@ -26,6 +26,8 @@  import logging
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
 from qemu.machine import QEMUMachine
 from avocado_qemu import Test
+from qemu.binutils import binary_get_arch
+from avocado.core.exceptions import TestCancel
 
 #list of machine types and virtqueue properties to test
 VIRTIO_SCSI_PROPS = {'seg_max_adjust': 'seg_max_adjust'}
@@ -96,18 +98,21 @@  class VirtioMaxSegSettingsCheck(Test):
             self.assertEqual(expected_val, prop_val)
 
     @staticmethod
-    def seg_max_adjust_enabled(mt):
-        # machine types >= 5.0 should have seg_max_adjust = true
-        # others seg_max_adjust = false
-        mt = mt.split("-")
+    def seg_max_adjust_enabled(arch, mt):
+        if arch in ['i386', 'x86_64']:
+            # machine types >= 5.0 should have seg_max_adjust = true
+            # others seg_max_adjust = false
+            mt = mt.split("-")
 
-        # machine types with one line name and name like pc-x.x
-        if len(mt) <= 2:
-            return False
+            # machine types with one line name and name like pc-x.x
+            if len(mt) <= 2:
+                return False
 
-        # machine types like pc-<chip_name>-x.x[.x]
-        ver = mt[2]
-        ver = ver.split(".");
+            # machine types like pc-<chip_name>-x.x[.x]
+            ver = mt[2]
+            ver = ver.split(".");
+        else:
+            raise TestCancel('Unsupported architecture: %s' % arch)
 
         # versions >= 5.0 goes with seg_max_adjust enabled
         major = int(ver[0])
@@ -117,9 +122,13 @@  class VirtioMaxSegSettingsCheck(Test):
         return False
 
     def test_machine_types(self):
-        EXCLUDED_MACHINES = ['none', 'isapc', 'microvm']
-        if os.geteuid() != 0:
-            EXCLUDED_MACHINES += ['xenfv', 'xenpv']
+        arch = binary_get_arch(self.qemu_bin)
+
+        EXCLUDED_MACHINES = ['none']
+        if arch in ['i386', 'x86_64']:
+            EXCLUDED_MACHINES += ['isapc', 'microvm']
+            if os.geteuid() != 0:
+                EXCLUDED_MACHINES += ['xenfv', 'xenpv']
         # collect all machine types except the ones in EXCLUDED_MACHINES
         with QEMUMachine(self.qemu_bin) as vm:
             vm.launch()
@@ -133,7 +142,7 @@  class VirtioMaxSegSettingsCheck(Test):
             # create the list of machine types and their parameters.
             mtypes = list()
             for m in machines:
-                if self.seg_max_adjust_enabled(m):
+                if self.seg_max_adjust_enabled(arch, m):
                     enabled = 'true'
                 else:
                     enabled = 'false'