Skip to content

Commit 5c3d1e5

Browse files
committed
tmt: Apply boot context when discovering plans
FMF adjustments need the boot type and seal state during plan discovery, not only during execution. Honor disabled plans before provisioning a VM so unsupported test variants can be excluded through existing metadata. Keep an unspecified seal state distinct from an explicitly unsealed one. Generated-by: AI Signed-off-by: Colin Walters <walters@verbum.org>
1 parent edc09a0 commit 5c3d1e5

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

crates/xtask/src/tmt.rs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ fn sanitize_plan_name(plan: &str) -> String {
6969
}
7070
}
7171

72+
fn boot_context(boot_type: &crate::BootType, seal_state: Option<&SealState>) -> [String; 2] {
73+
[
74+
format!("--context=boot_type={boot_type}"),
75+
format!(
76+
"--context=seal_state={}",
77+
seal_state.map_or("unspecified".to_string(), ToString::to_string)
78+
),
79+
]
80+
}
81+
7282
/// Check that required dependencies are available
7383
#[context("Checking dependencies")]
7484
fn check_dependencies(sh: &Shell) -> Result<()> {
@@ -378,6 +388,7 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
378388
.chain(std::iter::once(format!(
379389
"--context=VARIANT_ID={variant_id}"
380390
)))
391+
.chain(boot_context(&args.boot_type, args.seal_state.as_ref()))
381392
.collect::<Vec<_>>();
382393
let preserve_vm = args.preserve_vm;
383394

@@ -425,9 +436,13 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
425436

426437
// Get the list of plans
427438
println!("Discovering test plans...");
428-
let plans_output = cmd!(sh, "tmt plan ls")
429-
.read()
430-
.context("Getting list of test plans")?;
439+
let discovery_context = context.clone();
440+
let plans_output = cmd!(
441+
sh,
442+
"tmt {discovery_context...} plan ls --filter enabled:true"
443+
)
444+
.read()
445+
.context("Getting list of test plans")?;
431446

432447
let mut plans: Vec<&str> = plans_output
433448
.lines()
@@ -1399,6 +1414,21 @@ fn generate_integration() -> Result<(String, String)> {
13991414
mod tests {
14001415
use super::*;
14011416

1417+
#[test]
1418+
fn test_boot_context_values() {
1419+
assert_eq!(
1420+
boot_context(&crate::BootType::Uki, Some(&SealState::Sealed)),
1421+
["--context=boot_type=uki", "--context=seal_state=sealed"]
1422+
);
1423+
assert_eq!(
1424+
boot_context(&crate::BootType::Bls, None),
1425+
[
1426+
"--context=boot_type=bls",
1427+
"--context=seal_state=unspecified"
1428+
]
1429+
);
1430+
}
1431+
14021432
#[test]
14031433
fn test_parse_tmt_metadata_basic() {
14041434
let content = r#"# number: 1

0 commit comments

Comments
 (0)