[v3,4/7] testsuite: test WIC signer lookup in imaging chroot

Message ID 20261123140223.1707025-5-clara.kowalsky@siemens.com
State Under Review
Headers show
Series Update BitBake in Isar | expand

Commit Message

Clara Kowalsky Nov. 23, 2026, 2:02 p.m. UTC
WIC plugins run on the host, while commands launched through
WIC_TOOL_RUNNER run in the imaging chroot. A host-side os.path.exists()
check can therefore report a signer as missing even when it is present
in the chroot.

This adds a WIC build test that installs a copy-only signer in the
imaging chroot and selects it with the EFI boot partition's signwith
parameter. The test requires the unique signer path to be absent on the
host, as it exercises the host/chroot mismatch. The runner-aware lookup
checks for the signer, exec_cmd() then invokes it. The test does not
check cryptographic signing.

Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
 .../test-wic-signing/files/test-wic-signing   | 14 ++++++++++++++
 .../test-wic-signing/test-wic-signing.bb      | 19 +++++++++++++++++++
 meta-test/wic/test-wic-signing.wks            |  7 +++++++
 testsuite/citest.py                           | 16 ++++++++++++++++
 4 files changed, 56 insertions(+)
 create mode 100644 meta-test/recipes-app/test-wic-signing/files/test-wic-signing
 create mode 100644 meta-test/recipes-app/test-wic-signing/test-wic-signing.bb
 create mode 100644 meta-test/wic/test-wic-signing.wks

Patch

diff --git a/meta-test/recipes-app/test-wic-signing/files/test-wic-signing b/meta-test/recipes-app/test-wic-signing/files/test-wic-signing
new file mode 100644
index 00000000..b432c7a3
--- /dev/null
+++ b/meta-test/recipes-app/test-wic-signing/files/test-wic-signing
@@ -0,0 +1,14 @@ 
+#!/bin/sh
+# This software is a part of Isar.
+# Copyright (C) 2026 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+set -eu
+
+if [ "$#" -ne 2 ]; then
+    echo "usage: test-wic-signing INPUT OUTPUT" >&2
+    exit 2
+fi
+
+cp "$1" "$2"
diff --git a/meta-test/recipes-app/test-wic-signing/test-wic-signing.bb b/meta-test/recipes-app/test-wic-signing/test-wic-signing.bb
new file mode 100644
index 00000000..4741e778
--- /dev/null
+++ b/meta-test/recipes-app/test-wic-signing/test-wic-signing.bb
@@ -0,0 +1,19 @@ 
+# This software is a part of Isar.
+# Copyright (C) 2026 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+#
+# Test-only signer for exercising WIC's imaging-chroot command runner.
+# This copies the input file, it does not create a cryptographic signature.
+
+DPKG_ARCH = "any"
+SRC_URI = "file://test-wic-signing"
+
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+
+inherit dpkg-raw
+
+do_install[cleandirs] = "${D}/usr/libexec/isar-test-wic-signing"
+do_install() {
+    install -m 0755 ${WORKDIR}/test-wic-signing ${D}/usr/libexec/isar-test-wic-signing
+}
diff --git a/meta-test/wic/test-wic-signing.wks b/meta-test/wic/test-wic-signing.wks
new file mode 100644
index 00000000..f255d9c7
--- /dev/null
+++ b/meta-test/wic/test-wic-signing.wks
@@ -0,0 +1,7 @@ 
+# SPDX-License-Identifier: MIT
+#
+# Test-only WIC layout for the imaging-chroot signing-script lookup.
+part /boot --source bootimg-efi-isar --sourceparams "loader=grub-efi,signwith=/usr/libexec/isar-test-wic-signing/test-wic-signing" --ondisk sda --label efi --part-type EF00 --align 1024 --use-uuid
+part / --source rootfs --ondisk sda --fstype ext4 --mkfs-extraopts "-T default" --label platform --align 1024 --use-uuid --exclude-path boot/
+
+bootloader --ptable gpt --timeout 3 --append "rootwait console=ttyS0,115200 console=tty0"
diff --git a/testsuite/citest.py b/testsuite/citest.py
index e5113238..b6a8da7f 100644
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -978,6 +978,22 @@  class WicTest(CIBaseTest):
             compat_arch=False,
         )
 
+    def test_wic_signing_script(self):
+        targets = ['mc:qemuamd64-trixie:isar-image-base']
+        signer = '/usr/libexec/isar-test-wic-signing/test-wic-signing'
+        if os.path.exists(signer):
+            self.fail(f"WIC signing test requires {signer} to be absent on the host")
+
+        self.init()
+        self.perform_build_test(
+            targets,
+            lines=[
+                'WKS_FILE = "test-wic-signing.wks"',
+                'IMAGER_BUILD_DEPS += "test-wic-signing"',
+                'IMAGER_INSTALL:wic += "test-wic-signing"',
+            ],
+        )
+
 
 class DtbDeployTest(CIBaseTest):