at master 2.8 kB view raw
1{ pkgs, lib, ... }: 2let 3 secret-key = "key-name:/COlMSRbehSh6YSruJWjL+R0JXQUKuPEn96fIb+pLokEJUjcK/2Gv8Ai96D7JGay5gDeUTx5wdpPgNvum9YtwA=="; 4 public-key = "key-name:BCVI3Cv9hr/AIveg+yRmsuYA3lE8ecHaT4Db7pvWLcA="; 5in 6{ 7 name = "nixseparatedebuginfod"; 8 # A binary cache with debug info and source for gnumake 9 nodes.cache = 10 { pkgs, ... }: 11 { 12 services.nix-serve = { 13 enable = true; 14 secretKeyFile = builtins.toFile "secret-key" secret-key; 15 openFirewall = true; 16 }; 17 system.extraDependencies = [ 18 pkgs.gnumake.debug 19 pkgs.gnumake.src 20 pkgs.sl 21 ]; 22 }; 23 # the machine where we need the debuginfo 24 nodes.machine = { 25 imports = [ 26 ../modules/installer/cd-dvd/channel.nix 27 ]; 28 services.nixseparatedebuginfod.enable = true; 29 nix.settings = { 30 substituters = lib.mkForce [ "http://cache:5000" ]; 31 trusted-public-keys = [ public-key ]; 32 }; 33 environment.systemPackages = [ 34 pkgs.valgrind 35 pkgs.gdb 36 pkgs.gnumake 37 (pkgs.writeShellScriptBin "wait_for_indexation" '' 38 set -x 39 while debuginfod-find debuginfo /run/current-system/sw/bin/make |& grep 'File too large'; do 40 sleep 1; 41 done 42 '') 43 ]; 44 }; 45 testScript = '' 46 start_all() 47 cache.wait_for_unit("nix-serve.service") 48 cache.wait_for_open_port(5000) 49 machine.wait_for_unit("nixseparatedebuginfod.service") 50 machine.wait_for_open_port(1949) 51 52 with subtest("show the config to debug the test"): 53 machine.succeed("nix --extra-experimental-features nix-command show-config |& logger") 54 machine.succeed("cat /etc/nix/nix.conf |& logger") 55 with subtest("check that the binary cache works"): 56 machine.succeed("nix-store -r ${pkgs.sl}") 57 58 # nixseparatedebuginfod needs .drv to associate executable -> source 59 # on regular systems this would be provided by nixos-rebuild 60 machine.succeed("nix-instantiate '<nixpkgs>' -A gnumake") 61 62 machine.succeed("timeout 600 wait_for_indexation") 63 64 # test debuginfod-find 65 machine.succeed("debuginfod-find debuginfo /run/current-system/sw/bin/make") 66 67 # test that gdb can fetch source 68 out = machine.succeed("gdb /run/current-system/sw/bin/make --batch -x ${builtins.toFile "commands" '' 69 start 70 l 71 ''}") 72 print(out) 73 assert 'main (int argc, char **argv, char **envp)' in out 74 75 # test that valgrind can display location information 76 # this relies on the fact that valgrind complains about gnumake 77 # because we also ask valgrind to show leak kinds 78 # which are usually false positives. 79 out = machine.succeed("valgrind --leak-check=full --show-leak-kinds=all make --version 2>&1") 80 print(out) 81 assert 'main.c' in out 82 ''; 83}