summaryrefslogtreecommitdiff
path: root/tests/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/build.rs')
-rw-r--r--tests/build.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/build.rs b/tests/build.rs
index cae79b0..a0a75b8 100644
--- a/tests/build.rs
+++ b/tests/build.rs
@@ -39,6 +39,18 @@ impl PackageInstaller for RootfslessInstaller {
}
}
+struct RootfsFinalizationFailingInstaller;
+
+impl PackageInstaller for RootfsFinalizationFailingInstaller {
+ fn install(&self, request: &PackageRequest) -> anyhow::Result<()> {
+ let rootfs = request.workdir().join("chroot");
+ fs::create_dir_all(rootfs.join("boot"))?;
+ fs::write(rootfs.join("boot/vmlinuz-6.12.0-rt1"), "kernel")?;
+ fs::write(rootfs.join("etc"), "not a directory")?;
+ Ok(())
+ }
+}
+
struct FailingInitramfsBuilder;
impl InitramfsBuilder for FailingInitramfsBuilder {
@@ -218,6 +230,24 @@ fn removes_the_new_workspace_when_the_installer_does_not_create_a_rootfs() {
}
#[test]
+fn removes_the_new_workspace_when_rootfs_finalization_fails() {
+ let fixture = tempdir().expect("fixture directory");
+ let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml"))
+ .expect("load controller spec");
+ let plan = BuildPlan::compile(spec).expect("compile build plan");
+ let mut executor = BuildExecutor::new(RootfsFinalizationFailingInstaller, FixtureInitramfsBuilder);
+ let workspace = fixture.path().join("work");
+ let artifact = fixture.path().join("image.tar");
+
+ let _error = executor
+ .execute(&plan, &workspace, "profiles/apt.conf", &artifact)
+ .expect_err("failed rootfs finalization must fail the build");
+
+ assert!(!workspace.exists(), "failed build must not leave a workspace");
+ assert!(!artifact.exists());
+}
+
+#[test]
fn removes_the_new_workspace_when_initramfs_build_fails() {
let fixture = tempdir().expect("fixture directory");
let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml"))