diff mbox series

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

Message ID 20210927163116.1998349-3-f4bug@amsat.org
State New
Headers show
Series tests/acceptance: Add bFLT loader linux-user test | expand

Commit Message

Philippe Mathieu-Daudé Sept. 27, 2021, 4:31 p.m. UTC
Make pick_default_qemu_bin() generic to find qemu-system or
qemu-user binaries.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/avocado_qemu/__init__.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Willian Rampazzo Nov. 1, 2021, 6:52 p.m. UTC | #1
On Mon, Sep 27, 2021 at 1:31 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Make pick_default_qemu_bin() generic to find qemu-system or
> qemu-user binaries.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/acceptance/avocado_qemu/__init__.py | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index 8fcbed74849..2b9b5dd27fe 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -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-')

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

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

Anyway,

Reviewed-by: Willian Rampazzo <willianr@redhat.com>

>
>          self.machine = self.params.get('machine',
>                                         default=self._get_unique_tag_val('machine'))
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 8fcbed74849..2b9b5dd27fe 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -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'))