summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHermes Agent <hermes@localhost>2026-08-12 13:35:55 +0000
committerHermes Agent <hermes@localhost>2026-08-12 13:35:55 +0000
commit5debb9e51172745d7e564239ecb37a1d2c4f3a0e (patch)
treecdffe5ff6497d33ce2e68b44abd3f80cab84cc9f /tests
parentfeb6e6148cfc8f664bbae6b70cb1c793ef690c5c (diff)
Run native initramfs inside Hasher rooter context
Diffstat (limited to 'tests')
-rw-r--r--tests/initramfs.rs29
-rw-r--r--tests/package_installer.rs28
2 files changed, 52 insertions, 5 deletions
diff --git a/tests/initramfs.rs b/tests/initramfs.rs
index 5ad0b99..85908b2 100644
--- a/tests/initramfs.rs
+++ b/tests/initramfs.rs
@@ -67,15 +67,34 @@ fn make_initrd_adapter_uses_typed_chroot_arguments_and_records_output_digest() {
let result = builder.build(&request).expect("build initramfs");
+ let workdir = rootfs
+ .path()
+ .parent()
+ .expect("rootfs fixture has a parent")
+ .display()
+ .to_string();
assert_eq!(
builder.runner().invocations,
vec![Invocation::new(
- "chroot",
+ "sudo",
[
- rootfs.path().as_os_str().to_owned(),
- "make-initrd".into(),
- "-k".into(),
- "6.12-rt1".into(),
+ "-n",
+ "-u",
+ "hermes",
+ "hsh-run",
+ "--rooter",
+ "--mountpoints=/proc",
+ "--workdir",
+ &workdir,
+ "--",
+ "make-initrd",
+ "-N",
+ "-v",
+ "-k",
+ "6.12-rt1",
+ "AUTODETECT=",
+ "-c",
+ "/etc/initrd.mk.oem",
],
)]
);
diff --git a/tests/package_installer.rs b/tests/package_installer.rs
index 76d8683..74bf9aa 100644
--- a/tests/package_installer.rs
+++ b/tests/package_installer.rs
@@ -102,3 +102,31 @@ fn build_plan_compiles_its_typed_package_request() {
);
assert_eq!(request.selectors(), ["^kernel-(image|modules-())-(rt)$"]);
}
+
+#[test]
+fn sudo_user_runner_executes_hasher_commands_as_the_configured_user() {
+ let runner = alt_controller_image::hasher::SudoUserRunner::new("hermes");
+ let invocation = runner.wrap(Invocation::new("hsh", ["--version"]));
+
+ assert_eq!(
+ invocation,
+ Invocation::new("sudo", ["-n", "-u", "hermes", "hsh", "--version"])
+ );
+ let preparation = runner.prepare_workdir(std::path::Path::new("/build/work"));
+ assert_eq!(
+ preparation,
+ Invocation::new(
+ "sudo",
+ [
+ "-n",
+ "install",
+ "-d",
+ "-o",
+ "hermes",
+ "-g",
+ "hermes",
+ "/build/work"
+ ]
+ )
+ );
+}