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