Skip to content

Commit 42412fa

Browse files
committed
tests: Add generic post-install verification
Prep for more work. Signed-off-by: Colin Walters <[email protected]>
1 parent 3424b31 commit 42412fa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests-integration/src/install.rs

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::path::Path;
22
use std::{os::fd::AsRawFd, path::PathBuf};
33

44
use anyhow::Result;
5+
use camino::Utf8Path;
56
use cap_std_ext::cap_std;
67
use cap_std_ext::cap_std::fs::Dir;
78
use fn_error_context::context;
@@ -53,6 +54,12 @@ fn find_deployment_root() -> Result<Dir> {
5354
anyhow::bail!("Failed to find deployment root")
5455
}
5556

57+
// Hook relatively cheap post-install tests here
58+
fn generic_post_install_verification() -> Result<()> {
59+
assert!(Utf8Path::new("/ostree/repo").try_exists()?);
60+
Ok(())
61+
}
62+
5663
#[context("Install tests")]
5764
pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments) -> Result<()> {
5865
// Force all of these tests to be serial because they mutate global state
@@ -88,6 +95,8 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
8895
std::fs::write(&tmp_keys, b"ssh-ed25519 ABC0123 [email protected]")?;
8996
cmd!(sh, "sudo {BASE_ARGS...} {target_args...} -v {tmp_keys}:/test_authorized_keys {image} bootc install to-filesystem {generic_inst_args...} --acknowledge-destructive --karg=foo=bar --replace=alongside --root-ssh-authorized-keys=/test_authorized_keys /target").run()?;
9097

98+
generic_post_install_verification()?;
99+
91100
// Test kargs injected via CLI
92101
cmd!(
93102
sh,
@@ -120,6 +129,7 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
120129
let sh = &xshell::Shell::new()?;
121130
reset_root(sh)?;
122131
cmd!(sh, "sudo {BASE_ARGS...} {target_args...} {image} bootc install to-existing-root --acknowledge-destructive {generic_inst_args...}").run()?;
132+
generic_post_install_verification()?;
123133
let root = &Dir::open_ambient_dir("/ostree", cap_std::ambient_authority()).unwrap();
124134
let mut path = PathBuf::from(".");
125135
crate::selinux::verify_selinux_recurse(root, &mut path, false)?;
@@ -131,6 +141,7 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
131141
let empty = sh.create_temp_dir()?;
132142
let empty = empty.path().to_str().unwrap();
133143
cmd!(sh, "sudo {BASE_ARGS...} {target_args...} -v {empty}:/usr/lib/bootc/install {image} bootc install to-existing-root {generic_inst_args...}").run()?;
144+
generic_post_install_verification()?;
134145
Ok(())
135146
}),
136147
];

0 commit comments

Comments
 (0)