From: Thomas Huth <thuth@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>
Subject: [PATCH 1/2] tests/functional: Add the LinuxKernelTest for testing the Linux boot process
Date: Tue, 27 Aug 2024 14:31:06 +0200 [thread overview]
Message-ID: <20240827123107.34475-2-thuth@redhat.com> (raw)
In-Reply-To: <20240827123107.34475-1-thuth@redhat.com>
Copy the LinuxKernelTest from tests/acceptance/boot_linux_console.py
to be able to convert the related tests to the functional test framework
in the following patches.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/qemu_test/__init__.py | 1 +
tests/functional/qemu_test/linuxkernel.py | 41 +++++++++++++++++++++++
2 files changed, 42 insertions(+)
create mode 100644 tests/functional/qemu_test/linuxkernel.py
diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
index db05c8f412..4e7268c58d 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -12,3 +12,4 @@
interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
exec_command, exec_command_and_wait_for_pattern
from .testcase import QemuSystemTest, QemuBaseTest
+from .linuxkernel import LinuxKernelTest
diff --git a/tests/functional/qemu_test/linuxkernel.py b/tests/functional/qemu_test/linuxkernel.py
new file mode 100644
index 0000000000..fdd5307629
--- /dev/null
+++ b/tests/functional/qemu_test/linuxkernel.py
@@ -0,0 +1,41 @@
+# Test class for testing the boot process of a Linux kernel
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import os
+
+from .testcase import QemuSystemTest
+from .cmd import run_cmd, wait_for_console_pattern
+from .utils import archive_extract
+
+class LinuxKernelTest(QemuSystemTest):
+ KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
+
+ def wait_for_console_pattern(self, success_message, vm=None):
+ wait_for_console_pattern(self, success_message,
+ failure_message='Kernel panic - not syncing',
+ vm=vm)
+
+ def extract_from_deb(self, deb_path, path):
+ """
+ Extracts a file from a deb package into the test workdir
+
+ :param deb_path: 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(self.workdir)
+ (stdout, stderr, ret) = run_cmd(['ar', 't', deb_path])
+ file_path = stdout.split()[2]
+ run_cmd(['ar', 'x', deb_path, file_path])
+ archive_extract(file_path, self.workdir)
+ os.chdir(cwd)
+ # Return complete path to extracted file. Because callers to
+ # extract_from_deb() specify 'path' with a leading slash, it is
+ # necessary to use os.path.relpath() as otherwise os.path.join()
+ # interprets it as an absolute path and drops the self.workdir part.
+ return os.path.normpath(os.path.join(self.workdir,
+ os.path.relpath(path, '/')))
+
--
2.46.0
next prev parent reply other threads:[~2024-08-27 12:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 22:10 [PATCH 0/4] tests/functional: Convert Raspberry Pi avocado tests Philippe Mathieu-Daudé
2024-08-26 22:10 ` [PATCH 1/4] tests/functional: Add a class containing Linux kernel helpers Philippe Mathieu-Daudé
2024-08-27 5:34 ` Thomas Huth
2024-08-27 9:21 ` Philippe Mathieu-Daudé
2024-08-27 12:29 ` Thomas Huth
2024-08-27 12:31 ` [PATCH 0/2] tests/functional: Add LinuxKernelTest class and convert Q800 test Thomas Huth
2024-08-27 12:31 ` Thomas Huth [this message]
2024-08-27 12:31 ` [PATCH 2/2] tests/functional: Convert the m68k Q800 Avocado test into a functional test Thomas Huth
2024-08-26 22:10 ` [PATCH 2/4] tests/functional: Convert ARM Raspi2 avocado tests Philippe Mathieu-Daudé
2024-08-26 22:10 ` [PATCH 3/4] tests/functional: Convert Aarch64 Raspi3 " Philippe Mathieu-Daudé
2024-08-26 22:10 ` [PATCH 4/4] tests/functional: Convert Aarch64 Raspi4 " Philippe Mathieu-Daudé
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=20240827123107.34475-2-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=laurent@vivier.eu \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).