lix/tests/nixos/coredumps/package.nix
2024-05-16 17:11:21 -07:00

16 lines
409 B
Nix

{ 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
''