All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cleber Rosa <crosa@redhat.com>
To: Claudio Fontana <cfontana@suse.de>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>
Subject: Re: [PATCH v1 1/2] tests/acceptance: move pkg extraction to avocado_qemu/
Date: Tue, 13 Jul 2021 14:05:59 -0400	[thread overview]
Message-ID: <87sg0iytq0.fsf@p50.localhost.localdomain> (raw)
In-Reply-To: <20210604180945.9330-2-cfontana@suse.de>


Claudio Fontana writes:

> currently these utility functions are present only in boot_linux_console.py,
> but they are useful in general, not just for linux.
>
> In order to reuse them for a firmware test with OVMF, make these functions
> general utility functions inside avocado_qemu/ , from where we will
> punctually import them.
>
> Signed-off-by: Claudio Fontana <cfontana@suse.de>
> ---
>  tests/acceptance/avocado_qemu/__init__.py |  38 ++++++++
>  tests/acceptance/boot_linux_console.py    | 104 +++++++---------------
>  tests/acceptance/boot_xen.py              |   7 +-
>  tests/acceptance/replay_kernel.py         |  23 ++---
>  tests/acceptance/tcg_plugins.py           |   5 +-
>  5 files changed, 91 insertions(+), 86 deletions(-)
>
> diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
> index 83b1741ec8..f625eb1ab7 100644
> --- a/tests/acceptance/avocado_qemu/__init__.py
> +++ b/tests/acceptance/avocado_qemu/__init__.py
> @@ -21,6 +21,7 @@
>  from avocado.utils import datadrainer
>  from avocado.utils import network
>  from avocado.utils import vmimage
> +from avocado.utils import process

It's also missing:

   from avocado.utils import archive

Because it's used...

>  from avocado.utils.path import find_command
>  
>  
> @@ -140,6 +141,43 @@ def wait_for_console_pattern(test, success_message, failure_message=None,
>      """
>      _console_interaction(test, success_message, failure_message, None, vm=vm)
>  
> +def extract_from_deb(test, deb, path):
> +    """
> +    Extracts a file from a deb package into the test workdir
> +
> +    :param deb: path to the deb archive
> +    :param path: path within the deb archive of the file to be extracted
> +    :returns: path of the extracted file
> +    """
> +    cwd = os.getcwd()
> +    os.chdir(test.workdir)
> +    file_path = process.run("ar t %s" % deb).stdout_text.split()[2]
> +    process.run("ar x %s %s" % (deb, file_path))
> +    archive.extract(file_path, test.workdir)

... here.

Also there are some missing changes for other tests using
extract_from_(deb|rpm), such as:

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 55ce7a5870..1caea29d27 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -92,7 +92,7 @@ def test_mips_malta(self):
                    'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
         deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
         deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
-        kernel_path = extract_from_deb(deb_path,
+        kernel_path = extract_from_deb(self, deb_path,
                                        '/boot/vmlinux-2.6.32-5-4kc-malta')
 
         self.vm.set_console()

I've seen the same or similar problems for other tests:

   tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_malta: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s)
   tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips64el_malta: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s)
   tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips64el_fuloong2e: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s)
   tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_malta_cpio: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s)
   tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd:
   ERROR: 'BootLinuxConsole' object has no attribute 'extract_from_deb'
   (0.03 s)


Having said that, since Avocado 89.0[1] there is a new API[2] that
should be able to handle both deb and rpm extractions.

I'll try to post a suggestion based on that API here... unless you beat
me to it. :)

Thanks,
- Cleber.

[1] - https://avocado-framework.readthedocs.io/en/89.0/releases/89_0.html#utility-apis
[2] - https://avocado-framework.readthedocs.io/en/89.0/api/utils/avocado.utils.software_manager.html#avocado.utils.software_manager.SoftwareManager.extract_from_package



  reply	other threads:[~2021-07-13 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04 18:09 [PATCH v1 0/2] add x86 acceptance test for the "host" cpu bug Claudio Fontana
2021-06-04 18:09 ` [PATCH v1 1/2] tests/acceptance: move pkg extraction to avocado_qemu/ Claudio Fontana
2021-07-13 18:05   ` Cleber Rosa [this message]
2021-07-14  7:39     ` Claudio Fontana
2021-06-04 18:09 ` [PATCH v1 2/2] tests/acceptance: add OVMF firmware test to cover x86_64 "host" cpu bug Claudio Fontana
2021-06-04 19:12   ` Eduardo Habkost
2021-06-22  6:47     ` Claudio Fontana

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=87sg0iytq0.fsf@p50.localhost.localdomain \
    --to=crosa@redhat.com \
    --cc=cfontana@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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.