mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/4] efi: add EFI loader integration test
@ 2025-12-18 14:48 Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 1/4] test: py: strategy: add OS shell state Ahmad Fatoum
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-12-18 14:48 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For basic testing of the EFI loader support, add a Labgrid environment
capable of booting through barebox into Debian and some basic tests
checking in Linux that things are as we expect it.

This is intentionally not wired into CI as I don't want to hit Debian
infra on every test run. Github Actions supports caching for that, but
until this is done, we expect the Debian nocloud image to be manually
downloaded.

Ahmad Fatoum (4):
  test: py: strategy: add OS shell state
  test: py: add simple SMBIOS tests
  test: py: add simple EFI loader integration test
  test: arm: add Labgrid env YAML for multi_v8_efiloader_defconfig

 conftest.py                                |  6 +++
 test/arm/multi_v8_efiloader_defconfig.yaml | 33 ++++++++++++
 test/py/test_linux_efiloader.py            | 59 ++++++++++++++++++++++
 test/py/test_linux_smbios.py               | 30 +++++++++++
 test/strategy.py                           | 11 ++++
 5 files changed, 139 insertions(+)
 create mode 100644 test/arm/multi_v8_efiloader_defconfig.yaml
 create mode 100644 test/py/test_linux_efiloader.py
 create mode 100644 test/py/test_linux_smbios.py

-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] test: py: strategy: add OS shell state
  2025-12-18 14:48 [PATCH 0/4] efi: add EFI loader integration test Ahmad Fatoum
@ 2025-12-18 14:48 ` Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 2/4] test: py: add simple SMBIOS tests Ahmad Fatoum
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-12-18 14:48 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

So far, we only boot barebox from within barebox. Let's allow YAML files
to optional specify a ShellDriver that we will use to test booting of
actual kernels and not only barebox look-alikes.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 conftest.py      |  6 ++++++
 test/strategy.py | 11 +++++++++++
 2 files changed, 17 insertions(+)

diff --git a/conftest.py b/conftest.py
index 55935f7602f7..ef6ca221a5db 100644
--- a/conftest.py
+++ b/conftest.py
@@ -25,6 +25,12 @@ def barebox(request, strategy, target):
     return target.get_driver('BareboxDriver')
 
 
+@pytest.fixture(scope='function')
+def shell(strategy, target):
+    strategy.transition('shell')
+    return target.get_driver('ShellDriver')
+
+
 @pytest.fixture(scope="session")
 def barebox_config(request, strategy, target):
     transition_to_barebox(request, strategy)
diff --git a/test/strategy.py b/test/strategy.py
index fcfa2ed48125..0f1b76147443 100644
--- a/test/strategy.py
+++ b/test/strategy.py
@@ -25,6 +25,7 @@ class Status(enum.Enum):
     qemu_dry_run = 3
     qemu_interactive = 4
     qemu_dump_dtb = 5
+    shell = 6
 
 
 @target_factory.reg_driver
@@ -35,6 +36,7 @@ class BareboxTestStrategy(Strategy):
         "power": "PowerProtocol",
         "console": "ConsoleProtocol",
         "barebox": "BareboxDriver",
+        "shell": {"ShellDriver", None},
     }
 
     status = attr.ib(default=Status.unknown)
@@ -55,6 +57,9 @@ class BareboxTestStrategy(Strategy):
             step.skip("nothing to do")
             return  # nothing to do
         elif status == Status.off:
+            self.target.deactivate(self.barebox)
+            if self.shell:
+                self.target.deactivate(self.shell)
             self.target.deactivate(self.console)
             self.target.activate(self.power)
             self.power.off()
@@ -65,6 +70,12 @@ class BareboxTestStrategy(Strategy):
             self.power.cycle()
             # interrupt barebox
             self.target.activate(self.barebox)
+        elif status == Status.shell:
+            # transition to barebox
+            self.transition(Status.barebox)  # pylint: disable=missing-kwoa
+            self.barebox.boot("")
+            self.barebox.await_boot()
+            self.target.activate(self.shell)
         else:
             raise StrategyError(
                 "no transition found from {} to {}".
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/4] test: py: add simple SMBIOS tests
  2025-12-18 14:48 [PATCH 0/4] efi: add EFI loader integration test Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 1/4] test: py: strategy: add OS shell state Ahmad Fatoum
@ 2025-12-18 14:48 ` Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 3/4] test: py: add simple EFI loader integration test Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 4/4] test: arm: add Labgrid env YAML for multi_v8_efiloader_defconfig Ahmad Fatoum
  3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-12-18 14:48 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For configs that are bootable (meaning they are configured to start an
OS) and have the smbios feature enabled, let's verify that the kernel
has found the entry point and that it contains the "barebox" string.

We could do more extensive tests with dmidecode(1) and we should in
future, but we don't want to require its existence for the base check.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 test/py/test_linux_smbios.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 test/py/test_linux_smbios.py

diff --git a/test/py/test_linux_smbios.py b/test/py/test_linux_smbios.py
new file mode 100644
index 000000000000..d0c2b7ca5665
--- /dev/null
+++ b/test/py/test_linux_smbios.py
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+import pytest
+
+
+@pytest.mark.lg_feature(['bootable', 'smbios'])
+def test_smbios3_tables_present(shell):
+    _, _, ret = shell.run("test -e /sys/firmware/dmi/tables/smbios_entry_point")
+    assert ret == 0, "SMBIOS entry point not found"
+
+    [stdout], _, ret = shell.run("stat -c '%s' /sys/firmware/dmi/tables/DMI")
+    assert ret == 0
+
+    size = int(stdout)
+    assert size > 0, "SMBIOS DMI table is empty"
+
+    [stdout], _, ret = shell.run("dd if=/sys/firmware/dmi/tables/smbios_entry_point bs=1 count=5 2>/dev/null")
+    assert ret == 0
+    assert stdout == "_SM3_", "SMBIOS entry point is not SMBIOS 3.x"
+
+
+@pytest.mark.lg_feature(['bootable', 'smbios'])
+def test_smbios_contains_barebox(shell):
+    """
+    Search raw SMBIOS/DMI tables for a barebox vendor string.
+    This avoids dmidecode and relies on simple string matching.
+    """
+    # The DMI table is binary; strings are still ASCII embedded
+    stdout, _, ret = shell.run("strings /sys/firmware/dmi/tables/DMI | grep -i barebox")
+    assert len(stdout) > 0, "barebox not found in SMBIOS/DMI tables"
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] test: py: add simple EFI loader integration test
  2025-12-18 14:48 [PATCH 0/4] efi: add EFI loader integration test Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 1/4] test: py: strategy: add OS shell state Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 2/4] test: py: add simple SMBIOS tests Ahmad Fatoum
@ 2025-12-18 14:48 ` Ahmad Fatoum
  2025-12-18 14:48 ` [PATCH 4/4] test: arm: add Labgrid env YAML for multi_v8_efiloader_defconfig Ahmad Fatoum
  3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-12-18 14:48 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Boot into a Linux image (assumes journald) and check that the system was
UEFI booted by barebox.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 test/py/test_linux_efiloader.py | 59 +++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 test/py/test_linux_efiloader.py

diff --git a/test/py/test_linux_efiloader.py b/test/py/test_linux_efiloader.py
new file mode 100644
index 000000000000..22531bff81f4
--- /dev/null
+++ b/test/py/test_linux_efiloader.py
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+import re
+import pytest
+
+
+def get_dmesg(shell):
+    stdout, _, ret = shell.run("journalctl -k --no-pager --grep efi -o cat")
+    assert ret == 0
+    return stdout
+
+
+@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")
+    assert stdout == []
+    assert stderr == []
+
+
+@pytest.mark.lg_feature(['bootable', 'efi'])
+def test_expected_efi_messages(shell, env):
+    dmesg = get_dmesg(shell)
+
+    expected_patterns = [
+        r"efi:\s+EFI v2\.8 by barebox",
+        r"Remapping and enabling EFI services\.",
+        r"efivars:\s+Registered efivars operations",
+    ]
+
+    for pattern in expected_patterns:
+        assert re.search(pattern, "\n".join(dmesg)), \
+               f"Missing expected EFI message: {pattern}"
+
+
+@pytest.mark.lg_feature(['bootable', 'efi'])
+def test_efi_systab(shell, env):
+    stdout, stderr, ret = shell.run("cat /sys/firmware/efi/systab")
+    assert ret == 0
+    assert stderr == []
+    assert len(stdout) > 0
+
+    expected_patterns = [
+    ]
+
+    if 'smbios' in env.get_target_features():
+        expected_patterns.append(r"SMBIOS3=")
+
+    for pattern in expected_patterns:
+        assert re.search(pattern, "\n".join(stdout)), \
+               f"Missing expected entry in systab : {pattern}"
+
+
+@pytest.mark.lg_feature(['bootable', 'efi'])
+def test_efivars_filesystem_not_empty(shell):
+    # Directory must not be empty
+    stdout, _, ret = shell.run("ls -1 /sys/firmware/efi/efivars")
+    assert ret == 0
+
+    assert len(stdout), "EFI variables directory is empty"
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 4/4] test: arm: add Labgrid env YAML for multi_v8_efiloader_defconfig
  2025-12-18 14:48 [PATCH 0/4] efi: add EFI loader integration test Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2025-12-18 14:48 ` [PATCH 3/4] test: py: add simple EFI loader integration test Ahmad Fatoum
@ 2025-12-18 14:48 ` Ahmad Fatoum
  3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-12-18 14:48 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For basic testing of the EFI loader support, add a Labgrid environment
capable of booting through barebox into Debian.

This is intentionally not wired into CI as I don't want to hit Debian
infra on every test run. Github Actions supports caching for that, but
until this is done, we expect the file to be manually downloaded from:

https://cloud.debian.org/images/cloud/trixie/latest/debian-13-nocloud-arm64.raw

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 test/arm/multi_v8_efiloader_defconfig.yaml | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 test/arm/multi_v8_efiloader_defconfig.yaml

diff --git a/test/arm/multi_v8_efiloader_defconfig.yaml b/test/arm/multi_v8_efiloader_defconfig.yaml
new file mode 100644
index 000000000000..2aba23f3c0c1
--- /dev/null
+++ b/test/arm/multi_v8_efiloader_defconfig.yaml
@@ -0,0 +1,33 @@
+targets:
+  main:
+    drivers:
+      QEMUDriver:
+        qemu_bin: qemu-system-aarch64
+        machine: virt,highmem=off
+        cpu: cortex-a57
+        memory: 1024M
+        kernel: barebox-dt-2nd.img
+        display: qemu-default
+        extra_args: >
+          -drive if=virtio,format=raw,snapshot=on,file=debian-13-nocloud-arm64.raw
+          -device virtio-rng
+      BareboxDriver:
+        prompt: 'barebox@[^:]+:[^ ]+ '
+        autoboot: 'stop autoboot'
+        bootstring: 'commandline:|Starting EFI payload at'
+      ShellDriver:
+        prompt: '\x1b\[\?2004hroot@[^:]+:[^ ]+'
+        login_prompt: ' login: '
+        login_timeout: 300
+        await_login_timeout: 20
+        username: 'root'
+      BareboxTestStrategy: {}
+    features:
+      - virtio-mmio
+      - smbios
+      - bootable
+      - efi
+images:
+  barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+imports:
+  -  ../strategy.py
-- 
2.47.3




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-18 14:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-18 14:48 [PATCH 0/4] efi: add EFI loader integration test Ahmad Fatoum
2025-12-18 14:48 ` [PATCH 1/4] test: py: strategy: add OS shell state Ahmad Fatoum
2025-12-18 14:48 ` [PATCH 2/4] test: py: add simple SMBIOS tests Ahmad Fatoum
2025-12-18 14:48 ` [PATCH 3/4] test: py: add simple EFI loader integration test Ahmad Fatoum
2025-12-18 14:48 ` [PATCH 4/4] test: arm: add Labgrid env YAML for multi_v8_efiloader_defconfig Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox