11 env = { nativeBuildInputs = [ makeBinaryWrapper ]; };
12 envCheck = runCommandCC "envcheck" env ''
13 cc -Wall -Werror -Wpedantic -o $out ${./envcheck.c}
15 makeGoldenTest = testname: runCommand "make-binary-wrapper-test-${testname}" env ''
16 mkdir -p tmp/foo # for the chdir test
18 params=$(<"${./.}/${testname}.cmdline")
19 eval "makeCWrapper /send/me/flags $params" > wrapper.c
21 diff wrapper.c "${./.}/${testname}.c"
23 if [ -f "${./.}/${testname}.env" ]; then
24 eval "makeWrapper ${envCheck} wrapped $params"
25 env -i ./wrapped > env.txt
26 sed "s#SUBST_ARGV0#${envCheck}#;s#SUBST_CWD#$PWD#" \
27 "${./.}/${testname}.env" > golden-env.txt
28 if ! diff env.txt golden-env.txt; then
29 echo "env/argv should be:"
31 echo "env/argv output is:"
36 # without a golden env, we expect the wrapper compilation to fail
37 ! eval "makeWrapper ${envCheck} wrapped $params" &> error.txt
42 tests = lib.genAttrs [
54 ] makeGoldenTest // lib.optionalAttrs (! stdenv.isDarwin) {
55 cross = pkgsCross.${if stdenv.buildPlatform.isAarch64 then "gnu64" else "aarch64-multiplatform"}.callPackage ./cross.nix { };
59 writeText "make-binary-wrapper-tests" ''
60 ${lib.concatStringsSep "\n" (builtins.attrValues tests)}