Skip to contentSkip to conversation

tests/acceptance: Add bFLT loader linux-user test

PATCH Superseded Philippe Mathieu-Daudé 2 participants 17 messages Sep 27, 2021 – Nov 1, 2021 Broadcom iproc Arm architecture

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover tests/acceptance: Add bFLT loader linux-user test

Since v3:
- rebased
- addressed Wainer review comments from v2
- rename avocado_qemu.Test -> QemuSystemTest

Since v2:
- rebased tests/acceptance/avocado_qemu/__init__.py patches
- extract has_cmd() from virtiofs_submounts.py
- check cpio availability with has_cmd()

Philippe Mathieu-Daudé (6):
tests/acceptance: Extract QemuBaseTest from Test tests/acceptance: Make pick_default_qemu_bin() more generic tests/acceptance: Introduce QemuUserTest base class tests/acceptance: Share useful helpers from virtiofs_submounts test tests/acceptance: Add bFLT loader linux-user test tests/acceptance: Rename avocado_qemu.Test -> QemuSystemTest

 tests/acceptance/avocado_qemu/__init__.py    | 158 ++++++++++++++-----
 tests/acceptance/boot_linux_console.py       |   4 +-
 tests/acceptance/cpu_queries.py              |   4 +-
 tests/acceptance/empty_cpu_model.py          |   4 +-
 tests/acceptance/info_usernet.py             |   4 +-
 tests/acceptance/linux_initrd.py             |   4 +-
 tests/acceptance/linux_ssh_mips_malta.py     |   5 +-
 tests/acceptance/load_bflt.py                |  54 +++++++
 tests/acceptance/machine_arm_canona1100.py   |   4 +-
 tests/acceptance/machine_arm_integratorcp.py |   4 +-
 tests/acceptance/machine_arm_n8x0.py         |   4 +-
 tests/acceptance/machine_avr6.py             |   4 +-
 tests/acceptance/machine_m68k_nextcube.py    |   4 +-
 tests/acceptance/machine_microblaze.py       |   4 +-
 tests/acceptance/machine_mips_fuloong2e.py   |   4 +-
 tests/acceptance/machine_mips_loongson3v.py  |   4 +-
 tests/acceptance/machine_mips_malta.py       |   4 +-
 tests/acceptance/machine_ppc.py              |   4 +-
 tests/acceptance/machine_rx_gdbsim.py        |   4 +-
 tests/acceptance/machine_s390_ccw_virtio.py  |   4 +-
 tests/acceptance/machine_sparc_leon3.py      |   4 +-
 tests/acceptance/migration.py                |   4 +-
 tests/acceptance/multiprocess.py             |   4 +-
 tests/acceptance/pc_cpu_hotplug_props.py     |   4 +-
 tests/acceptance/ppc_prep_40p.py             |   4 +-
 tests/acceptance/version.py                  |   4 +-
 tests/acceptance/virtio-gpu.py               |   4 +-
 tests/acceptance/virtio_check_params.py      |   4 +-
 tests/acceptance/virtio_version.py           |   4 +-
 tests/acceptance/virtiofs_submounts.py       |  59 +------
 tests/acceptance/vnc.py                      |   4 +-
 tests/acceptance/x86_cpu_model_versions.py   |   4 +-
 32 files changed, 235 insertions(+), 153 deletions(-)
 create mode 100644 tests/acceptance/load_bflt.py
Signature · 1 line
2.31.1
#1 lore raw

PATCH v4 1/6 tests/acceptance: Extract QemuBaseTest from Test

The Avocado Test::fetch_asset() is handy to download artifacts before running tests. The current class is named Test but only tests system emulation. As we want to test user emulation, refactor the common code as QemuBaseTest.

---
 tests/acceptance/avocado_qemu/__init__.py | 72 +++++++++++++----------
 1 file changed, 41 insertions(+), 31 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +41 -31
index 2c4fef3e149..8fcbed74849 100644
@@ -175,7 +175,7 @@ def exec_command_and_wait_for_pattern(test, command,
     """
     _console_interaction(test, success_message, failure_message, command + '\r')
 
-class Test(avocado.Test):
+class QemuBaseTest(avocado.Test):
     def _get_unique_tag_val(self, tag_name):
         """
         Gets a tag value, if unique for a key
@@ -185,6 +185,46 @@ def _get_unique_tag_val(self, tag_name):
             return vals.pop()
         return None
 
+    def setUp(self):
+        self.arch = self.params.get('arch',
+                                    default=self._get_unique_tag_val('arch'))
+
+        self.cpu = self.params.get('cpu',
+                                   default=self._get_unique_tag_val('cpu'))
+
+        default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
+        self.qemu_bin = self.params.get('qemu_bin',
+                                        default=default_qemu_bin)
+        if self.qemu_bin is None:
+            self.cancel("No QEMU binary defined or found in the build tree")
+
+    def fetch_asset(self, name,
+                    asset_hash=None, algorithm=None,
+                    locations=None, expire=None,
+                    find_only=False, cancel_on_missing=True):
+        return super(QemuBaseTest, self).fetch_asset(name,
+                        asset_hash=asset_hash,
+                        algorithm=algorithm,
+                        locations=locations,
+                        expire=expire,
+                        find_only=find_only,
+                        cancel_on_missing=cancel_on_missing)
+
+
+class Test(QemuBaseTest):
+    """Facilitates system emulation tests.
+
+    TODO: Rename this class as `QemuSystemTest`.
+    """
+
+    def setUp(self):
+        self._vms = {}
+
+        super(Test, self).setUp()
+
+        self.machine = self.params.get('machine',
+                                       default=self._get_unique_tag_val('machine'))
+
     def require_accelerator(self, accelerator):
         """
         Requires an accelerator to be available for the test to continue
@@ -207,24 +247,6 @@ def require_accelerator(self, accelerator):
             self.cancel("%s accelerator does not seem to be "
                         "available" % accelerator)
 
-    def setUp(self):
-        self._vms = {}
-
-        self.arch = self.params.get('arch',
-                                    default=self._get_unique_tag_val('arch'))
-
-        self.cpu = self.params.get('cpu',
-                                   default=self._get_unique_tag_val('cpu'))
-
-        self.machine = self.params.get('machine',
-                                       default=self._get_unique_tag_val('machine'))
-
-        default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
-        self.qemu_bin = self.params.get('qemu_bin',
-                                        default=default_qemu_bin)
-        if self.qemu_bin is None:
-            self.cancel("No QEMU binary defined or found in the build tree")
-
     def _new_vm(self, name, *args):
         self._sd = tempfile.TemporaryDirectory(prefix="avo_qemu_sock_")
         vm = QEMUMachine(self.qemu_bin, base_temp_dir=self.workdir,
@@ -277,18 +299,6 @@ def tearDown(self):
             vm.shutdown()
         self._sd = None
 
-    def fetch_asset(self, name,
-                    asset_hash=None, algorithm=None,
-                    locations=None, expire=None,
-                    find_only=False, cancel_on_missing=True):
-        return super(Test, self).fetch_asset(name,
-                        asset_hash=asset_hash,
-                        algorithm=algorithm,
-                        locations=locations,
-                        expire=expire,
-                        find_only=find_only,
-                        cancel_on_missing=cancel_on_missing)
-
 
 class LinuxSSHMixIn:
     """Contains utility methods for interacting with a guest via SSH."""
Signature · 1 line
2.31.1
Reviewed-by on v4 1/6
#2 lore raw

Re: [PATCH v4 1/6] tests/acceptance: Extract QemuBaseTest from Test

Quoted 36 lines · Philippe Mathieu-Daudé

The Avocado Test::fetch_asset() is handy to download artifacts before running tests. The current class is named Test but only tests system emulation. As we want to test user emulation, refactor the common code as QemuBaseTest.

---
 tests/acceptance/avocado_qemu/__init__.py | 72 +++++++++++++----------
 1 file changed, 41 insertions(+), 31 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +9 -1
index 2c4fef3e149..8fcbed74849 100644
@@ -175,7 +175,7 @@ def exec_command_and_wait_for_pattern(test, command,
     """
     _console_interaction(test, success_message, failure_message, command + '\r')
 
-class Test(avocado.Test):
+class QemuBaseTest(avocado.Test):
     def _get_unique_tag_val(self, tag_name):
         """
         Gets a tag value, if unique for a key
@@ -185,6 +185,46 @@ def _get_unique_tag_val(self, tag_name):
             return vals.pop()
         return None
 
+    def setUp(self):
+        self.arch = self.params.get('arch',
+                                    default=self._get_unique_tag_val('arch'))
+
+        self.cpu = self.params.get('cpu',
+                                   default=self._get_unique_tag_val('cpu'))
+
+        default_qemu_bin = pick_default_qemu_bin(arch=self.arch)

tests/acceptance/avocado_qemu/__init__.py def _get_unique_tag_val(self, tag_name): · line 205

Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +10 -0
+        self.qemu_bin = self.params.get('qemu_bin',
+                                        default=default_qemu_bin)
+        if self.qemu_bin is None:
+            self.cancel("No QEMU binary defined or found in the build tree")
+
+    def fetch_asset(self, name,
+                    asset_hash=None, algorithm=None,
+                    locations=None, expire=None,
+                    find_only=False, cancel_on_missing=True):
+        return super(QemuBaseTest, self).fetch_asset(name,

It is preferable to use the PEP3135
(https://www.python.org/dev/peps/pep-3135/) when calling super as linter are complaining about it:

return super().fetch_asset(name,

And after reading through the patch I noticed it was a method move, so, feel free to take the suggestion or ignore it for now.

Quoted 8 lines
tests/acceptance/avocado_qemu/__init__.py +8 -0
+                        asset_hash=asset_hash,
+                        algorithm=algorithm,
+                        locations=locations,
+                        expire=expire,
+                        find_only=find_only,
+                        cancel_on_missing=cancel_on_missing)
+
+

tests/acceptance/avocado_qemu/__init__.py def _get_unique_tag_val(self, tag_name): · line 223

Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +10 -0
+class Test(QemuBaseTest):
+    """Facilitates system emulation tests.
+
+    TODO: Rename this class as `QemuSystemTest`.
+    """
+
+    def setUp(self):
+        self._vms = {}
+
+        super(Test, self).setUp()

Same from previous comment:

super().setUp()

Quoted 52 lines
tests/acceptance/avocado_qemu/__init__.py +4 -31
+
+        self.machine = self.params.get('machine',
+                                       default=self._get_unique_tag_val('machine'))
+
     def require_accelerator(self, accelerator):
         """
         Requires an accelerator to be available for the test to continue
@@ -207,24 +247,6 @@ def require_accelerator(self, accelerator):
             self.cancel("%s accelerator does not seem to be "
                         "available" % accelerator)
 
-    def setUp(self):
-        self._vms = {}
-
-        self.arch = self.params.get('arch',
-                                    default=self._get_unique_tag_val('arch'))
-
-        self.cpu = self.params.get('cpu',
-                                   default=self._get_unique_tag_val('cpu'))
-
-        self.machine = self.params.get('machine',
-                                       default=self._get_unique_tag_val('machine'))
-
-        default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
-        self.qemu_bin = self.params.get('qemu_bin',
-                                        default=default_qemu_bin)
-        if self.qemu_bin is None:
-            self.cancel("No QEMU binary defined or found in the build tree")
-
     def _new_vm(self, name, *args):
         self._sd = tempfile.TemporaryDirectory(prefix="avo_qemu_sock_")
         vm = QEMUMachine(self.qemu_bin, base_temp_dir=self.workdir,
@@ -277,18 +299,6 @@ def tearDown(self):
             vm.shutdown()
         self._sd = None
 
-    def fetch_asset(self, name,
-                    asset_hash=None, algorithm=None,
-                    locations=None, expire=None,
-                    find_only=False, cancel_on_missing=True):
-        return super(Test, self).fetch_asset(name,
-                        asset_hash=asset_hash,
-                        algorithm=algorithm,
-                        locations=locations,
-                        expire=expire,
-                        find_only=find_only,
-                        cancel_on_missing=cancel_on_missing)
-
 
 class LinuxSSHMixIn:
     """Contains utility methods for interacting with a guest via SSH."""
--
Quoted 2 lines

2.31.1

Except for one (or two, if you consider the first) small comment, looks good to me, so

#3 lore raw

Re: [PATCH v4 1/6] tests/acceptance: Extract QemuBaseTest from Test

Quoted 52 lines · Willian Rampazzo
Quoted 36 lines · Philippe Mathieu-Daudé

The Avocado Test::fetch_asset() is handy to download artifacts before running tests. The current class is named Test but only tests system emulation. As we want to test user emulation, refactor the common code as QemuBaseTest.

---
 tests/acceptance/avocado_qemu/__init__.py | 72 +++++++++++++----------
 1 file changed, 41 insertions(+), 31 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +9 -1
index 2c4fef3e149..8fcbed74849 100644
@@ -175,7 +175,7 @@ def exec_command_and_wait_for_pattern(test, command,
     """
     _console_interaction(test, success_message, failure_message, command + '\r')
 
-class Test(avocado.Test):
+class QemuBaseTest(avocado.Test):
     def _get_unique_tag_val(self, tag_name):
         """
         Gets a tag value, if unique for a key
@@ -185,6 +185,46 @@ def _get_unique_tag_val(self, tag_name):
             return vals.pop()
         return None
 
+    def setUp(self):
+        self.arch = self.params.get('arch',
+                                    default=self._get_unique_tag_val('arch'))
+
+        self.cpu = self.params.get('cpu',
+                                   default=self._get_unique_tag_val('cpu'))
+
+        default_qemu_bin = pick_default_qemu_bin(arch=self.arch)

tests/acceptance/avocado_qemu/__init__.py def _get_unique_tag_val(self, tag_name): · line 205

Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +10 -0
+        self.qemu_bin = self.params.get('qemu_bin',
+                                        default=default_qemu_bin)
+        if self.qemu_bin is None:
+            self.cancel("No QEMU binary defined or found in the build tree")
+
+    def fetch_asset(self, name,
+                    asset_hash=None, algorithm=None,
+                    locations=None, expire=None,
+                    find_only=False, cancel_on_missing=True):
+        return super(QemuBaseTest, self).fetch_asset(name,

It is preferable to use the PEP3135
(https://www.python.org/dev/peps/pep-3135/) when calling super as linter are complaining about it:

Quoted 4 lines

return super().fetch_asset(name,

And after reading through the patch I noticed it was a method move, so, feel free to take the suggestion or ignore it for now.

This series was sent before commit 14f02d8a9ec ("Merge 'integration-testing-20210927' into staging") :/

I'll modify, thanks.

#4 lore raw

PATCH v4 2/6 tests/acceptance: Make pick_default_qemu_bin() more generic

In reply to Philippe Mathieu-Daudé

Make pick_default_qemu_bin() generic to find qemu-system or qemu-user binaries.

---
 tests/acceptance/avocado_qemu/__init__.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +5 -5
index 8fcbed74849..2b9b5dd27fe 100644
@@ -52,7 +52,7 @@ def is_readable_executable_file(path):
     return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
 
 
-def pick_default_qemu_bin(arch=None):
+def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
     """
     Picks the path of a QEMU binary, starting either in the current working
     directory or in the source tree root directory.
@@ -71,7 +71,7 @@ def pick_default_qemu_bin(arch=None):
     # qemu binary path does not match arch for powerpc, handle it
     if 'ppc64le' in arch:
         arch = 'ppc64'
-    qemu_bin_relative_path = "./qemu-system-%s" % arch
+    qemu_bin_relative_path = os.path.join(".", bin_prefix + arch)
     if is_readable_executable_file(qemu_bin_relative_path):
         return qemu_bin_relative_path
 
@@ -185,14 +185,14 @@ def _get_unique_tag_val(self, tag_name):
             return vals.pop()
         return None
 
-    def setUp(self):
+    def setUp(self, bin_prefix):
         self.arch = self.params.get('arch',
                                     default=self._get_unique_tag_val('arch'))
 
         self.cpu = self.params.get('cpu',
                                    default=self._get_unique_tag_val('cpu'))
 
-        default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
+        default_qemu_bin = pick_default_qemu_bin(bin_prefix, arch=self.arch)
         self.qemu_bin = self.params.get('qemu_bin',
                                         default=default_qemu_bin)
         if self.qemu_bin is None:
@@ -220,7 +220,7 @@ class Test(QemuBaseTest):
     def setUp(self):
         self._vms = {}
 
-        super(Test, self).setUp()
+        super(Test, self).setUp('qemu-system-')
 
         self.machine = self.params.get('machine',
                                        default=self._get_unique_tag_val('machine'))
Signature · 1 line
2.31.1
Reviewed-by on v4 2/6
#5 lore raw

Re: [PATCH v4 2/6] tests/acceptance: Make pick_default_qemu_bin() more generic

Quoted 49 lines · Philippe Mathieu-Daudé

Make pick_default_qemu_bin() generic to find qemu-system or qemu-user binaries.

---
 tests/acceptance/avocado_qemu/__init__.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +4 -4
index 8fcbed74849..2b9b5dd27fe 100644
@@ -52,7 +52,7 @@ def is_readable_executable_file(path):
     return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
 
 
-def pick_default_qemu_bin(arch=None):
+def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
     """
     Picks the path of a QEMU binary, starting either in the current working
     directory or in the source tree root directory.
@@ -71,7 +71,7 @@ def pick_default_qemu_bin(arch=None):
     # qemu binary path does not match arch for powerpc, handle it
     if 'ppc64le' in arch:
         arch = 'ppc64'
-    qemu_bin_relative_path = "./qemu-system-%s" % arch
+    qemu_bin_relative_path = os.path.join(".", bin_prefix + arch)
     if is_readable_executable_file(qemu_bin_relative_path):
         return qemu_bin_relative_path
 
@@ -185,14 +185,14 @@ def _get_unique_tag_val(self, tag_name):
             return vals.pop()
         return None
 
-    def setUp(self):
+    def setUp(self, bin_prefix):
         self.arch = self.params.get('arch',
                                     default=self._get_unique_tag_val('arch'))
 
         self.cpu = self.params.get('cpu',
                                    default=self._get_unique_tag_val('cpu'))
 
-        default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
+        default_qemu_bin = pick_default_qemu_bin(bin_prefix, arch=self.arch)
         self.qemu_bin = self.params.get('qemu_bin',
                                         default=default_qemu_bin)
         if self.qemu_bin is None:

tests/acceptance/avocado_qemu/__init__.py class Test(QemuBaseTest): · line 223

Quoted 5 lines
tests/acceptance/avocado_qemu/__init__.py +1 -1
@@ -220,7 +220,7 @@ class Test(QemuBaseTest):
     def setUp(self):
         self._vms = {}
 
-        super(Test, self).setUp()
+        super(Test, self).setUp('qemu-system-')

If you need to change something else in this patch, consider using PEP3135:

super().setUp('qemu-system-')

Anyway,

Quoted 6 lines
tests/acceptance/avocado_qemu/__init__.py +0 -1
         self.machine = self.params.get('machine',
                                        default=self._get_unique_tag_val('machine'))
--

2.31.1

#6 lore raw

PATCH v4 3/6 tests/acceptance: Introduce QemuUserTest base class

In reply to Philippe Mathieu-Daudé

Similarly to the 'System' Test base class with methods for testing system emulation, the QemuUserTest class contains methods useful to test user-mode emulation.

---
 tests/acceptance/avocado_qemu/__init__.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
tests/acceptance/avocado_qemu/__init__.py +18 -0
index 2b9b5dd27fe..2f59e171e49 100644
@@ -20,6 +20,7 @@
 from avocado.utils import cloudinit
 from avocado.utils import datadrainer
 from avocado.utils import network
+from avocado.utils import process
 from avocado.utils import ssh
 from avocado.utils import vmimage
 from avocado.utils.path import find_command
@@ -300,6 +301,23 @@ def tearDown(self):
         self._sd = None
 
 
+class QemuUserTest(QemuBaseTest):
+    """Facilitates user-mode emulation tests."""
+
+    def setUp(self):
+        self._ldpath = []
+        super(QemuUserTest, self).setUp('qemu-')
+
+    def add_ldpath(self, ldpath):
+        self._ldpath += [os.path.abspath(ldpath)]
+
+    def run(self, bin_path, args=[]):
+        qemu_args = " ".join(["-L %s" % ldpath for ldpath in self._ldpath])
+        bin_args = " ".join(args)
+        return process.run("%s %s %s %s" % (self.qemu_bin, qemu_args,
+                                            bin_path, bin_args))
+
+
 class LinuxSSHMixIn:
     """Contains utility methods for interacting with a guest via SSH."""
 
Signature · 1 line
2.31.1
Reviewed-by on v4 3/6
#7 lore raw

Re: [PATCH v4 3/6] tests/acceptance: Introduce QemuUserTest base class

Quoted 24 lines · Philippe Mathieu-Daudé

Similarly to the 'System' Test base class with methods for testing system emulation, the QemuUserTest class contains methods useful to test user-mode emulation.

---
 tests/acceptance/avocado_qemu/__init__.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
tests/acceptance/avocado_qemu/__init__.py +1 -0
index 2b9b5dd27fe..2f59e171e49 100644
@@ -20,6 +20,7 @@
 from avocado.utils import cloudinit
 from avocado.utils import datadrainer
 from avocado.utils import network
+from avocado.utils import process
 from avocado.utils import ssh
 from avocado.utils import vmimage
 from avocado.utils.path import find_command

tests/acceptance/avocado_qemu/__init__.py def tearDown(self): · line 309

Quoted 9 lines
tests/acceptance/avocado_qemu/__init__.py +6 -0
@@ -300,6 +301,23 @@ def tearDown(self):
         self._sd = None
 
 
+class QemuUserTest(QemuBaseTest):
+    """Facilitates user-mode emulation tests."""
+
+    def setUp(self):
+        self._ldpath = []
+        super(QemuUserTest, self).setUp('qemu-')

Consider using PEP3135,

super().setUp('qemu-')

tests/acceptance/avocado_qemu/__init__.py def tearDown(self): · line 312

Quoted 3 lines
tests/acceptance/avocado_qemu/__init__.py +3 -0
+
+    def add_ldpath(self, ldpath):
+        self._ldpath += [os.path.abspath(ldpath)]

The use of the append method is more common here:

self._ldpath.append(os.path.abspath(ldpath))

tests/acceptance/avocado_qemu/__init__.py def tearDown(self): · line 322

Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +8 -0
+
+    def run(self, bin_path, args=[]):
+        qemu_args = " ".join(["-L %s" % ldpath for ldpath in self._ldpath])
+        bin_args = " ".join(args)
+        return process.run("%s %s %s %s" % (self.qemu_bin, qemu_args,
+                                            bin_path, bin_args))
+
+
 class LinuxSSHMixIn:
     """Contains utility methods for interacting with a guest via SSH."""

Besides some Python related suggestions, the code looks good.

Quoted 4 lines
tests/acceptance/avocado_qemu/__init__.py +0 -1
--

2.31.1

#8 lore raw

PATCH v4 4/6 tests/acceptance: Share useful helpers from virtiofs_submounts test

In reply to Philippe Mathieu-Daudé

Move the useful has_cmd()/has_cmds() helpers from the virtiofs test to the avocado_qemu public class.

---
 tests/acceptance/avocado_qemu/__init__.py | 57 ++++++++++++++++++++++
 tests/acceptance/virtiofs_submounts.py    | 59 +----------------------
 2 files changed, 59 insertions(+), 57 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +57 -0
index 2f59e171e49..a497a24f823 100644
@@ -11,6 +11,7 @@
 import logging
 import os
 import shutil
+import subprocess
 import sys
 import uuid
 import tempfile
@@ -49,6 +50,62 @@
     tcg_available,
 )
 
+def has_cmd(name, args=None):
+    """
+    This function is for use in a @avocado.skipUnless decorator, e.g.:
+
+        @skipUnless(*has_cmd('sudo -n', ('sudo', '-n', 'true')))
+        def test_something_that_needs_sudo(self):
+            ...
+    """
+
+    if args is None:
+        args = ('which', name)
+
+    try:
+        _, stderr, exitcode = run_cmd(args)
+    except Exception as e:
+        exitcode = -1
+        stderr = str(e)
+
+    if exitcode != 0:
+        cmd_line = ' '.join(args)
+        err = f'{name} required, but "{cmd_line}" failed: {stderr.strip()}'
+        return (False, err)
+    else:
+        return (True, '')
+
+def has_cmds(*cmds):
+    """
+    This function is for use in a @avocado.skipUnless decorator and
+    allows checking for the availability of multiple commands, e.g.:
+
+        @skipUnless(*has_cmds(('cmd1', ('cmd1', '--some-parameter')),
+                              'cmd2', 'cmd3'))
+        def test_something_that_needs_cmd1_and_cmd2(self):
+            ...
+    """
+
+    for cmd in cmds:
+        if isinstance(cmd, str):
+            cmd = (cmd,)
+
+        ok, errstr = has_cmd(*cmd)
+        if not ok:
+            return (False, errstr)
+
+    return (True, '')
+
+def run_cmd(args):
+    subp = subprocess.Popen(args,
+                            stdout=subprocess.PIPE,
+                            stderr=subprocess.PIPE,
+                            universal_newlines=True)
+    stdout, stderr = subp.communicate()
+    ret = subp.returncode
+
+    return (stdout, stderr, ret)
+
 def is_readable_executable_file(path):
     return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
 
tests/acceptance/virtiofs_submounts.py +2 -57

69 lines not on this page · raw message

Signature · 1 line
2.31.1
Reviewed-by on v4 4/6
#9 lore raw

Re: [PATCH v4 4/6] tests/acceptance: Share useful helpers from virtiofs_submounts test

Quoted 11 lines · Philippe Mathieu-Daudé

Move the useful has_cmd()/has_cmds() helpers from the virtiofs test to the avocado_qemu public class.

---
 tests/acceptance/avocado_qemu/__init__.py | 57 ++++++++++++++++++++++
 tests/acceptance/virtiofs_submounts.py    | 59 +----------------------
 2 files changed, 59 insertions(+), 57 deletions(-)
#10 lore raw

PATCH v4 5/6 tests/acceptance: Add bFLT loader linux-user test

In reply to Philippe Mathieu-Daudé

Add a very quick test that runs a busybox binary in bFLT format:

  $ AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
    avocado --show=app run -t linux_user tests/acceptance/load_bflt.py
  JOB ID     : db94d5960ce564c50904d666a7e259148c27e88f
  JOB LOG    : ~/avocado/job-results/job-2019-06-25T10.52-db94d59/job.log
   (1/1) tests/acceptance/load_bflt.py:LoadBFLT.test_stm32: PASS (0.15 s)
  RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
  JOB TIME   : 0.54 s
---
 tests/acceptance/load_bflt.py | 54 +++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 tests/acceptance/load_bflt.py
tests/acceptance/load_bflt.py new file +54 -0
new file mode 100644
index 00000000000..f071a979d8e
@@ -0,0 +1,54 @@
+# Test the bFLT loader format
+#
+# Copyright (C) 2019 Philippe Mathieu-Daudé <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+import bz2
+import subprocess
+
+from avocado import skipUnless
+from avocado_qemu import QemuUserTest
+from avocado_qemu import has_cmd
+
+
+class LoadBFLT(QemuUserTest):
+
+    def extract_cpio(self, cpio_path):
+        """
+        Extracts a cpio archive into the test workdir
+
+        :param cpio_path: path to the cpio archive
+        """
+        cwd = os.getcwd()
+        os.chdir(self.workdir)
+        with bz2.open(cpio_path, 'rb') as archive_cpio:
+            subprocess.run(['cpio', '-i'], input=archive_cpio.read(),
+                           stderr=subprocess.DEVNULL)
+        os.chdir(cwd)
+
+    @skipUnless(*has_cmd('cpio'))
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    def test_stm32(self):
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=linux_user
+        :avocado: tags=quick
+        """
+        # See https://elinux.org/STM32#User_Space
+        rootfs_url = ('https://elinux.org/images/5/51/'
+                      'Stm32_mini_rootfs.cpio.bz2')
+        rootfs_hash = '9f065e6ba40cce7411ba757f924f30fcc57951e6'
+        rootfs_path_bz2 = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
+        busybox_path = self.workdir + "/bin/busybox"
+
+        self.extract_cpio(rootfs_path_bz2)
+
+        res = self.run(busybox_path)
+        ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.'
+        self.assertIn(ver, res.stdout_text)
+
+        res = self.run(busybox_path, ['uname', '-a'])
+        unm = 'armv7l GNU/Linux'
+        self.assertIn(unm, res.stdout_text)
Signature · 1 line
2.31.1
#11 lore raw

Hi, Phill,

Quoted 58 lines · Philippe Mathieu-Daudé

Add a very quick test that runs a busybox binary in bFLT format:

  $ AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
    avocado --show=app run -t linux_user tests/acceptance/load_bflt.py
  JOB ID     : db94d5960ce564c50904d666a7e259148c27e88f
  JOB LOG    : ~/avocado/job-results/job-2019-06-25T10.52-db94d59/job.log
   (1/1) tests/acceptance/load_bflt.py:LoadBFLT.test_stm32: PASS (0.15 s)
  RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
  JOB TIME   : 0.54 s
---
 tests/acceptance/load_bflt.py | 54 +++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 tests/acceptance/load_bflt.py
tests/acceptance/load_bflt.py new file +34 -0
new file mode 100644
index 00000000000..f071a979d8e
@@ -0,0 +1,54 @@
+# Test the bFLT loader format
+#
+# Copyright (C) 2019 Philippe Mathieu-Daudé <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+import bz2
+import subprocess
+
+from avocado import skipUnless
+from avocado_qemu import QemuUserTest
+from avocado_qemu import has_cmd
+
+
+class LoadBFLT(QemuUserTest):
+
+    def extract_cpio(self, cpio_path):
+        """
+        Extracts a cpio archive into the test workdir
+
+        :param cpio_path: path to the cpio archive
+        """
+        cwd = os.getcwd()
+        os.chdir(self.workdir)
+        with bz2.open(cpio_path, 'rb') as archive_cpio:
+            subprocess.run(['cpio', '-i'], input=archive_cpio.read(),
+                           stderr=subprocess.DEVNULL)
+        os.chdir(cwd)
+
+    @skipUnless(*has_cmd('cpio'))
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    def test_stm32(self):
+        """

tests/acceptance/load_bflt.py line 44

Quoted 10 lines
tests/acceptance/load_bflt.py new file +10 -0
+        :avocado: tags=arch:arm
+        :avocado: tags=linux_user
+        :avocado: tags=quick
+        """
+        # See https://elinux.org/STM32#User_Space
+        rootfs_url = ('https://elinux.org/images/5/51/'
+                      'Stm32_mini_rootfs.cpio.bz2')
+        rootfs_hash = '9f065e6ba40cce7411ba757f924f30fcc57951e6'
+        rootfs_path_bz2 = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
+        busybox_path = self.workdir + "/bin/busybox"

If there are other changes to this patch, also, change this to use the os library:

busybox_path = os.path.join(self.workdir, "/bin/busybox")

Sorry for not catching this before.

Quoted 13 lines
tests/acceptance/load_bflt.py new file +10 -1
+
+        self.extract_cpio(rootfs_path_bz2)
+
+        res = self.run(busybox_path)
+        ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.'
+        self.assertIn(ver, res.stdout_text)
+
+        res = self.run(busybox_path, ['uname', '-a'])
+        unm = 'armv7l GNU/Linux'
+        self.assertIn(unm, res.stdout_text)
--

2.31.1

#12 lore raw
Quoted 75 lines · Willian Rampazzo

Hi, Phill,

Quoted 58 lines · Philippe Mathieu-Daudé

Add a very quick test that runs a busybox binary in bFLT format:

  $ AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
    avocado --show=app run -t linux_user tests/acceptance/load_bflt.py
  JOB ID     : db94d5960ce564c50904d666a7e259148c27e88f
  JOB LOG    : ~/avocado/job-results/job-2019-06-25T10.52-db94d59/job.log
   (1/1) tests/acceptance/load_bflt.py:LoadBFLT.test_stm32: PASS (0.15 s)
  RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
  JOB TIME   : 0.54 s
---
 tests/acceptance/load_bflt.py | 54 +++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 tests/acceptance/load_bflt.py
tests/acceptance/load_bflt.py new file +34 -0
new file mode 100644
index 00000000000..f071a979d8e
@@ -0,0 +1,54 @@
+# Test the bFLT loader format
+#
+# Copyright (C) 2019 Philippe Mathieu-Daudé <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+import bz2
+import subprocess
+
+from avocado import skipUnless
+from avocado_qemu import QemuUserTest
+from avocado_qemu import has_cmd
+
+
+class LoadBFLT(QemuUserTest):
+
+    def extract_cpio(self, cpio_path):
+        """
+        Extracts a cpio archive into the test workdir
+
+        :param cpio_path: path to the cpio archive
+        """
+        cwd = os.getcwd()
+        os.chdir(self.workdir)
+        with bz2.open(cpio_path, 'rb') as archive_cpio:
+            subprocess.run(['cpio', '-i'], input=archive_cpio.read(),
+                           stderr=subprocess.DEVNULL)
+        os.chdir(cwd)
+
+    @skipUnless(*has_cmd('cpio'))
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    def test_stm32(self):
+        """

tests/acceptance/load_bflt.py line 44

Quoted 10 lines
tests/acceptance/load_bflt.py new file +10 -0
+        :avocado: tags=arch:arm
+        :avocado: tags=linux_user
+        :avocado: tags=quick
+        """
+        # See https://elinux.org/STM32#User_Space
+        rootfs_url = ('https://elinux.org/images/5/51/'
+                      'Stm32_mini_rootfs.cpio.bz2')
+        rootfs_hash = '9f065e6ba40cce7411ba757f924f30fcc57951e6'
+        rootfs_path_bz2 = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
+        busybox_path = self.workdir + "/bin/busybox"

If there are other changes to this patch, also, change this to use the os library:

Quoted 1 line

busybox_path = os.path.join(self.workdir, "/bin/busybox")

OK, I'll update.

#13 lore raw

PATCH v4 6/6 tests/acceptance: Rename avocado_qemu.Test -> QemuSystemTest

In reply to Philippe Mathieu-Daudé

To run user-mode emulation tests, we introduced the avocado_qemu.QemuUserTest which inherits from avocado_qemu.QemuBaseTest. System-mode emulation tests are based on the avocado_qemu.Test class, which also inherits avocado_qemu.QemuBaseTest. To avoid confusion, rename it as avocado_qemu.QemuSystemTest.

---
 tests/acceptance/avocado_qemu/__init__.py    | 21 +++++++++-----------
 tests/acceptance/boot_linux_console.py       |  4 ++--
 tests/acceptance/cpu_queries.py              |  4 ++--
 tests/acceptance/empty_cpu_model.py          |  4 ++--
 tests/acceptance/info_usernet.py             |  4 ++--
 tests/acceptance/linux_initrd.py             |  4 ++--
 tests/acceptance/linux_ssh_mips_malta.py     |  5 +++--
 tests/acceptance/machine_arm_canona1100.py   |  4 ++--
 tests/acceptance/machine_arm_integratorcp.py |  4 ++--
 tests/acceptance/machine_arm_n8x0.py         |  4 ++--
 tests/acceptance/machine_avr6.py             |  4 ++--
 tests/acceptance/machine_m68k_nextcube.py    |  4 ++--
 tests/acceptance/machine_microblaze.py       |  4 ++--
 tests/acceptance/machine_mips_fuloong2e.py   |  4 ++--
 tests/acceptance/machine_mips_loongson3v.py  |  4 ++--
 tests/acceptance/machine_mips_malta.py       |  4 ++--
 tests/acceptance/machine_ppc.py              |  4 ++--
 tests/acceptance/machine_rx_gdbsim.py        |  4 ++--
 tests/acceptance/machine_s390_ccw_virtio.py  |  4 ++--
 tests/acceptance/machine_sparc_leon3.py      |  4 ++--
 tests/acceptance/migration.py                |  4 ++--
 tests/acceptance/multiprocess.py             |  4 ++--
 tests/acceptance/pc_cpu_hotplug_props.py     |  4 ++--
 tests/acceptance/ppc_prep_40p.py             |  4 ++--
 tests/acceptance/version.py                  |  4 ++--
 tests/acceptance/virtio-gpu.py               |  4 ++--
 tests/acceptance/virtio_check_params.py      |  4 ++--
 tests/acceptance/virtio_version.py           |  4 ++--
 tests/acceptance/vnc.py                      |  4 ++--
 tests/acceptance/x86_cpu_model_versions.py   |  4 ++--
 30 files changed, 68 insertions(+), 70 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +9 -12
index a497a24f823..1abec2abaca 100644
@@ -183,7 +183,7 @@ def interrupt_interactive_console_until_pattern(test, success_message,
 
     :param test: an Avocado test containing a VM that will have its console
                  read and probed for a success or failure message
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param success_message: if this message appears, test succeeds
     :param failure_message: if this message appears, test fails
     :param interrupt_string: a string to send to the console before trying
@@ -199,7 +199,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None,
 
     :param test: an Avocado test containing a VM that will have its console
                  read and probed for a success or failure message
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param success_message: if this message appears, test succeeds
     :param failure_message: if this message appears, test fails
     """
@@ -211,7 +211,7 @@ def exec_command(test, command):
     the content.
 
     :param test: an Avocado test containing a VM.
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param command: the command to send
     :type command: str
     """
@@ -226,7 +226,7 @@ def exec_command_and_wait_for_pattern(test, command,
 
     :param test: an Avocado test containing a VM that will have its console
                  read and probed for a success or failure message
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param command: the command to send
     :param success_message: if this message appears, test succeeds
     :param failure_message: if this message appears, test fails
@@ -269,16 +269,13 @@ def fetch_asset(self, name,
                         cancel_on_missing=cancel_on_missing)
 
 
-class Test(QemuBaseTest):
-    """Facilitates system emulation tests.
-
-    TODO: Rename this class as `QemuSystemTest`.
-    """
+class QemuSystemTest(QemuBaseTest):
+    """Facilitates system emulation tests."""
 
     def setUp(self):
         self._vms = {}
 
-        super(Test, self).setUp('qemu-system-')
+        super(QemuSystemTest, self).setUp('qemu-system-')
 
         self.machine = self.params.get('machine',
                                        default=self._get_unique_tag_val('machine'))
@@ -515,11 +512,11 @@ def default_kernel_params(self):
         return self._info.get('kernel_params', None)
 
 
-class LinuxTest(Test, LinuxSSHMixIn):
+class LinuxTest(QemuSystemTest, LinuxSSHMixIn):
     """Facilitates having a cloud-image Linux based available.
 
     For tests that indend to interact with guests, this is a better choice
-    to start with than the more vanilla `Test` class.
+    to start with than the more vanilla `QemuSystemTest` class.
     """
 
     timeout = 900
tests/acceptance/boot_linux_console.py +2 -2
index 0a49c0e2760..80740452f54 100644
@@ -15,7 +15,7 @@
 
 from avocado import skip
 from avocado import skipUnless
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import exec_command
 from avocado_qemu import exec_command_and_wait_for_pattern
 from avocado_qemu import interrupt_interactive_console_until_pattern
@@ -46,7 +46,7 @@ def image_pow2ceil_expand(path):
             with open(path, 'ab+') as fd:
                 fd.truncate(size_aligned)
 
-class LinuxKernelTest(Test):
+class LinuxKernelTest(QemuSystemTest):
     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
 
     def wait_for_console_pattern(self, success_message, vm=None):
tests/acceptance/cpu_queries.py +2 -2
index cc9e380cc7f..cf69f69b116 100644
@@ -8,9 +8,9 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
-class QueryCPUModelExpansion(Test):
+class QueryCPUModelExpansion(QemuSystemTest):
     """
     Run query-cpu-model-expansion for each CPU model, and validate results
     """
tests/acceptance/empty_cpu_model.py +2 -2
index a1e59e45e4e..22f504418d2 100644
@@ -7,9 +7,9 @@
 #
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
-class EmptyCPUModel(Test):
+class EmptyCPUModel(QemuSystemTest):
     def test(self):
         self.vm.add_args('-S', '-display', 'none', '-machine', 'none', '-cpu', '')
         self.vm.set_qmp_monitor(enabled=False)
tests/acceptance/info_usernet.py +2 -2
index 9c1fd903a0b..dc01f74150c 100644
@@ -8,12 +8,12 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
 from qemu.utils import get_info_usernet_hostfwd_port
 
 
-class InfoUsernet(Test):
+class InfoUsernet(QemuSystemTest):
 
     def test_hostfwd(self):
         self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22')
tests/acceptance/linux_initrd.py +2 -2
index a249e2f14a2..25fba6a28a7 100644
@@ -12,11 +12,11 @@
 import logging
 import tempfile
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado import skipIf
 
 
-class LinuxInitrd(Test):
+class LinuxInitrd(QemuSystemTest):
     """
     Checks QEMU evaluates correctly the initrd file passed as -initrd option.
 
tests/acceptance/linux_ssh_mips_malta.py +3 -2
index 4de19474188..c0f0be5adee 100644
@@ -12,7 +12,8 @@
 import time
 
 from avocado import skipUnless
-from avocado_qemu import Test, LinuxSSHMixIn
+from avocado_qemu import LinuxSSHMixIn
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import process
 from avocado.utils import archive
@@ -21,7 +22,7 @@
 
 @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
 @skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available')
-class LinuxSSH(Test, LinuxSSHMixIn):
+class LinuxSSH(QemuSystemTest, LinuxSSHMixIn):
 
     timeout = 150 # Not for 'configure --enable-debug --enable-debug-tcg'
 
tests/acceptance/machine_arm_canona1100.py +2 -2
index 0e5c43dbcf8..182a0b05134 100644
@@ -8,11 +8,11 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import archive
 
-class CanonA1100Machine(Test):
+class CanonA1100Machine(QemuSystemTest):
     """Boots the barebox firmware and checks that the console is operational"""
 
     timeout = 90
tests/acceptance/machine_arm_integratorcp.py +2 -2
index 49c8ebff78b..1ffe1073ef8 100644
@@ -12,7 +12,7 @@
 import logging
 
 from avocado import skipUnless
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 
 
@@ -29,7 +29,7 @@
     CV2_AVAILABLE = False
 
 
-class IntegratorMachine(Test):
+class IntegratorMachine(QemuSystemTest):
 
     timeout = 90
 
tests/acceptance/machine_arm_n8x0.py +2 -2
index e5741f2d8d1..12e9a6803ba 100644
@@ -11,10 +11,10 @@
 import os
 
 from avocado import skipUnless
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 
-class N8x0Machine(Test):
+class N8x0Machine(QemuSystemTest):
     """Boots the Linux kernel and checks that the console is operational"""
 
     timeout = 90
tests/acceptance/machine_avr6.py +2 -2
index 6baf4e9c7f3..7536d83356f 100644
@@ -19,9 +19,9 @@
 
 import time
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
-class AVR6Machine(Test):
+class AVR6Machine(QemuSystemTest):
     timeout = 5
 
     def test_freertos(self):
tests/acceptance/machine_m68k_nextcube.py +2 -2
index 09e2745cc52..6790e7d9cd1 100644
@@ -8,7 +8,7 @@
 import os
 import time
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado import skipUnless
 
 from tesseract_utils import tesseract_available, tesseract_ocr
@@ -20,7 +20,7 @@
     PIL_AVAILABLE = False
 
 
-class NextCubeMachine(Test):
+class NextCubeMachine(QemuSystemTest):
     """
     :avocado: tags=arch:m68k
     :avocado: tags=machine:next-cube
tests/acceptance/machine_microblaze.py +2 -2
index 7f6d18495d8..4928920f960 100644
@@ -5,11 +5,11 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later. See the COPYING file in the top-level directory.
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import archive
 
-class MicroblazeMachine(Test):
+class MicroblazeMachine(QemuSystemTest):
 
     timeout = 90
 
tests/acceptance/machine_mips_fuloong2e.py +2 -2
index 0ac285e2af1..89291f47b24 100644
@@ -10,10 +10,10 @@
 import os
 
 from avocado import skipUnless
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 
-class MipsFuloong2e(Test):
+class MipsFuloong2e(QemuSystemTest):
 
     timeout = 60
 
tests/acceptance/machine_mips_loongson3v.py +2 -2
index 85b131a40f0..5194cf18c9c 100644
@@ -11,10 +11,10 @@
 import time
 
 from avocado import skipUnless
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 
-class MipsLoongson3v(Test):
+class MipsLoongson3v(QemuSystemTest):
     timeout = 60
 
     @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
tests/acceptance/machine_mips_malta.py +2 -2
index b67d8cb141c..f1895d59f35 100644
@@ -12,7 +12,7 @@
 import logging
 
 from avocado import skipUnless
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import archive
 from avocado import skipIf
@@ -33,7 +33,7 @@
 
 @skipUnless(NUMPY_AVAILABLE, 'Python NumPy not installed')
 @skipUnless(CV2_AVAILABLE, 'Python OpenCV not installed')
-class MaltaMachineFramebuffer(Test):
+class MaltaMachineFramebuffer(QemuSystemTest):
 
     timeout = 30
 
tests/acceptance/machine_ppc.py +2 -2
index a836e2496f1..67e24fa4f7c 100644
@@ -6,10 +6,10 @@
 # later.  See the COPYING file in the top-level directory.
 
 from avocado.utils import archive
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 
-class PpcMachine(Test):
+class PpcMachine(QemuSystemTest):
 
     timeout = 90
     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
tests/acceptance/machine_rx_gdbsim.py +2 -2
index 32b737b6d85..6cd8704b016 100644
@@ -11,13 +11,13 @@
 import os
 
 from avocado import skipIf
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import exec_command_and_wait_for_pattern
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import archive
 
 
-class RxGdbSimMachine(Test):
+class RxGdbSimMachine(QemuSystemTest):
 
     timeout = 30
     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
tests/acceptance/machine_s390_ccw_virtio.py +2 -2
index 4028c99afce..bd03d7160b4 100644
@@ -13,12 +13,12 @@
 import tempfile
 
 from avocado import skipIf
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import exec_command_and_wait_for_pattern
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import archive
 
-class S390CCWVirtioMachine(Test):
+class S390CCWVirtioMachine(QemuSystemTest):
     KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
 
     timeout = 120
tests/acceptance/machine_sparc_leon3.py +2 -2
index 2405cd7a0d7..e61b223185a 100644
@@ -5,12 +5,12 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later. See the COPYING file in the top-level directory.
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado import skip
 
 
-class Leon3Machine(Test):
+class Leon3Machine(QemuSystemTest):
 
     timeout = 60
 
tests/acceptance/migration.py +2 -2
index 792639cb693..584d6ef53f5 100644
@@ -11,7 +11,7 @@
 
 
 import tempfile
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado import skipUnless
 
 from avocado.utils import network
@@ -19,7 +19,7 @@
 from avocado.utils.path import find_command
 
 
-class Migration(Test):
+class Migration(QemuSystemTest):
     """
     :avocado: tags=migration
     """
tests/acceptance/multiprocess.py +2 -2
index 96627f022a8..80a3b8f442b 100644
@@ -7,12 +7,12 @@
 import os
 import socket
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado_qemu import exec_command
 from avocado_qemu import exec_command_and_wait_for_pattern
 
-class Multiprocess(Test):
+class Multiprocess(QemuSystemTest):
     """
     :avocado: tags=multiprocess
     """
tests/acceptance/pc_cpu_hotplug_props.py +2 -2
index 2e86d5017a5..52b878188ed 100644
@@ -20,9 +20,9 @@
 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
 #
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
-class OmittedCPUProps(Test):
+class OmittedCPUProps(QemuSystemTest):
     """
     :avocado: tags=arch:x86_64
     :avocado: tags=cpu:qemu64
tests/acceptance/ppc_prep_40p.py +2 -2
index 2993ee3b078..cbcb7d06ad6 100644
@@ -9,11 +9,11 @@
 
 from avocado import skipIf
 from avocado import skipUnless
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 
 
-class IbmPrep40pMachine(Test):
+class IbmPrep40pMachine(QemuSystemTest):
 
     timeout = 60
 
tests/acceptance/version.py +2 -2
index 79b923d4fc0..ded7f039c1b 100644
@@ -9,10 +9,10 @@
 # later.  See the COPYING file in the top-level directory.
 
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
 
-class Version(Test):
+class Version(QemuSystemTest):
     """
     :avocado: tags=quick
     """
tests/acceptance/virtio-gpu.py +2 -2
index 4acc1e6d5fd..2a249a3a2c1 100644
@@ -4,8 +4,8 @@
 # later.  See the COPYING file in the top-level directory.
 
 
-from avocado_qemu import Test
 from avocado_qemu import BUILD_DIR
+from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado_qemu import exec_command_and_wait_for_pattern
 from avocado_qemu import is_readable_executable_file
@@ -27,7 +27,7 @@ def pick_default_vug_bin():
         return bld_dir_path
 
 
-class VirtioGPUx86(Test):
+class VirtioGPUx86(QemuSystemTest):
     """
     :avocado: tags=virtio-gpu
     :avocado: tags=arch:x86_64
tests/acceptance/virtio_check_params.py +2 -2
index 87e6c839d14..e869690473a 100644
@@ -24,7 +24,7 @@
 
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
 from qemu.machine import QEMUMachine
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 from avocado import skip
 
 #list of machine types and virtqueue properties to test
@@ -41,7 +41,7 @@
                                     'driver=null-co,id=drive0,if=none']}
 
 
-class VirtioMaxSegSettingsCheck(Test):
+class VirtioMaxSegSettingsCheck(QemuSystemTest):
     @staticmethod
     def make_pattern(props):
         pattern_items = ['{0} = \w+'.format(prop) for prop in props]
tests/acceptance/virtio_version.py +2 -2
index 33593c29dd0..208910bb844 100644
@@ -13,7 +13,7 @@
 
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
 from qemu.machine import QEMUMachine
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
 # Virtio Device IDs:
 VIRTIO_NET = 1
@@ -55,7 +55,7 @@ def get_pci_interfaces(vm, devtype):
     interfaces = ('pci-express-device', 'conventional-pci-device')
     return [i for i in interfaces if devtype_implements(vm, devtype, i)]
 
-class VirtioVersionCheck(Test):
+class VirtioVersionCheck(QemuSystemTest):
     """
     Check if virtio-version-specific device types result in the
     same device tree created by `disable-modern` and
tests/acceptance/vnc.py +2 -2
index 22656bbcc2b..e6ebdf5d1ee 100644
@@ -8,10 +8,10 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
-from avocado_qemu import Test
+from avocado_qemu import QemuSystemTest
 
 
-class Vnc(Test):
+class Vnc(QemuSystemTest):
     """
     :avocado: tags=vnc,quick
     """
tests/acceptance/x86_cpu_model_versions.py +2 -2
index 0e9feda62d4..a6edf74c1cc 100644
@@ -24,7 +24,7 @@
 import avocado_qemu
 import re
 
-class X86CPUModelAliases(avocado_qemu.Test):
+class X86CPUModelAliases(avocado_qemu.QemuSystemTest):
     """
     Validation of PC CPU model versions and CPU model aliases
 
@@ -239,7 +239,7 @@ def test_none_alias(self):
         self.validate_aliases(cpus)
 
 
-class CascadelakeArchCapabilities(avocado_qemu.Test):
+class CascadelakeArchCapabilities(avocado_qemu.QemuSystemTest):
     """
     Validation of Cascadelake arch-capabilities
 
Signature · 1 line
2.31.1
Reviewed-by on v4 6/6
#14 lore raw

Re: [PATCH v4 6/6] tests/acceptance: Rename avocado_qemu.Test -> QemuSystemTest

Quoted 89 lines · Philippe Mathieu-Daudé

To run user-mode emulation tests, we introduced the avocado_qemu.QemuUserTest which inherits from avocado_qemu.QemuBaseTest. System-mode emulation tests are based on the avocado_qemu.Test class, which also inherits avocado_qemu.QemuBaseTest. To avoid confusion, rename it as avocado_qemu.QemuSystemTest.

---
 tests/acceptance/avocado_qemu/__init__.py    | 21 +++++++++-----------
 tests/acceptance/boot_linux_console.py       |  4 ++--
 tests/acceptance/cpu_queries.py              |  4 ++--
 tests/acceptance/empty_cpu_model.py          |  4 ++--
 tests/acceptance/info_usernet.py             |  4 ++--
 tests/acceptance/linux_initrd.py             |  4 ++--
 tests/acceptance/linux_ssh_mips_malta.py     |  5 +++--
 tests/acceptance/machine_arm_canona1100.py   |  4 ++--
 tests/acceptance/machine_arm_integratorcp.py |  4 ++--
 tests/acceptance/machine_arm_n8x0.py         |  4 ++--
 tests/acceptance/machine_avr6.py             |  4 ++--
 tests/acceptance/machine_m68k_nextcube.py    |  4 ++--
 tests/acceptance/machine_microblaze.py       |  4 ++--
 tests/acceptance/machine_mips_fuloong2e.py   |  4 ++--
 tests/acceptance/machine_mips_loongson3v.py  |  4 ++--
 tests/acceptance/machine_mips_malta.py       |  4 ++--
 tests/acceptance/machine_ppc.py              |  4 ++--
 tests/acceptance/machine_rx_gdbsim.py        |  4 ++--
 tests/acceptance/machine_s390_ccw_virtio.py  |  4 ++--
 tests/acceptance/machine_sparc_leon3.py      |  4 ++--
 tests/acceptance/migration.py                |  4 ++--
 tests/acceptance/multiprocess.py             |  4 ++--
 tests/acceptance/pc_cpu_hotplug_props.py     |  4 ++--
 tests/acceptance/ppc_prep_40p.py             |  4 ++--
 tests/acceptance/version.py                  |  4 ++--
 tests/acceptance/virtio-gpu.py               |  4 ++--
 tests/acceptance/virtio_check_params.py      |  4 ++--
 tests/acceptance/virtio_version.py           |  4 ++--
 tests/acceptance/vnc.py                      |  4 ++--
 tests/acceptance/x86_cpu_model_versions.py   |  4 ++--
 30 files changed, 68 insertions(+), 70 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +4 -7
index a497a24f823..1abec2abaca 100644
@@ -183,7 +183,7 @@ def interrupt_interactive_console_until_pattern(test, success_message,
 
     :param test: an Avocado test containing a VM that will have its console
                  read and probed for a success or failure message
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param success_message: if this message appears, test succeeds
     :param failure_message: if this message appears, test fails
     :param interrupt_string: a string to send to the console before trying
@@ -199,7 +199,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None,
 
     :param test: an Avocado test containing a VM that will have its console
                  read and probed for a success or failure message
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param success_message: if this message appears, test succeeds
     :param failure_message: if this message appears, test fails
     """
@@ -211,7 +211,7 @@ def exec_command(test, command):
     the content.
 
     :param test: an Avocado test containing a VM.
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param command: the command to send
     :type command: str
     """
@@ -226,7 +226,7 @@ def exec_command_and_wait_for_pattern(test, command,
 
     :param test: an Avocado test containing a VM that will have its console
                  read and probed for a success or failure message
-    :type test: :class:`avocado_qemu.Test`
+    :type test: :class:`avocado_qemu.QemuSystemTest`
     :param command: the command to send
     :param success_message: if this message appears, test succeeds
     :param failure_message: if this message appears, test fails
@@ -269,16 +269,13 @@ def fetch_asset(self, name,
                         cancel_on_missing=cancel_on_missing)
 
 
-class Test(QemuBaseTest):
-    """Facilitates system emulation tests.
-

tests/acceptance/avocado_qemu/__init__.py def fetch_asset(self, name, · line 278

Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +3 -3
-    TODO: Rename this class as `QemuSystemTest`.
-    """
+class QemuSystemTest(QemuBaseTest):
+    """Facilitates system emulation tests."""
 
     def setUp(self):
         self._vms = {}
 
-        super(Test, self).setUp('qemu-system-')
+        super(QemuSystemTest, self).setUp('qemu-system-')

If you take my suggestion in one of the previous patches, you don't need this change here.

tests/acceptance/avocado_qemu/__init__.py def default_kernel_params(self): · line 518

Quoted 12 lines
tests/acceptance/avocado_qemu/__init__.py +1 -1
         self.machine = self.params.get('machine',
                                        default=self._get_unique_tag_val('machine'))
@@ -515,11 +512,11 @@ def default_kernel_params(self):
         return self._info.get('kernel_params', None)
 
 
-class LinuxTest(Test, LinuxSSHMixIn):
+class LinuxTest(QemuSystemTest, LinuxSSHMixIn):
     """Facilitates having a cloud-image Linux based available.
 
     For tests that indend to interact with guests, this is a better choice

If you touch this patch again, please, s/indend/intend/

So far, looks good to me

#15 lore raw

Re: [PATCH v4 6/6] tests/acceptance: Rename avocado_qemu.Test -> QemuSystemTest

Quoted 51 lines · Willian Rampazzo
Quoted 50 lines · Philippe Mathieu-Daudé

To run user-mode emulation tests, we introduced the avocado_qemu.QemuUserTest which inherits from avocado_qemu.QemuBaseTest. System-mode emulation tests are based on the avocado_qemu.Test class, which also inherits avocado_qemu.QemuBaseTest. To avoid confusion, rename it as avocado_qemu.QemuSystemTest.

---
 tests/acceptance/avocado_qemu/__init__.py    | 21 +++++++++-----------
 tests/acceptance/boot_linux_console.py       |  4 ++--
 tests/acceptance/cpu_queries.py              |  4 ++--
 tests/acceptance/empty_cpu_model.py          |  4 ++--
 tests/acceptance/info_usernet.py             |  4 ++--
 tests/acceptance/linux_initrd.py             |  4 ++--
 tests/acceptance/linux_ssh_mips_malta.py     |  5 +++--
 tests/acceptance/machine_arm_canona1100.py   |  4 ++--
 tests/acceptance/machine_arm_integratorcp.py |  4 ++--
 tests/acceptance/machine_arm_n8x0.py         |  4 ++--
 tests/acceptance/machine_avr6.py             |  4 ++--
 tests/acceptance/machine_m68k_nextcube.py    |  4 ++--
 tests/acceptance/machine_microblaze.py       |  4 ++--
 tests/acceptance/machine_mips_fuloong2e.py   |  4 ++--
 tests/acceptance/machine_mips_loongson3v.py  |  4 ++--
 tests/acceptance/machine_mips_malta.py       |  4 ++--
 tests/acceptance/machine_ppc.py              |  4 ++--
 tests/acceptance/machine_rx_gdbsim.py        |  4 ++--
 tests/acceptance/machine_s390_ccw_virtio.py  |  4 ++--
 tests/acceptance/machine_sparc_leon3.py      |  4 ++--
 tests/acceptance/migration.py                |  4 ++--
 tests/acceptance/multiprocess.py             |  4 ++--
 tests/acceptance/pc_cpu_hotplug_props.py     |  4 ++--
 tests/acceptance/ppc_prep_40p.py             |  4 ++--
 tests/acceptance/version.py                  |  4 ++--
 tests/acceptance/virtio-gpu.py               |  4 ++--
 tests/acceptance/virtio_check_params.py      |  4 ++--
 tests/acceptance/virtio_version.py           |  4 ++--
 tests/acceptance/vnc.py                      |  4 ++--
 tests/acceptance/x86_cpu_model_versions.py   |  4 ++--
 30 files changed, 68 insertions(+), 70 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +2 -5
-class Test(QemuBaseTest):
-    """Facilitates system emulation tests.
-
-    TODO: Rename this class as `QemuSystemTest`.
-    """
+class QemuSystemTest(QemuBaseTest):
+    """Facilitates system emulation tests."""
Quoted 8 lines

tests/acceptance/avocado_qemu/__init__.py def fetch_asset(self, name, · line 278

Quoted 5 lines
     def setUp(self):
         self._vms = {}
tests/acceptance/avocado_qemu/__init__.py +1 -1
-        super(Test, self).setUp('qemu-system-')
+        super(QemuSystemTest, self).setUp('qemu-system-')

If you take my suggestion in one of the previous patches, you don't need this change here.

Indeed.

Quoted 7 lines
Quoted 7 lines

self.machine = self.params.get('machine',
default=self._get_unique_tag_val('machine'))

tests/acceptance/avocado_qemu/__init__.py +0 -0
@@ -515,11 +512,11 @@ def default_kernel_params(self):
         return self._info.get('kernel_params', None)
 
 
Quoted 7 lines

tests/acceptance/avocado_qemu/__init__.py def default_kernel_params(self): · line 518

Quoted 5 lines
tests/acceptance/avocado_qemu/__init__.py +1 -1
-class LinuxTest(Test, LinuxSSHMixIn):
+class LinuxTest(QemuSystemTest, LinuxSSHMixIn):
     """Facilitates having a cloud-image Linux based available.
 
     For tests that indend to interact with guests, this is a better choice

If you touch this patch again, please, s/indend/intend/

OK.

Quoted 4 lines

So far, looks good to me

Thanks for reviewing the series :)

#16 lore raw
In reply to Philippe Mathieu-Daudé

Almost one month passed... ping?

(adding Cleber who wasn't Cc'ed)

Quoted 53 lines · Philippe Mathieu-Daudé

Since v3:
- rebased
- addressed Wainer review comments from v2
- rename avocado_qemu.Test -> QemuSystemTest

Since v2:
- rebased tests/acceptance/avocado_qemu/__init__.py patches
- extract has_cmd() from virtiofs_submounts.py
- check cpio availability with has_cmd()

Philippe Mathieu-Daudé (6):
tests/acceptance: Extract QemuBaseTest from Test tests/acceptance: Make pick_default_qemu_bin() more generic tests/acceptance: Introduce QemuUserTest base class tests/acceptance: Share useful helpers from virtiofs_submounts test tests/acceptance: Add bFLT loader linux-user test tests/acceptance: Rename avocado_qemu.Test -> QemuSystemTest

 tests/acceptance/avocado_qemu/__init__.py    | 158 ++++++++++++++-----
 tests/acceptance/boot_linux_console.py       |   4 +-
 tests/acceptance/cpu_queries.py              |   4 +-
 tests/acceptance/empty_cpu_model.py          |   4 +-
 tests/acceptance/info_usernet.py             |   4 +-
 tests/acceptance/linux_initrd.py             |   4 +-
 tests/acceptance/linux_ssh_mips_malta.py     |   5 +-
 tests/acceptance/load_bflt.py                |  54 +++++++
 tests/acceptance/machine_arm_canona1100.py   |   4 +-
 tests/acceptance/machine_arm_integratorcp.py |   4 +-
 tests/acceptance/machine_arm_n8x0.py         |   4 +-
 tests/acceptance/machine_avr6.py             |   4 +-
 tests/acceptance/machine_m68k_nextcube.py    |   4 +-
 tests/acceptance/machine_microblaze.py       |   4 +-
 tests/acceptance/machine_mips_fuloong2e.py   |   4 +-
 tests/acceptance/machine_mips_loongson3v.py  |   4 +-
 tests/acceptance/machine_mips_malta.py       |   4 +-
 tests/acceptance/machine_ppc.py              |   4 +-
 tests/acceptance/machine_rx_gdbsim.py        |   4 +-
 tests/acceptance/machine_s390_ccw_virtio.py  |   4 +-
 tests/acceptance/machine_sparc_leon3.py      |   4 +-
 tests/acceptance/migration.py                |   4 +-
 tests/acceptance/multiprocess.py             |   4 +-
 tests/acceptance/pc_cpu_hotplug_props.py     |   4 +-
 tests/acceptance/ppc_prep_40p.py             |   4 +-
 tests/acceptance/version.py                  |   4 +-
 tests/acceptance/virtio-gpu.py               |   4 +-
 tests/acceptance/virtio_check_params.py      |   4 +-
 tests/acceptance/virtio_version.py           |   4 +-
 tests/acceptance/virtiofs_submounts.py       |  59 +------
 tests/acceptance/vnc.py                      |   4 +-
 tests/acceptance/x86_cpu_model_versions.py   |   4 +-
 32 files changed, 235 insertions(+), 153 deletions(-)
 create mode 100644 tests/acceptance/load_bflt.py