All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willian Rampazzo <wrampazz@redhat.com>
To: Cleber Rosa <crosa@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Fam Zheng" <fam@euphon.net>,
	"Thomas Huth" <thuth@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	qemu-block@nongnu.org, "Erik Skultety" <eskultet@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"John Snow" <jsnow@redhat.com>,
	"Andrea Bolognani" <abologna@redhat.com>,
	"Stefan Hajnoczi" <stefanha@gmail.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Beraldo Leal" <bleal@redhat.com>
Subject: Re: [PATCH 3/4] Acceptance Tests: introduce method to require a feature and option
Date: Thu, 10 Jun 2021 16:46:52 -0300	[thread overview]
Message-ID: <CAKJDGDbJ+9sC0QsbNFYMOjPunQ2fD7jybja6REgZafG4j7sjgg@mail.gmail.com> (raw)
In-Reply-To: <20210608140938.863580-4-crosa@redhat.com>

On Tue, Jun 8, 2021 at 11:09 AM Cleber Rosa <crosa@redhat.com> wrote:
>
> In this context, and according to the qemu.utils.list_feature() utility
> function, a feature is something is available as a QEMU command line
> option that can take the "help" value.
>
> This builds on top of that utility function, and allows test writers
> to require, for instance, the "x-remote" (option) machine type
> (feature).
>
> This example is actually applied here to the reespective test, given
> that the option is conditionally built, and the test will ERROR
> without it.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>  tests/acceptance/avocado_qemu/__init__.py | 29 ++++++++++++++++++++++-
>  tests/acceptance/multiprocess.py          |  1 +
>  2 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index 93c4b9851f..432caff4e6 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -11,6 +11,7 @@
>  import logging
>  import os
>  import shutil
> +import subprocess
>  import sys
>  import uuid
>  import tempfile
> @@ -45,7 +46,8 @@
>  from qemu.utils import (
>      get_info_usernet_hostfwd_port,
>      kvm_available,
> -    tcg_available,
> +    list_feature,
> +    tcg_available
>  )
>
>  def is_readable_executable_file(path):
> @@ -182,6 +184,31 @@ def _get_unique_tag_val(self, tag_name):
>              return vals.pop()
>          return None
>
> +    def require_feature(self, feature, option=None):
> +        """
> +        Requires a feature to be available for the test to continue
> +
> +        It takes into account the currently set qemu binary, and only checks
> +        for by running a "qemu -$feature help" command.  If the specific option
> +        is given, it checks if it's listed for the given feature.
> +
> +        If the check fails, the test is canceled.
> +
> +        :param feature: name of a QEMU feature, such as "accel" or "machine"
> +        :type feature: str
> +        :param option: the specific value for the feature.  For instance,
> +                       if feature is "machine", option can be "q35".
> +        type option: str
> +        """
> +        try:
> +            options_available = list_feature(self.qemu_bin, feature)

Looking at this code, the previous patch makes more sense the way it is now :)

Maybe, splitting it into multiple `list_` functions will make the code
here more complex.

Anyway, I'll let you decide.

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



  reply	other threads:[~2021-06-10 19:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 14:09 [PATCH 0/4] Jobs based on custom runners: add CentOS Stream 8 Cleber Rosa
2021-06-08 14:09 ` [PATCH 1/4] block.c: fix compilation error on possible unitialized variable Cleber Rosa
2021-06-09  7:08   ` Thomas Huth
2021-06-08 14:09 ` [PATCH 2/4] Python QEMU utils: introduce a generic feature list Cleber Rosa
2021-06-08 21:42   ` Wainer dos Santos Moschetta
2021-06-08 23:55     ` Cleber Rosa Junior
2021-06-10 19:39       ` Willian Rampazzo
2021-06-10 20:31       ` Wainer dos Santos Moschetta
2021-06-10 19:48   ` Willian Rampazzo
2021-06-22 15:43   ` John Snow
2021-06-08 14:09 ` [PATCH 3/4] Acceptance Tests: introduce method to require a feature and option Cleber Rosa
2021-06-10 19:46   ` Willian Rampazzo [this message]
2021-06-08 14:09 ` [PATCH 4/4] Jobs based on custom runners: add CentOS Stream 8 Cleber Rosa
2021-06-09 20:37   ` Cleber Rosa Junior
2021-06-10 19:27   ` Willian Rampazzo
2021-06-10 18:40 ` [PATCH 0/4] " Willian Rampazzo

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=CAKJDGDbJ+9sC0QsbNFYMOjPunQ2fD7jybja6REgZafG4j7sjgg@mail.gmail.com \
    --to=wrampazz@redhat.com \
    --cc=abologna@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=eskultet@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=fam@euphon.net \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=thuth@redhat.com \
    --cc=wainersm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.