summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHermes Agent <hermes@localhost>2026-08-12 04:18:12 +0000
committerHermes Agent <hermes@localhost>2026-08-12 04:18:12 +0000
commit39a23d9035ab99191e305db3a55a8df1606f63b3 (patch)
treeac48f8d44ce5c884b4694ea88e806e9cb08ee2c6 /tests
parentfc4e46c41bfb769193159143f6567341cd3e3a51 (diff)
Make rootfs finalization repeatable
Diffstat (limited to 'tests')
-rw-r--r--tests/rootfs_finalization.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/rootfs_finalization.rs b/tests/rootfs_finalization.rs
index fa0cf3b..3a98290 100644
--- a/tests/rootfs_finalization.rs
+++ b/tests/rootfs_finalization.rs
@@ -79,3 +79,39 @@ fn finalization_rejects_rootfs_escaping_destinations_and_symlinks() {
.expect_err("unsafe symlink must be rejected");
assert!(error.to_string().contains("escapes copied tree"));
}
+
+#[test]
+fn finalization_is_idempotent_for_matching_symlinks() {
+ let fixture = tempdir().expect("fixture directory");
+ let source = fixture.path().join("overlay");
+ fs::create_dir_all(&source).expect("create source tree");
+ symlink("controller.conf", source.join("controller-link")).expect("create source symlink");
+ fs::write(source.join("controller.conf"), "controller\n").expect("write source file");
+ let rootfs = tempdir().expect("rootfs directory");
+ let finalization = RootfsFinalization::new(
+ vec![CopyTree::new(&source, "etc/controller").expect("valid copy destination")],
+ InitrdOem::new(std::iter::empty::<&str>(), std::iter::empty::<&str>()),
+ vec![ServiceName::new("chronyd.service").expect("valid service")],
+ );
+
+ finalization.apply(rootfs.path()).expect("first finalization succeeds");
+ let second = finalization.apply(rootfs.path()).expect("repeat finalization succeeds");
+
+ assert_eq!(
+ fs::read_link(rootfs.path().join("etc/controller/controller-link")).expect("copied symlink"),
+ Path::new("controller.conf")
+ );
+ assert_eq!(
+ fs::read_link(
+ rootfs
+ .path()
+ .join("etc/systemd/system/multi-user.target.wants/chronyd.service")
+ )
+ .expect("enabled service"),
+ Path::new("/usr/lib/systemd/system/chronyd.service")
+ );
+ assert!(second
+ .created_paths()
+ .iter()
+ .any(|path| path == "etc/controller/controller-link"));
+}