Skip to content

Commit 9e63391

Browse files
tests: Update tests for GrubCC
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 751c2bb commit 9e63391

4 files changed

Lines changed: 21 additions & 10 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

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-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)