Commit fc0cc3fe authored by Zhaofeng Li's avatar Zhaofeng Li Committed by Julius Michaelis
Browse files

nixos/tests/systemd-binfmt: Add chroot test

parent b8c1ef98
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -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")
    '';
  };
}