Skip to content

Commit f415e69

Browse files
tests: Update tests for GrubCC
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com> No secureboot for grub-cc Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 751c2bb commit f415e69

6 files changed

Lines changed: 32 additions & 18 deletions

File tree

crates/lib/src/spec.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,15 @@ pub enum Bootloader {
238238
#[default]
239239
Grub,
240240
/// Use Grub for confidential clusters as the bootloader
241+
#[serde(rename = "grub-cc")]
241242
GrubCC,
242243
/// Use SystemdBoot as the bootloader
243244
Systemd,
244245
/// Don't use a bootloader managed by bootc
245246
None,
246247
}
247248

248-
#[derive(Debug)]
249+
#[derive(Debug, PartialEq, Eq)]
249250
pub enum BootloaderKind {
250251
/// Bootloader that support Bootloader Specification
251252
/// GrubCC and SystemdBoot

crates/xtask/src/bcvk.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ impl BcvkInstallOpts {
110110
Run 'just generate-secureboot-keys' to generate them."
111111
);
112112
}
113-
} else if matches!(self.bootloader, Some(Bootloader::Systemd)) {
113+
} else if matches!(
114+
self.bootloader,
115+
Some(Bootloader::Systemd) | Some(Bootloader::GrubCC)
116+
) {
114117
Ok(vec!["--firmware=uefi-insecure".into()])
115118
} else {
116119
Ok(Vec::new())

tmt/tests/booted/readonly/030-test-composefs.nu

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ def parse_cmdline [] {
77
open /proc/cmdline | str trim | split row " "
88
}
99

10+
def find_root_eq_in_cmdline [bootloader: string] {
11+
let cmdline = parse_cmdline
12+
let has_root_param = ($cmdline | any { |param| $param | str starts-with 'root=' })
13+
assert (not $has_root_param) $"($bootloader) image should not have root= in kernel cmdline; systemd-gpt-auto-generator should discover the root partition via DPS"
14+
}
15+
1016
# Detect composefs by checking if composefs field is present
1117
let st = bootc status --json | from json
1218
let is_composefs = (tap is_composefs)
@@ -24,11 +30,14 @@ if $expecting_composefs {
2430
let bootctl_output = (bootctl)
2531

2632
if ($bootctl_output | str contains 'Product: systemd-boot') {
27-
let cmdline = parse_cmdline
28-
let has_root_param = ($cmdline | any { |param| $param | str starts-with 'root=' })
29-
assert (not $has_root_param) "systemd-boot image should not have root= in kernel cmdline; systemd-gpt-auto-generator should discover the root partition via DPS"
33+
find_root_eq_in_cmdline "systemd-boot"
3034
}
3135
}
36+
37+
# GrubCC also supports BLS and shouldn't need root=
38+
if $bootloader == "grub-cc" {
39+
find_root_eq_in_cmdline "grub-cc"
40+
}
3241
}
3342

3443
if $is_composefs {

tmt/tests/booted/test-composefs-gc.nu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def third_boot [] {
8888
# Also assert we have two different kernel + initrd pairs
8989
let booted_verity = (bootc status --json | from json).status.booted.composefs.verity
9090

91-
let bootloader = (bootc status --json | from json).status.booted.composefs.bootloader
91+
let bootloader = ((bootc status --json | from json).status.booted.composefs.bootloader | str downcase)
9292

93-
let boot_dir = if ($bootloader | str downcase) == "systemd" {
93+
let boot_dir = if $bootloader == "systemd" or $bootloader == "grub-cc" {
9494
# TODO: Some concrete API for this would be great
9595
mkdir /var/tmp/efi
9696
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
@@ -123,9 +123,9 @@ def third_boot [] {
123123
}
124124

125125
def fourth_boot [] {
126-
let bootloader = (bootc status --json | from json).status.booted.composefs.bootloader
126+
let bootloader = ((bootc status --json | from json).status.booted.composefs.bootloader | str downcase)
127127

128-
if ($bootloader | str downcase) == "systemd" {
128+
if $bootloader == "systemd" or $bootloader == "grub-cc" {
129129
# TODO: Some concrete API for this would be great
130130
mkdir /var/tmp/efi
131131
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi

tmt/tests/booted/test-install-to-filesystem-var-mount.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,15 @@ echo "Filesystem layout:"
141141
mount | grep /var/mnt/target || true
142142
df -h /var/mnt/target /var/mnt/target/boot /var/mnt/target/boot/efi /var/mnt/target/var
143143

144-
COMPOSEFS_BACKEND=()
144+
bootloader=$(bootc status --json | jq -r '.status.booted.composefs.bootloader' | tr '[:upper:]' '[:lower:]')
145+
146+
COMPOSEFS_BACKEND_PARAMS=()
145147
KARGS=("--karg=root=UUID=$ROOT_UUID")
146148

147149
if [[ $is_composefs != "null" ]]; then
148-
COMPOSEFS_BACKEND+=("--composefs-backend")
150+
COMPOSEFS_BACKEND_PARAMS+=("--composefs-backend")
151+
COMPOSEFS_BACKEND_PARAMS+=("--bootloader" "${bootloader}")
152+
149153
tune2fs -O verity /dev/BL/var02
150154
tune2fs -O verity /dev/BL/root02
151155

@@ -164,7 +168,7 @@ podman run \
164168
"$TARGET_IMAGE" \
165169
bootc install to-filesystem \
166170
--disable-selinux \
167-
"${COMPOSEFS_BACKEND[@]}" \
171+
"${COMPOSEFS_BACKEND_PARAMS[@]}" \
168172
"${KARGS[@]}" \
169173
--root-mount-spec=UUID="$ROOT_UUID" \
170174
--boot-mount-spec=UUID="$BOOT_UUID" \
@@ -186,16 +190,12 @@ else
186190
# It works for now as the CI runs separately for each bootloader, but we need to get the
187191
# bootloader from the installed systemd if we wish to run the tests locally without rebuilding the images
188192
# This probably also happens in other tests, one instance is install-outside-container
189-
bootloader=$(bootc status --json | jq '.status.booted.composefs.bootloader' | tr '[:upper:]' '[:lower:]')
190-
bootloader=${bootloader//\"/}
191-
192193
if [[ $bootloader == "grub" ]]; then
193194
test -d /var/mnt/target/boot/grub2 || test -d /var/mnt/target/boot/loader
194195
else
195196
test -d /var/mnt/target/boot/efi/EFI
196197
test -d /var/mnt/target/boot/efi/loader/entries
197198
fi
198-
199199
fi
200200

201201

tmt/tests/booted/test-multi-device-esp.nu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,9 @@ def main [] {
437437
# supports GRUB today. Skip when the image uses systemd-boot.
438438
if (tap is_composefs) {
439439
let st = bootc status --json | from json
440-
if ($st.status.booted.composefs.bootloader | str downcase) == "systemd" {
441-
print "SKIP: multi-device ESP test not supported with systemd-boot"
440+
let bootloader = $st.status.booted.composefs.bootloader | str downcase
441+
if $bootloader == "systemd" or $bootloader == "grub-cc" {
442+
print $"SKIP: multi-device ESP test not supported with ($bootloader)"
442443
tap ok
443444
return
444445
}

0 commit comments

Comments
 (0)