at 23.05-pre 2.2 kB view raw
1# Teach the kernel how to run armv7l and aarch64-linux binaries, 2# and run GNU Hello for these architectures. 3 4{ system ? builtins.currentSystem, 5 config ? {}, 6 pkgs ? import ../.. { inherit system config; } 7}: 8 9with import ../lib/testing-python.nix { inherit system pkgs; }; 10 11let 12 expectArgv0 = xpkgs: xpkgs.runCommandCC "expect-argv0" { 13 src = pkgs.writeText "expect-argv0.c" '' 14 #include <stdio.h> 15 #include <string.h> 16 17 int main(int argc, char **argv) { 18 fprintf(stderr, "Our argv[0] is %s\n", argv[0]); 19 20 if (strcmp(argv[0], argv[1])) { 21 fprintf(stderr, "ERROR: argv[0] is %s, should be %s\n", argv[0], argv[1]); 22 return 1; 23 } 24 25 return 0; 26 } 27 ''; 28 } '' 29 $CC -o $out $src 30 ''; 31in { 32 basic = makeTest { 33 name = "systemd-binfmt"; 34 nodes.machine = { 35 boot.binfmt.emulatedSystems = [ 36 "armv7l-linux" 37 "aarch64-linux" 38 ]; 39 }; 40 41 testScript = let 42 helloArmv7l = pkgs.pkgsCross.armv7l-hf-multiplatform.hello; 43 helloAarch64 = pkgs.pkgsCross.aarch64-multiplatform.hello; 44 in '' 45 machine.start() 46 47 assert "world" in machine.succeed( 48 "${helloArmv7l}/bin/hello" 49 ) 50 51 assert "world" in machine.succeed( 52 "${helloAarch64}/bin/hello" 53 ) 54 ''; 55 }; 56 57 preserveArgvZero = makeTest { 58 name = "systemd-binfmt-preserve-argv0"; 59 nodes.machine = { 60 boot.binfmt.emulatedSystems = [ 61 "aarch64-linux" 62 ]; 63 }; 64 testScript = let 65 testAarch64 = expectArgv0 pkgs.pkgsCross.aarch64-multiplatform; 66 in '' 67 machine.start() 68 machine.succeed("exec -a meow ${testAarch64} meow") 69 ''; 70 }; 71 72 ldPreload = makeTest { 73 name = "systemd-binfmt-ld-preload"; 74 nodes.machine = { 75 boot.binfmt.emulatedSystems = [ 76 "aarch64-linux" 77 ]; 78 }; 79 testScript = let 80 helloAarch64 = pkgs.pkgsCross.aarch64-multiplatform.hello; 81 libredirectAarch64 = pkgs.pkgsCross.aarch64-multiplatform.libredirect; 82 in '' 83 machine.start() 84 85 assert "error" not in machine.succeed( 86 "LD_PRELOAD='${libredirectAarch64}/lib/libredirect.so' ${helloAarch64}/bin/hello 2>&1" 87 ).lower() 88 ''; 89 }; 90}