diff options
author | midnightveil <midnight@trainwit.ch> | 2024-05-10 15:25:12 +1000 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-05-16 17:11:21 -0700 |
commit | 5b7dcb3005ed38d4634f228f01852ae18b2d9cd4 (patch) | |
tree | a254515d74a24144865ae37ef468306b2e112a85 /tests/nixos/coredumps | |
parent | 9322a1cbe775a32c7019a91236d9e37037b9241a (diff) |
Allow enabling core dumps from builds for nix & child processes
Fixes https://git.lix.systems/lix-project/lix/issues/268
Change-Id: I3f1b0ddf064f891cca8b53229c5c31c74cea3d9f
Diffstat (limited to 'tests/nixos/coredumps')
-rw-r--r-- | tests/nixos/coredumps/default.nix | 15 | ||||
-rw-r--r-- | tests/nixos/coredumps/package.nix | 16 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/nixos/coredumps/default.nix b/tests/nixos/coredumps/default.nix new file mode 100644 index 000000000..3d0d62945 --- /dev/null +++ b/tests/nixos/coredumps/default.nix @@ -0,0 +1,15 @@ +let + inherit (import ../util.nix) mkNixBuildTest; +in mkNixBuildTest rec { + name = "coredumps"; + extraMachineConfig = { pkgs, ... }: { + boot.kernel.sysctl."kernel.core_pattern" = "core"; + }; + + expressionFile = ./package.nix; + + testScriptPost = '' + # do a test, but this time with coredumps enabled. + machine.succeed('nix-build --option enable-core-dumps true --expr "let pkgs = import <nixpkgs> {}; in pkgs.callPackage ${expressionFile} { shouldBePresent = true; }"') + ''; +} diff --git a/tests/nixos/coredumps/package.nix b/tests/nixos/coredumps/package.nix new file mode 100644 index 000000000..a7f6434ed --- /dev/null +++ b/tests/nixos/coredumps/package.nix @@ -0,0 +1,16 @@ +{ lib, runCommand, shouldBePresent ? false }: + +runCommand "core-dump-now" { } '' + set -m + sleep infinity & + + # make a coredump + kill -SIGSEGV %1 + + if ${lib.optionalString (shouldBePresent) "!"} test -n "$(find . -maxdepth 1 -name 'core*' -print -quit)"; then + echo "core file was in wrong presence state, expected: ${if shouldBePresent then "present" else "missing"}" + exit 1 + fi + + touch $out +'' |