nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at haskell-updates 101 lines 2.2 kB view raw
1# NOTE: Tests related to getRunpathEntries go here. 2{ 3 emptyFile, 4 getRunpathEntries, 5 hello, 6 lib, 7 pkgsStatic, 8 stdenv, 9 testers, 10}: 11let 12 inherit (lib.attrsets) recurseIntoAttrs; 13 inherit (testers) 14 shellcheck 15 shfmt 16 testBuildFailure' 17 testEqualArrayOrMap 18 ; 19 20 check = 21 { 22 name, 23 elfFile, 24 runpathEntries, 25 }: 26 (testEqualArrayOrMap { 27 inherit name; 28 expectedArray = runpathEntries; 29 script = '' 30 set -eu 31 nixLog "running getRunpathEntries with ''${elfFile@Q} to populate actualArray" 32 getRunpathEntries "$elfFile" actualArray || { 33 nixErrorLog "getRunpathEntries failed" 34 exit 1 35 } 36 ''; 37 }).overrideAttrs 38 (prevAttrs: { 39 inherit elfFile; 40 nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ getRunpathEntries ]; 41 meta = prevAttrs.meta or { } // { 42 platforms = lib.platforms.linux; 43 }; 44 }); 45in 46recurseIntoAttrs { 47 shellcheck = shellcheck { 48 name = "getRunpathEntries"; 49 src = ./getRunpathEntries.bash; 50 }; 51 52 shfmt = shfmt { 53 name = "getRunpathEntries"; 54 src = ./getRunpathEntries.bash; 55 }; 56} 57# Only tested on Linux. 58// lib.optionalAttrs stdenv.hostPlatform.isLinux { 59 # Not an ELF file 60 notElfFileFails = testBuildFailure' { 61 name = "notElfFileFails"; 62 drv = check { 63 name = "notElfFile"; 64 elfFile = emptyFile; 65 runpathEntries = [ ]; 66 }; 67 expectedBuilderLogEntries = [ 68 "getRunpathEntries failed" 69 ]; 70 }; 71 72 # Not a dynamic ELF file 73 staticElfFileFails = testBuildFailure' { 74 name = "staticElfFileFails"; 75 drv = check { 76 name = "staticElfFile"; 77 elfFile = lib.getExe pkgsStatic.hello; 78 runpathEntries = [ ]; 79 }; 80 expectedBuilderLogEntries = [ 81 "getRunpathEntries failed" 82 ]; 83 }; 84 85 hello = check { 86 name = "hello"; 87 elfFile = lib.getExe hello; 88 runpathEntries = [ 89 "${lib.getLib stdenv.cc.libc}/lib" 90 ]; 91 }; 92 93 libstdcplusplus = check { 94 name = "libstdcplusplus"; 95 elfFile = "${lib.getLib stdenv.cc.cc}/lib/libstdc++.so"; 96 runpathEntries = [ 97 "${lib.getLib stdenv.cc.cc}/lib" 98 "${lib.getLib stdenv.cc.libc}/lib" 99 ]; 100 }; 101}