qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wainer dos Santos Moschetta <wainersm@redhat.com>
To: Cleber Rosa <crosa@redhat.com>, qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Willian Rampazzo" <wrampazz@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Beraldo Leal" <bleal@redhat.com>
Subject: Re: [PATCH v9 1/3] Acceptance tests: introduce BUILD_DIR and SOURCE_DIR
Date: Thu, 20 Feb 2020 10:31:45 -0300	[thread overview]
Message-ID: <38105bbf-a9d2-24d9-e979-3b93bc110918@redhat.com> (raw)
In-Reply-To: <20200220020652.16276-2-crosa@redhat.com>


On 2/19/20 11:06 PM, Cleber Rosa wrote:
> Some tests may benefit from using resources from a build directory.
> This introduces three variables that can help tests find resources in
> those directories.
>
> First, a BUILD_DIR is assumed to exist, given that the primary form of
> running the acceptance tests is from a build directory (which may or
> may not be the same as the source tree, that is, the SOURCE_DIR).
>
> If the directory containing the acceptance tests happens to be a link
> to a directory, it's assumed to it points to the source tree
> (SOURCE_DIR), which is the behavior defined on the QEMU Makefiles.  If
> the directory containing the acceptance tests is not a link, then a
> in-tree build is assumed, and the BUILD_DIR and SOURCE_DIR have the
> same value.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>   tests/acceptance/avocado_qemu/__init__.py | 25 +++++++++++++++++------
>   1 file changed, 19 insertions(+), 6 deletions(-)


Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>

Also tested with QEMU built outside of source dir:

Tested-by: Wainer dos Santos Moschetta <wainersm@redhat.com>

>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index d4358eb431..59e7b4f763 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -16,8 +16,21 @@ import tempfile
>   
>   import avocado
>   
> -SRC_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..', '..')
> -sys.path.append(os.path.join(SRC_ROOT_DIR, 'python'))
> +#: The QEMU build root directory.  It may also be the source directory
> +#: if building from the source dir, but it's safer to use BUILD_DIR for
> +#: that purpose.  Be aware that if this code is moved outside of a source
> +#: and build tree, it will not be accurate.
> +BUILD_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
> +
> +if os.path.islink(os.path.dirname(os.path.dirname(__file__))):
> +    # The link to the acceptance tests dir in the source code directory
> +    lnk = os.path.dirname(os.path.dirname(__file__))
> +    #: The QEMU root source directory
> +    SOURCE_DIR = os.path.dirname(os.path.dirname(os.readlink(lnk)))
> +else:
> +    SOURCE_DIR = BUILD_DIR
> +
> +sys.path.append(os.path.join(SOURCE_DIR, 'python'))
>   
>   from qemu.machine import QEMUMachine
>   
> @@ -49,10 +62,10 @@ def pick_default_qemu_bin(arch=None):
>       if is_readable_executable_file(qemu_bin_relative_path):
>           return qemu_bin_relative_path
>   
> -    qemu_bin_from_src_dir_path = os.path.join(SRC_ROOT_DIR,
> +    qemu_bin_from_bld_dir_path = os.path.join(BUILD_DIR,
>                                                 qemu_bin_relative_path)
> -    if is_readable_executable_file(qemu_bin_from_src_dir_path):
> -        return qemu_bin_from_src_dir_path
> +    if is_readable_executable_file(qemu_bin_from_bld_dir_path):
> +        return qemu_bin_from_bld_dir_path
>   
>   
>   def _console_interaction(test, success_message, failure_message,
> @@ -153,7 +166,7 @@ class Test(avocado.Test):
>           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 source tree")
> +            self.cancel("No QEMU binary defined or found in the build tree")
>   
>       def _new_vm(self, *args):
>           vm = QEMUMachine(self.qemu_bin, sock_dir=tempfile.mkdtemp())



  reply	other threads:[~2020-02-20 13:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20  2:06 [PATCH v9 0/3] Acceptance test: Add "boot_linux" acceptance test Cleber Rosa
2020-02-20  2:06 ` [PATCH v9 1/3] Acceptance tests: introduce BUILD_DIR and SOURCE_DIR Cleber Rosa
2020-02-20 13:31   ` Wainer dos Santos Moschetta [this message]
2020-02-20  2:06 ` [PATCH v9 2/3] Acceptance test: add "boot_linux" tests Cleber Rosa
2020-02-20 16:49   ` Wainer dos Santos Moschetta
2020-02-20 19:52     ` Cleber Rosa
2020-02-24  9:25       ` Andrew Jones
2020-02-20  2:06 ` [PATCH v9 3/3] Acceptance tests: add make targets to download images Cleber Rosa
2020-02-20 15:43 ` [PATCH v9 0/3] Acceptance test: Add "boot_linux" acceptance test 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=38105bbf-a9d2-24d9-e979-3b93bc110918@redhat.com \
    --to=wainersm@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=fam@euphon.net \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wrampazz@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).