qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v2 1/6] avocado: Add a Test.arch property


From: Alex Bennée
Subject: Re: [Qemu-devel] [RFC PATCH v2 1/6] avocado: Add a Test.arch property
Date: Thu, 28 Jun 2018 17:10:42 +0100
User-agent: mu4e 1.1.0; emacs 26.1.50

Philippe Mathieu-Daudé <address@hidden> writes:

> Tests can change this property to run tests in other
> architectures than the host one.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
>  tests/acceptance/avocado_qemu/__init__.py | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py 
> b/tests/acceptance/avocado_qemu/__init__.py
> index 1e54fd5932..6e9601f5e9 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -13,6 +13,7 @@ import sys
>
>  import avocado
>
> +HOST_ARCH = os.uname()[4]

The python docs seem to point to platform as a more stable way of
querying this stuff:

  platform.machine() => 'x86_64' or 'aarch64'

>  SRC_ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
>  SRC_ROOT_DIR = os.path.abspath(os.path.dirname(SRC_ROOT_DIR))
>  sys.path.append(os.path.join(SRC_ROOT_DIR, 'scripts'))
> @@ -23,12 +24,11 @@ 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():
> +def pick_default_qemu_bin(arch):
>      """
>      Picks the path of a QEMU binary, starting either in the current working
>      directory or in the source tree root directory.
>      """
> -    arch = os.uname()[4]
>      qemu_bin_relative_path = os.path.join("%s-softmmu" % arch,
>                                            "qemu-system-%s" % arch)
>      if is_readable_executable_file(qemu_bin_relative_path):
> @@ -41,10 +41,19 @@ def pick_default_qemu_bin():
>
>
>  class Test(avocado.Test):
> +    _arch = HOST_ARCH
> +
> +    @property
> +    def arch(self):
> +        """
> +        Returns the architecture required to run the current test
> +        """
> +        return self._arch
> +
>      def setUp(self):
>          self.vm = None
> -        self.qemu_bin = self.params.get('qemu_bin',
> -                                        default=pick_default_qemu_bin())
> +        qemu_bin = pick_default_qemu_bin(self.arch)
> +        self.qemu_bin = self.params.get('qemu_bin', default=qemu_bin)
>          if self.qemu_bin is None:
>              self.cancel("No QEMU binary defined or found in the source tree")
>          self.vm = QEMUMachine(self.qemu_bin)


--
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]