[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 1/2] tests/acceptance: move pkg extraction to avocado_qemu
From: |
Cleber Rosa |
Subject: |
Re: [PATCH v1 1/2] tests/acceptance: move pkg extraction to avocado_qemu/ |
Date: |
Tue, 13 Jul 2021 14:05:59 -0400 |
User-agent: |
mu4e 1.4.15; emacs 27.2 |
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
- Re: [PATCH v1 1/2] tests/acceptance: move pkg extraction to avocado_qemu/,
Cleber Rosa <=