nixos/tests/systemd-binfmt: Add chroot test

This commit is contained in:
Zhaofeng Li 2023-05-27 11:11:49 -06:00 committed by Julius Michaelis
parent b8c1ef98e4
commit fc0cc3fe27

View File

@ -87,4 +87,29 @@ in {
).lower()
'';
};
chroot = makeTest {
name = "systemd-binfmt-chroot";
nodes.machine = { pkgs, lib, ... }: {
boot.binfmt.emulatedSystems = [
"aarch64-linux" "wasm32-wasi"
];
boot.binfmt.preferStaticEmulators = true;
environment.systemPackages = [
(pkgs.writeShellScriptBin "test-chroot" ''
set -euo pipefail
mkdir -p /tmp/chroot
cp ${lib.getExe' pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic.busybox "busybox"} /tmp/chroot/busybox
cp ${lib.getExe pkgs.pkgsCross.wasi32.yaml2json} /tmp/chroot/yaml2json # wasi binaries that build are hard to come by
chroot /tmp/chroot /busybox uname -m | grep aarch64
echo 42 | chroot /tmp/chroot /yaml2json | grep 42
'')
];
};
testScript = ''
machine.start()
machine.succeed("test-chroot")
'';
};
}