Skip to content

Commit 136593a

Browse files
mvo5cgwalters
authored andcommitted
tests: add test_bootc_install_config_all integration test
This adds a simple integration test for ``` $ bootc install print-configuration --all ``` in the container tests. Thanks to Colin for suggesting this. Signed-off-by: Michael Vogt <[email protected]>
1 parent d84443d commit 136593a

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/tests-integration/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ bootc-kernel-cmdline = { path = "../kernel_cmdline", version = "0.0.0" }
2929
libtest-mimic = "0.8.0"
3030
oci-spec = "0.8.0"
3131
rexpect = "0.6"
32+
scopeguard = "1.2.0"
3233

3334
[lints]
3435
workspace = true

crates/tests-integration/src/container.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
use indoc::indoc;
2+
use scopeguard::defer;
3+
use serde::Deserialize;
4+
use std::fs;
15
use std::process::Command;
26

37
use anyhow::{Context, Result};
@@ -36,8 +40,34 @@ pub(crate) fn test_bootc_install_config() -> Result<()> {
3640
let config = cmd!(sh, "bootc install print-configuration").read()?;
3741
let config: serde_json::Value =
3842
serde_json::from_str(&config).context("Parsing install config")?;
39-
// Just verify we parsed the config, if any
40-
drop(config);
43+
// check that it parses okay, but also ensure kargs is not available here (only via --all)
44+
assert!(config.get("kargs").is_none());
45+
Ok(())
46+
}
47+
48+
pub(crate) fn test_bootc_install_config_all() -> Result<()> {
49+
#[derive(Deserialize)]
50+
struct TestInstallConfig {
51+
kargs: Vec<String>,
52+
}
53+
54+
let config_d = std::path::Path::new("/run/bootc/install/");
55+
let test_toml_path = config_d.join("10-test.toml");
56+
std::fs::create_dir_all(&config_d)?;
57+
let content = indoc! {r#"
58+
[install]
59+
kargs = ["karg1=1", "karg2=2"]
60+
"#};
61+
std::fs::write(&test_toml_path, content)?;
62+
defer! {
63+
fs::remove_file(test_toml_path).expect("cannot remove tempfile");
64+
}
65+
66+
let sh = &xshell::Shell::new()?;
67+
let config = cmd!(sh, "bootc install print-configuration --all").read()?;
68+
let config: TestInstallConfig =
69+
serde_json::from_str(&config).context("Parsing install config")?;
70+
assert_eq! {config.kargs, vec!["karg1=1".to_string(), "karg2=2".to_string(), "localtestkarg=somevalue".to_string(), "otherlocalkarg=42".to_string()]};
4171
Ok(())
4272
}
4373

@@ -88,6 +118,7 @@ pub(crate) fn run(testargs: libtest_mimic::Arguments) -> Result<()> {
88118
new_test("variant-base-crosscheck", test_variant_base_crosscheck),
89119
new_test("bootc upgrade", test_bootc_upgrade),
90120
new_test("install config", test_bootc_install_config),
121+
new_test("printconfig --all", test_bootc_install_config_all),
91122
new_test("status", test_bootc_status),
92123
new_test("system-reinstall --help", test_system_reinstall_help),
93124
];

0 commit comments

Comments
 (0)