]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
Acceptance tests: introduce utility method for tags unique vals
authorCleber Rosa <crosa@redhat.com>
Tue, 24 Sep 2019 19:45:00 +0000 (15:45 -0400)
committerCleber Rosa <crosa@redhat.com>
Mon, 16 Dec 2019 16:12:16 +0000 (11:12 -0500)
Currently a test can describe the target architecture binary that it
should primarily be run with, be setting a single tag value.

The same approach is expected to be done with other QEMU aspects to be
tested, for instance, the machine type and accelerator, so let's
generalize the logic into a utility method.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20190924194501.9303-3-crosa@redhat.com>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
tests/acceptance/avocado_qemu/__init__.py

index 9a57c020d896027b680c645ca109d43fdfa920b7..e676d9c4e73cb4631182317d1b86dd07fc788b82 100644 (file)
@@ -100,14 +100,21 @@ def exec_command_and_wait_for_pattern(test, command,
 
 
 class Test(avocado.Test):
+    def _get_unique_tag_val(self, tag_name):
+        """
+        Gets a tag value, if unique for a key
+        """
+        vals = self.tags.get(tag_name, [])
+        if len(vals) == 1:
+            return vals.pop()
+        return None
+
     def setUp(self):
         self._vms = {}
-        arches = self.tags.get('arch', [])
-        if len(arches) == 1:
-            arch = arches.pop()
-        else:
-            arch = None
-        self.arch = self.params.get('arch', default=arch)
+
+        self.arch = self.params.get('arch',
+                                    default=self._get_unique_tag_val('arch'))
+
         default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
         self.qemu_bin = self.params.get('qemu_bin',
                                         default=default_qemu_bin)