qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
To: Cleber Rosa <crosa@redhat.com>
Cc: qemu-devel@nongnu.org, "Fam Zheng" <famz@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Laszlo Ersek" <lersek@redhat.com>,
	"Philippe Mathieu-Daudé" <pmathieu@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Caio Carrara" <ccarrara@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 2/7] Acceptance Tests: introduce arch parameter and attribute
Date: Thu, 4 Oct 2018 20:56:02 -0300	[thread overview]
Message-ID: <20181004235602.GA24920@kermit-br-ibm-com> (raw)
In-Reply-To: <20181004151429.7232-3-crosa@redhat.com>

Hi, Cleber.

On Thu, Oct 04, 2018 at 11:14:24AM -0400, Cleber Rosa wrote:
> On a number of different scenarios, such as when choosing a QEMU
> binary to be used on tests (or a image to use to boot a test VM), it's
> useful to define the architecture that should be used.
>
> This introduces both a test parameter and a test instance attribute,
> that will contain such a value.
>
> The selection of the default QEMU binary, if one is not given
> explicitly, has also been changed to look at the arch attribute.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>  docs/devel/testing.rst                    | 18 ++++++++++++++++++
>  tests/acceptance/avocado_qemu/__init__.py | 13 ++++++++++---
>  2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
> index 727c4019b5..4178ae5022 100644
> --- a/docs/devel/testing.rst
> +++ b/docs/devel/testing.rst
> @@ -659,6 +659,17 @@ vm
>  A QEMUMachine instance, initially configured according to the given
>  ``qemu_bin`` parameter.
>
> +arch
> +~~~~
> +
> +The architecture that will be used on a number of different
> +scenarios.  For instance, when a QEMU binary is not explicitly given,
> +the one selected will depend on this attribute.
> +
> +The ``arch`` attribute will be set to the test parameter of the same
> +name, and if one is not given explicitly, it will default to the
> +system architecture (as given by ``uname``).
> +
>  qemu_bin
>  ~~~~~~~~
>
> @@ -681,6 +692,13 @@ like the following:
>
>    PARAMS (key=qemu_bin, path=*, default=x86_64-softmmu/qemu-system-x86_64) => 'x86_64-softmmu/qemu-system-x86_64
>
> +arch
> +~~~~
> +
> +The architecture that will be used on a number of different scenarios.
> +This parameter has a direct relation with the ``arch`` attribute.  If
> +not given, it will default to None.
> +
>  qemu_bin
>  ~~~~~~~~
>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index d8d5b48dac..9329d9b9ec 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -23,16 +23,22 @@ 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=None):
>      """
>      Picks the path of a QEMU binary, starting either in the current working
>      directory or in the source tree root directory.
>
> +    :param arch: the arch to use when looking for a QEMU binary (the target
> +                 will match the arch given).  If None (the default) arch
> +                 will be the current host system arch (as given by
> +                 :func:`os.uname`).
> +    :param arch: str

Do you mean

    :type arch: str

?

>      :returns: the path to the default QEMU binary or None if one could not
>                be found
>      :rtype: str or None
>      """
> -    arch = os.uname()[4]
> +    if arch is None:
> +        arch = os.uname()[4]
>      qemu_bin_relative_path = os.path.join("%s-softmmu" % arch,
>                                            "qemu-system-%s" % arch)

On ppc64le systems, this can lead to an unexisting path.

For instance, os.uname() returns:

    >>> os.uname()
    ('Linux', 'localhost', '4.15.0-34-generic', '#37-Ubuntu SMP Mon Aug 27 15:18:58 UTC 2018', 'ppc64le')

Then, qemu_bin_relative_path would be set to:

    ppc64le-softmmu/qemu-system-ppc64le

However, the correct path is:

    ppc64-softmmu/qemu-system-ppc64

I'm not sure if ppc64le is the only case where the target name is different from
the OS architecture.

If you decide not to handle this now, at least add a FIXME, if possible.

>      if is_readable_executable_file(qemu_bin_relative_path):
> @@ -47,8 +53,9 @@ def pick_default_qemu_bin():
>  class Test(avocado.Test):
>      def setUp(self):
>          self.vm = None
> +        self.arch = self.params.get('arch', default=os.uname()[4])
>          self.qemu_bin = self.params.get('qemu_bin',
> -                                        default=pick_default_qemu_bin())
> +                                        default=pick_default_qemu_bin(self.arch))
>          if self.qemu_bin is None:
>              self.cancel("No QEMU binary defined or found in the source tree")
>          self.vm = QEMUMachine(self.qemu_bin)
> --
> 2.17.1
>
>

--
Murilo

  reply	other threads:[~2018-10-04 23:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 15:14 [Qemu-devel] [PATCH 0/7] Acceptance Tests: basic architecture support Cleber Rosa
2018-10-04 15:14 ` [Qemu-devel] [PATCH 1/7] Acceptance Tests: improve docstring on pick_default_qemu_bin() Cleber Rosa
2018-10-05 15:24   ` Philippe Mathieu-Daudé
2018-10-04 15:14 ` [Qemu-devel] [PATCH 2/7] Acceptance Tests: introduce arch parameter and attribute Cleber Rosa
2018-10-04 23:56   ` Murilo Opsfelder Araujo [this message]
2018-10-10 13:16     ` Cleber Rosa
2018-10-04 15:14 ` [Qemu-devel] [PATCH 3/7] scripts/qemu.py: add method and private attribute for arch Cleber Rosa
2018-10-05 15:28   ` Philippe Mathieu-Daudé
2018-10-04 15:14 ` [Qemu-devel] [PATCH 4/7] scripts/qemu.py: set predefined machine type based on arch Cleber Rosa
2018-10-04 15:14 ` [Qemu-devel] [PATCH 5/7] Acceptance Tests: set machine type Cleber Rosa
2018-10-05 15:42   ` Philippe Mathieu-Daudé
2018-10-09 23:08     ` Cleber Rosa
2018-10-04 15:14 ` [Qemu-devel] [PATCH 6/7] Acceptance Tests: add variants definition for architectures Cleber Rosa
2018-10-04 16:48   ` Laszlo Ersek
2018-10-05 16:24   ` Philippe Mathieu-Daudé
2018-10-05 16:32     ` Eric Blake
2018-10-05 17:07       ` Cleber Rosa
2018-10-05 17:30         ` Philippe Mathieu-Daudé
2018-10-05 17:34           ` Cleber Rosa
2018-10-04 15:14 ` [Qemu-devel] [PATCH 7/7] Acceptance Tests: change the handling of tests for specific archs Cleber Rosa
2018-10-04 15:42   ` Philippe Mathieu-Daudé
2018-10-04 15:48     ` Cleber Rosa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181004235602.GA24920@kermit-br-ibm-com \
    --to=muriloo@linux.ibm.com \
    --cc=alex.bennee@linaro.org \
    --cc=ccarrara@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=famz@redhat.com \
    --cc=lersek@redhat.com \
    --cc=pmathieu@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).