Skip to content

Commit 87e2a69

Browse files
Johan-Liebert1cgwalters
authored andcommitted
Make tests work for sdboot
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com> Remove root= cmdline for sdboot Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com> Use insecure UEFI for sdboot Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent e980dbf commit 87e2a69

6 files changed

Lines changed: 45 additions & 17 deletions

File tree

Justfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ test-composefs bootloader:
114114
just variant=composefs bootloader={{bootloader}} \
115115
test-tmt --composefs-backend --bootloader {{bootloader}} \
116116
readonly \
117-
bib-build \
118117
download-only \
119118
image-pushpull-upgrade \
120119
image-upgrade-reboot \

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use std::path::Path;
6868

6969
use anyhow::{Context, Result, anyhow, bail};
7070
use bootc_blockdev::find_parent_devices;
71-
use bootc_kernel_cmdline::utf8::{Cmdline, Parameter};
71+
use bootc_kernel_cmdline::utf8::{Cmdline, Parameter, ParameterKey};
7272
use bootc_mount::inspect_filesystem_of_dir;
7373
use bootc_mount::tempmount::TempMount;
7474
use camino::{Utf8Path, Utf8PathBuf};
@@ -566,6 +566,12 @@ pub(crate) fn setup_composefs_bls_boot(
566566
}
567567
};
568568

569+
// Remove "root=" from kernel cmdline as systemd-auto-gpt-generator should use DPS
570+
// UUID
571+
if bootloader == Bootloader::Systemd {
572+
cmdline_refs.remove(&ParameterKey::from("root"));
573+
}
574+
569575
let is_upgrade = matches!(setup_type, BootSetupType::Upgrade(..));
570576

571577
let current_root = if is_upgrade {

crates/xtask/src/tmt.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const DISTRO_CENTOS_9: &str = "centos-9";
3232
const COMPOSEFS_KERNEL_ARGS: [&str; 1] = ["--karg=enforcing=0"];
3333

3434
// Import the argument types from xtask.rs
35-
use crate::{RunTmtArgs, TmtProvisionArgs};
35+
use crate::{Bootloader, RunTmtArgs, TmtProvisionArgs};
3636

3737
/// Generate a random alphanumeric suffix for VM names
3838
fn generate_random_suffix() -> String {
@@ -111,7 +111,11 @@ const DEFAULT_SB_KEYS_DIR: &str = "target/test-secureboot";
111111
///
112112
/// For sealed images, secure boot keys must be present or an error is returned.
113113
#[context("Building firmware arguments")]
114-
fn build_firmware_args(sh: &Shell, image: &str) -> Result<Vec<String>> {
114+
fn build_firmware_args(
115+
sh: &Shell,
116+
image: &str,
117+
bootloader: &Option<Bootloader>,
118+
) -> Result<Vec<String>> {
115119
let is_sealed = is_sealed_image(sh, image)?;
116120
let sb_keys_dir = Utf8Path::new(DEFAULT_SB_KEYS_DIR);
117121

@@ -133,6 +137,8 @@ fn build_firmware_args(sh: &Shell, image: &str) -> Result<Vec<String>> {
133137
sb_keys_dir
134138
);
135139
}
140+
} else if matches!(bootloader, Some(Bootloader::Systemd)) {
141+
vec!["--firmware=uefi-insecure".into()]
136142
} else {
137143
Vec::new()
138144
};
@@ -310,7 +316,7 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
310316
println!("Detected distro: {}", distro);
311317
println!("Detected VARIANT_ID: {variant_id}");
312318

313-
let firmware_args = build_firmware_args(sh, image)?;
319+
let firmware_args = build_firmware_args(sh, image, &args.bootloader)?;
314320

315321
// Create tmt-workdir and copy tmt bits to it
316322
// This works around https://github.com/teemtee/tmt/issues/4062
@@ -699,7 +705,8 @@ pub(crate) fn tmt_provision(sh: &Shell, args: &TmtProvisionArgs) -> Result<()> {
699705
println!(" Image: {}", image);
700706
println!(" VM name: {}\n", vm_name);
701707

702-
let firmware_args = build_firmware_args(sh, image)?;
708+
// TODO: Send bootloader param here
709+
let firmware_args = build_firmware_args(sh, image, &None)?;
703710

704711
// Launch VM with bcvk
705712
// Use ds=iid-datasource-none to disable cloud-init for faster boot

crates/xtask/src/xtask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) struct LocalRustDepsArgs {
7979

8080
/// Bootloader passed as --bootloader param for composefs builds
8181
// TODO: Find a better way to share this Enum between this and crates/lib
82-
#[derive(Debug, Clone, ValueEnum)]
82+
#[derive(Debug, Clone, ValueEnum, PartialEq, Eq)]
8383
pub enum Bootloader {
8484
/// grub as bootloader
8585
Grub,

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,21 @@ let is_composefs = (tap is_composefs)
1313
let expecting_composefs = ($env.BOOTC_variant? | default "" | find "composefs") != null
1414
if $expecting_composefs {
1515
assert $is_composefs
16-
# When using systemd-boot with DPS (Discoverable Partition Specification),
17-
# /proc/cmdline should NOT contain a root= parameter because systemd-gpt-auto-generator
18-
# discovers the root partition automatically
19-
# Note that there is `bootctl --json=pretty` but it doesn't actually output JSON
20-
let bootctl_output = (bootctl)
21-
if ($bootctl_output | str contains 'Product: systemd-boot') {
22-
let cmdline = parse_cmdline
23-
let has_root_param = ($cmdline | any { |param| $param | str starts-with 'root=' })
24-
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"
16+
17+
let bootloader = ($st.status.booted.composefs.bootloader | str downcase)
18+
19+
if $bootloader == "systemd" {
20+
# When using systemd-boot with DPS (Discoverable Partition Specification),
21+
# /proc/cmdline should NOT contain a root= parameter because systemd-gpt-auto-generator
22+
# discovers the root partition automatically
23+
# Note that there is `bootctl --json=pretty` but it doesn't actually output JSON
24+
let bootctl_output = (bootctl)
25+
26+
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"
30+
}
2531
}
2632
}
2733

tmt/tests/booted/test-install-outside-container.nu

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ umount /var/mnt
2828
# so we mask off /sysroot/ostree
2929
# And using systemd-run here breaks our install_t so we disable SELinux enforcement
3030
setenforce 0
31+
32+
let st = bootc status --json | from json
33+
let bootloader = ($st.status.booted.composefs.bootloader | str downcase)
34+
35+
let install_cmd = if (tap is_composefs) {
36+
$"bootc install to-disk --disable-selinux --via-loopback --composefs-backend --bootloader=($bootloader) --filesystem ext4 --source-imgref ($target_image) ./disk.img"
37+
} else {
38+
$"bootc install to-disk --disable-selinux --via-loopback --filesystem xfs --source-imgref ($target_image) ./disk.img"
39+
}
40+
3141
systemd-run -p MountFlags=slave -qdPG -- /bin/sh -c $"
3242
set -xeuo pipefail
3343
bootc usr-overlay
@@ -36,7 +46,7 @@ if test -d /sysroot/ostree; then mount --bind /usr/share/empty /sysroot/ostree;
3646
rm -vrf /usr/lib/bootupd/updates
3747
# Another bootc install bug, we should not look at this in outside-of-container flows
3848
rm -vrf /usr/lib/bootc/bound-images.d
39-
bootc install to-disk --disable-selinux --via-loopback --filesystem xfs --source-imgref ($target_image) ./disk.img
49+
($install_cmd)
4050
"
4151

4252
tap ok

0 commit comments

Comments
 (0)