about summary refs log tree commit diff
path: root/nixpkgs/pkgs/test/make-binary-wrapper/cross.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/test/make-binary-wrapper/cross.nix')
-rw-r--r--nixpkgs/pkgs/test/make-binary-wrapper/cross.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/test/make-binary-wrapper/cross.nix b/nixpkgs/pkgs/test/make-binary-wrapper/cross.nix
new file mode 100644
index 000000000000..64912364b863
--- /dev/null
+++ b/nixpkgs/pkgs/test/make-binary-wrapper/cross.nix
@@ -0,0 +1,28 @@
+{ stdenv
+, runCommand
+, makeBinaryWrapper
+, binutils
+, lib
+, expectedArch ? stdenv.hostPlatform.parsed.cpu.name
+}:
+
+
+runCommand "make-binary-wrapper-test-cross" {
+  nativeBuildInputs = [
+    makeBinaryWrapper
+    binutils
+  ];
+  # For x86_64-linux the machine field is
+  # Advanced Micro Devices X86-64
+  # and uses a dash instead of a underscore unlike x86_64-linux in hostPlatform.parsed.cpu.name
+  expectedArch = lib.replaceStrings ["_"] ["-"] expectedArch;
+} ''
+  touch prog
+  chmod +x prog
+  makeWrapper prog $out
+  read -r _ arch < <($READELF --file-header $out | grep Machine:)
+  if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
+    echo "expected $expectedArch, got $arch"
+    exit 1
+  fi
+''