]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-kernel-install: test 60-ukify.install and 90-uki-copy.install
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 13 Apr 2023 16:11:39 +0000 (18:11 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 May 2023 16:42:37 +0000 (18:42 +0200)
We install a kernel with layout=uki and uki_generator=ukify, and test
that a UKI gets installed in the expected place. The two plugins cooperate,
so it's easiest to test them together.

meson.build
src/kernel-install/meson.build
src/kernel-install/test-kernel-install.sh

index 88ef5679c5304c45481b0c64b6e38d1bd19c074c..910b55d3c07287119cb792721b98021540cae55c 100644 (file)
@@ -4352,7 +4352,7 @@ executable(
         install : true,
         install_dir : rootlibexecdir)
 
-exe = custom_target(
+kernel_install = custom_target(
         'kernel-install',
         input : kernel_install_in,
         output : 'kernel-install',
@@ -4364,14 +4364,7 @@ if want_kernel_install
         public_programs += exe
 endif
 
-if want_tests != 'false' and want_kernel_install
-        test('test-kernel-install',
-             test_kernel_install_sh,
-             env : test_env,
-             args : [exe.full_path(), loaderentry_install])
-endif
-
-exe = custom_target(
+ukify = custom_target(
         'ukify',
         input : 'src/ukify/ukify.py',
         output : 'ukify',
@@ -4380,7 +4373,19 @@ exe = custom_target(
         install_mode : 'rwxr-xr-x',
         install_dir : rootlibexecdir)
 if want_ukify
-   public_programs += exe
+   public_programs += ukify
+endif
+
+if want_tests != 'false' and want_kernel_install
+        args = [kernel_install.full_path(), loaderentry_install, uki_copy_install]
+        if want_ukify
+                args += [ukify.full_path(), ukify_install]
+        endif
+
+        test('test-kernel-install',
+             test_kernel_install_sh,
+             env : test_env,
+             args : args)
 endif
 
 ############################################################
index 95aa0d9497bd7cd3f85c5fa9df80c5e915257bbb..744071b9e94c021dc28f96ca6e63198ce0620ac9 100644 (file)
@@ -20,10 +20,12 @@ loaderentry_install = custom_target(
         install_mode : 'rwxr-xr-x',
         install_dir : kernelinstalldir)
 
-kernel_install_files = files(
-        '50-depmod.install',
-        '90-uki-copy.install',
-)
+uki_copy_install = files('90-uki-copy.install')
+
+kernel_install_files = [
+        files('50-depmod.install'),
+        uki_copy_install,
+]
 
 if want_kernel_install
         install_data(kernel_install_files,
index 4cbf16f0df2754e42ece790191d9fbfc4ee45d78..c9d73ff8e32944147ec5e9e59dc15b1e94773a47 100755 (executable)
@@ -7,7 +7,10 @@ set -o pipefail
 export SYSTEMD_LOG_LEVEL=debug
 
 kernel_install="${1:?}"
-plugin="${2:?}"
+loaderentry_install="${2:?}"
+uki_copy_install="${3:?}"
+ukify="${4:-}"
+ukify_install="${5:-}"
 if [[ -d "${PROJECT_BUILD_ROOT:-}" ]]; then
     bootctl="${PROJECT_BUILD_ROOT}/bootctl"
 else
@@ -36,11 +39,14 @@ MACHINE_ID=badbadbadbadbadbad6abadbadbadbad
 EOF
 
 export KERNEL_INSTALL_CONF_ROOT="$D/sources"
-export KERNEL_INSTALL_PLUGINS="$plugin"
+# We "install" multiple plugins, but control which ones will be active via install.conf.
+export KERNEL_INSTALL_PLUGINS="${ukify_install} ${loaderentry_install} ${uki_copy_install}"
 export BOOT_ROOT="$D/boot"
 export BOOT_MNT="$D/boot"
 export MACHINE_ID='3e0484f3634a418b8e6a39e8828b03e3'
+export KERNEL_INSTALL_UKIFY="$ukify"
 
+# Test type#1 installation
 "$kernel_install" -v add 1.1.1 "$D/sources/linux" "$D/sources/initrd"
 
 entry="$BOOT_ROOT/loader/entries/the-token-1.1.1.conf"
@@ -91,7 +97,25 @@ grep -qE '^initrd .*/the-token/1.1.1/initrd' "$entry"
 grep -qE 'image' "$BOOT_ROOT/the-token/1.1.1/linux"
 grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd"
 
-if test -x "$bootctl"; then
+# Install UKI
+if [ -f "$ukify" ]; then
+    cat >>"$D/sources/install.conf" <<EOF
+layout=uki
+uki_generator=ukify
+EOF
+    "$kernel_install" -v add 1.1.3 "$D/sources/linux" "$D/sources/initrd"
+    uki="${BOOT_ROOT}/EFI/Linux/the-token-1.1.3+56.efi"
+    test -f "$uki"
+
+    if [ -x "$bootctl" ]; then
+        "$bootctl" kernel-inspect "$uki" | grep -qE 'Kernel Type: +uki$'
+        "$bootctl" kernel-inspect "$uki" | grep -qE 'Version: +1\.1\.3$'
+        "$bootctl" kernel-inspect "$uki" | grep -qE 'Cmdline: +opt1 opt2$'
+    fi
+fi
+
+# Test bootctl
+if [ -x "$bootctl" ]; then
     echo "Testing bootctl"
     e2="${entry%+*}_2.conf"
     cp "$entry" "$e2"