aboutsummaryrefslogtreecommitdiff
path: root/tests/nixos/coredumps/package.nix
blob: a7f6434ed64e943d0c9f5974efe383fd70d8b2f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
''