2020-05-18 11:16:56 +02:00
|
|
|
# Teach the kernel how to run armv7l and aarch64-linux binaries,
|
|
|
|
# and run GNU Hello for these architectures.
|
|
|
|
|
2021-10-28 10:03:50 +02:00
|
|
|
{ system ? builtins.currentSystem,
|
|
|
|
config ? {},
|
|
|
|
pkgs ? import ../.. { inherit system config; }
|
|
|
|
}:
|
|
|
|
|
|
|
|
with import ../lib/testing-python.nix { inherit system pkgs; };
|
|
|
|
|
|
|
|
let
|
|
|
|
expectArgv0 = xpkgs: xpkgs.runCommandCC "expect-argv0" {
|
|
|
|
src = pkgs.writeText "expect-argv0.c" ''
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
fprintf(stderr, "Our argv[0] is %s\n", argv[0]);
|
|
|
|
|
|
|
|
if (strcmp(argv[0], argv[1])) {
|
|
|
|
fprintf(stderr, "ERROR: argv[0] is %s, should be %s\n", argv[0], argv[1]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
} ''
|
|
|
|
$CC -o $out $src
|
2020-05-18 11:16:56 +02:00
|
|
|
'';
|
2021-10-28 10:03:50 +02:00
|
|
|
in {
|
|
|
|
basic = makeTest {
|
|
|
|
name = "systemd-binfmt";
|
|
|
|
machine = {
|
|
|
|
boot.binfmt.emulatedSystems = [
|
|
|
|
"armv7l-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = let
|
|
|
|
helloArmv7l = pkgs.pkgsCross.armv7l-hf-multiplatform.hello;
|
|
|
|
helloAarch64 = pkgs.pkgsCross.aarch64-multiplatform.hello;
|
|
|
|
in ''
|
|
|
|
machine.start()
|
|
|
|
|
|
|
|
assert "world" in machine.succeed(
|
|
|
|
"${helloArmv7l}/bin/hello"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert "world" in machine.succeed(
|
|
|
|
"${helloAarch64}/bin/hello"
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
preserveArgvZero = makeTest {
|
|
|
|
name = "systemd-binfmt-preserve-argv0";
|
|
|
|
machine = {
|
|
|
|
boot.binfmt.emulatedSystems = [
|
|
|
|
"aarch64-linux"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
testScript = let
|
|
|
|
testAarch64 = expectArgv0 pkgs.pkgsCross.aarch64-multiplatform;
|
|
|
|
in ''
|
|
|
|
machine.start()
|
|
|
|
machine.succeed("exec -a meow ${testAarch64} meow")
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|