tests: Add a sanity check for composefs
authorColin Walters <walters@verbum.org>
Mon, 19 Jun 2023 23:02:20 +0000 (19:02 -0400)
committerColin Walters <walters@verbum.org>
Mon, 19 Jun 2023 23:02:20 +0000 (19:02 -0400)
Prep for adding some coverage of this flow when booting with
composefs.

tests/inst/src/composefs.rs [new file with mode: 0644]
tests/inst/src/insttestmain.rs

diff --git a/tests/inst/src/composefs.rs b/tests/inst/src/composefs.rs
new file mode 100644 (file)
index 0000000..a75af87
--- /dev/null
@@ -0,0 +1,31 @@
+use anyhow::Result;
+use xshell::cmd;
+
+pub(crate) fn itest_composefs() -> Result<()> {
+    let sh = xshell::Shell::new()?;
+    if !cmd!(sh, "ostree --version").read()?.contains("- composefs") {
+        println!("SKIP no composefs support");
+        return Ok(());
+    }
+    let mark = match crate::test::get_reboot_mark()? {
+        None => {
+            cmd!(
+                sh,
+                "ostree --repo=/ostree/repo config set ex-integrity.composefs true"
+            )
+            .run()?;
+            // A dummy change; TODO add an ostree command for this
+            cmd!(sh, "rpm-ostree kargs --append=foo=bar").run()?;
+            return Err(crate::test::reboot("1").into());
+        }
+        Some(v) => v,
+    };
+    if mark != "1" {
+        anyhow::bail!("Invalid reboot mark: {mark}")
+    }
+
+    let fstype = cmd!(sh, "findmnt -n -o FSTYPE /").read()?;
+    assert_eq!(fstype.as_str(), "overlay");
+
+    Ok(())
+}
index e8a7acb960550f1baca8eeb4905c66d202a36726..92ca8e014c5c1ed1149cd9fac2ab88c2ebf3b9f3 100644 (file)
@@ -2,6 +2,7 @@ use anyhow::{bail, Result};
 use libtest_mimic::Trial;
 use structopt::StructOpt;
 
+mod composefs;
 mod destructive;
 mod repobin;
 mod sysroot;
@@ -28,7 +29,10 @@ const TESTS: &[StaticTest] = &[
     test!(repobin::itest_extensions),
     test!(repobin::itest_pull_basicauth),
 ];
-const DESTRUCTIVE_TESTS: &[StaticTest] = &[test!(destructive::itest_transactionality)];
+const DESTRUCTIVE_TESTS: &[StaticTest] = &[
+    test!(destructive::itest_transactionality),
+    test!(composefs::itest_composefs),
+];
 
 #[derive(Debug, StructOpt)]
 #[structopt(rename_all = "kebab-case")]