Skip to content

Commit e31ce45

Browse files
tmt: Add composefs= cmdline validation tests for UKI addons
Test that bootc rejects composefs= in the wrong places - Build a global addon containing composefs= from `bootc compute-composefs-digest`, attempt switch with --global-uki-addon, assert failure - Build a scoped addon containing composefs= alongside the UKI (which already has it), attempt switch with --uki-addon, assert failure due to duplicate composefs= It's a shame that we can't test UKI Addon only cmdline without piling on a bunch of hacks since `bootc container ukify` unconditionally puts the cmdline inside the UKI Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent bb2c766 commit e31ce45

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

‎tmt/tests/booted/test-composefs-uki-addons.nu‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,26 @@ def second_boot [] {
6060
ukify build --cmdline 'johan=liebert' --output /out/${kver}.efi.extra.d/monster-cmdline.addon.efi
6161
mkdir -p '/out/loader/addons'
6262
ukify build --cmdline 'kenzo=tenma' --output /out/loader/addons/global-cmdline.addon.efi
63+
64+
# /run/target is taken from tap make_uki_containerfile 'FROM base as sealed-uki'
65+
CFS_DIGEST=$\(bootc compute-composefs-digest /run/target\)
66+
ukify build --cmdline 'composefs=${CFS_DIGEST}' --output /out/loader/addons/global-cfs-cmdline.addon.efi
6367
"
6468

6569
$containerfile = (tap make_uki_containerfile $containerfile --addon-cmds $cmds)
6670

6771
echo $containerfile | podman build -t localhost/bootc-uki-addons-2 . -f -
6872

69-
# Include two addons
73+
# Include composefs cmdline in global addon
74+
# Should fail
75+
let result_global = (do {
76+
bootc switch --transport containers-storage --global-uki-addon global-cfs-cmdline localhost/bootc-uki-addons-2
77+
} | complete)
78+
79+
assert ($result_global.exit_code != 0) "Global addon with composefs= should be rejected"
80+
81+
# Include two addons, but don't include the global composefs= cmdline
82+
# should succeed
7083
bootc switch --transport containers-storage --uki-addon monster-cmdline --global-uki-addon global-cmdline localhost/bootc-uki-addons-2
7184

7285
tmt-reboot
@@ -89,9 +102,15 @@ def third_boot [] {
89102
RUN touch /usr/share/third
90103
"
91104

105+
# Put the composefs= in a local addon
92106
let cmds = "
93107
mkdir -p /out/${kver}.efi.extra.d
94108
ukify build --cmdline 'berserk=guts' --output /out/${kver}.efi.extra.d/berserk-cmdline.addon.efi
109+
110+
# /run/target is taken from tap make_uki_containerfile 'FROM base as sealed-uki'
111+
CFS_DIGEST=$\(bootc compute-composefs-digest /run/target\)
112+
ukify build --cmdline 'composefs=${CFS_DIGEST}' --output /out/${kver}.efi.extra.d/local-cfs-cmdline.addon.efi
113+
95114
mkdir -p '/out/loader/addons'
96115
ukify build --cmdline 'pink=floyd' --output /out/loader/addons/global-cmdline.addon.efi
97116
"
@@ -100,7 +119,16 @@ def third_boot [] {
100119

101120
echo $containerfile | podman build -t localhost/bootc-uki-addons-3 . -f -
102121

122+
# Include two composefs cmdlines
123+
# Should fail
124+
let result_local = (do {
125+
bootc switch --transport containers-storage --uki-addon local-cfs-cmdline localhost/bootc-uki-addons-3
126+
} | complete)
127+
128+
assert ($result_local.exit_code != 0) "Two composefs cmdline should've been rejected"
129+
103130
# This should update the global cmdline because we have the same name
131+
# Also this shouldn't include the local cmdline addon so we're good and this should pass
104132
bootc switch --transport containers-storage --uki-addon berserk-cmdline localhost/bootc-uki-addons-3
105133

106134
tmt-reboot

0 commit comments

Comments
 (0)