|
| 1 | +use indoc::indoc; |
| 2 | +use scopeguard::defer; |
| 3 | +use serde::Deserialize; |
| 4 | +use std::fs; |
1 | 5 | use std::process::Command; |
2 | 6 |
|
3 | 7 | use anyhow::{Context, Result}; |
@@ -36,8 +40,34 @@ pub(crate) fn test_bootc_install_config() -> Result<()> { |
36 | 40 | let config = cmd!(sh, "bootc install print-configuration").read()?; |
37 | 41 | let config: serde_json::Value = |
38 | 42 | 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()]}; |
41 | 71 | Ok(()) |
42 | 72 | } |
43 | 73 |
|
@@ -88,6 +118,7 @@ pub(crate) fn run(testargs: libtest_mimic::Arguments) -> Result<()> { |
88 | 118 | new_test("variant-base-crosscheck", test_variant_base_crosscheck), |
89 | 119 | new_test("bootc upgrade", test_bootc_upgrade), |
90 | 120 | new_test("install config", test_bootc_install_config), |
| 121 | + new_test("printconfig --all", test_bootc_install_config_all), |
91 | 122 | new_test("status", test_bootc_status), |
92 | 123 | new_test("system-reinstall --help", test_system_reinstall_help), |
93 | 124 | ]; |
|
0 commit comments