From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 4/5] test: py: add more kernel boot tests
Date: Fri, 9 Jan 2026 17:57:30 +0100 [thread overview]
Message-ID: <20260109170007.805177-5-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260109170007.805177-1-a.fatoum@barebox.org>
We have one boot test for a Debian kernel via GRUB. The kernel in this
same image can be EFI booted directly thanks to its EFI stub and it can
be even booted without EFI at all via the normal boot protocol.
Add a test exercising both.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
test/arm/multi_v8_efiloader_defconfig.yaml | 5 ++
test/py/test_linux_efiloader.py | 64 ++++++++++++++++++++++
2 files changed, 69 insertions(+)
diff --git a/test/arm/multi_v8_efiloader_defconfig.yaml b/test/arm/multi_v8_efiloader_defconfig.yaml
index 42bb418af6f8..b24058da8e99 100644
--- a/test/arm/multi_v8_efiloader_defconfig.yaml
+++ b/test/arm/multi_v8_efiloader_defconfig.yaml
@@ -27,6 +27,11 @@ targets:
- smbios
- bootable
- efi
+ options:
+ root_dev: virtioblk0.0
+ bootm.image: 'boot/vmlinuz-*'
+ bootm.initrd: 'boot/initrd.img-*'
+
images:
barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
imports:
diff --git a/test/py/test_linux_efiloader.py b/test/py/test_linux_efiloader.py
index 8530747a7a6b..b9ea82d27c0d 100644
--- a/test/py/test_linux_efiloader.py
+++ b/test/py/test_linux_efiloader.py
@@ -15,6 +15,70 @@ def get_journalctl(shell, kernel=True, grep=None):
return stdout
+@pytest.mark.lg_feature(['bootable', 'efi'])
+@pytest.mark.parametrize('efiloader', [False, True])
+def test_boot_manual_with_initrd(strategy, barebox, env, efiloader):
+ """Test booting Debian kernel directly without GRUB"""
+
+ barebox.run_check(f"global.bootm.efi={'required' if efiloader else 'disabled'}")
+
+ def get_option(strategy, opt):
+ config = strategy.target.env.config
+ return config.get_target_option(strategy.target.name, opt)
+
+ try:
+ root_dev = get_option(strategy, "root_dev")
+ kernel_path = get_option(strategy, "bootm.image")
+ except KeyError:
+ pytest.fail("Feature bootable enabled, but root_dev/bootm.image option missing.") # noqa
+
+ # Detect block devices
+ barebox.run_check("detect -a")
+ barebox.run_check(f"ls /mnt/{root_dev}/")
+
+ [kernel_path] = barebox.run_check(f"ls /mnt/{root_dev}/{kernel_path}")
+
+ try:
+ initrd_path = get_option(strategy, "bootm.initrd")
+ [initrd_path] = barebox.run_check(f"ls /mnt/{root_dev}/{initrd_path}")
+ barebox.run_check(f"global.bootm.initrd={initrd_path}")
+ except KeyError:
+ pass
+
+ barebox.run_check(f"global.bootm.image={kernel_path}")
+ barebox.run_check(f"global.bootm.root_dev=/dev/{root_dev}")
+ barebox.run_check("global.bootm.appendroot=1")
+ # Speed up subsequent runs a bit
+ barebox.run_check("global linux.bootargs.noapparmor=apparmor=0")
+
+ # Boot the kernel - it should use EFI stub by default
+ with strategy.boot_kernel(bootm=True) as shell:
+ shell.run_check("grep -q apparmor=0 /proc/cmdline")
+
+ initrd_freed = any("Freeing initrd memory"
+ in line for line in get_journalctl(shell, 'initrd'))
+ assert initrd_freed, "initrd was not loaded or freed"
+
+ # Verify we booted to shell
+ dmesg = get_journalctl(shell, 'efi')
+
+ uefi_not_found = re.search("efi: UEFI not found.",
+ "\n".join(dmesg)) is not None
+
+ if efiloader:
+ test_efi_kernel_no_warn(shell)
+ test_expected_efi_messages(shell, env)
+ test_efi_systab(shell, env)
+ test_efivars_filesystem_not_empty(shell)
+
+ assert not uefi_not_found, \
+ "EFI stub was not used despite global.bootm.efi=required"
+ else:
+ # Verify that EFI was NOT used
+ assert uefi_not_found, \
+ "EFI stub was used despite global.bootm.efi=disabled"
+
+
@pytest.mark.lg_feature(['bootable', 'efi'])
def test_efi_kernel_no_warn(shell):
stdout, stderr, ret = shell.run("journalctl -k --no-pager --grep efi -o cat -p warning")
--
2.47.3
next prev parent reply other threads:[~2026-01-09 17:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 16:57 [PATCH 0/5] test: arm: boot test Debian image in CI Ahmad Fatoum
2026-01-09 16:57 ` [PATCH 1/5] test: arm: multi_v8_efiloader_defconfig: use qcow2 image Ahmad Fatoum
2026-01-09 16:57 ` [PATCH 2/5] test: py: strategy: add helpers for booting kernel and bootm Ahmad Fatoum
2026-01-09 16:57 ` [PATCH 3/5] test: py: efiloader: prepare get_dmesg for more general usage Ahmad Fatoum
2026-01-09 16:57 ` Ahmad Fatoum [this message]
2026-01-09 16:57 ` [PATCH 5/5] ci: add Debian ARM64 EFI loader boot test Ahmad Fatoum
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=20260109170007.805177-5-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.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