diff options
author | squalus <squalus@squalus.net> | 2022-08-01 09:44:29 -0700 |
---|---|---|
committer | squalus <squalus@squalus.net> | 2022-08-01 09:52:56 -0700 |
commit | 257db1dd4a2dc4569ba5bfeb9d89f40cd891410c (patch) | |
tree | 2b2d47b870323ee4b1cc2b9088c7c91c32bc5019 /nixos/tests/systemd-coredump.nix | |
parent | 710292db8cd159bf6cb302bfe59326b2fd2154d9 (diff) |
nixos: systemd-coredump: improve disabled state
The systemd-coredump module required systemd to be built with withCoredump=true, even if the module was disabled. - allow systemd to be missing systemd-coredump if the module is disabled - switch to mkDefault for the sysctl config to allow user overrides when the module is disabled - add nixos tests for both the enabled and disabled cases
Diffstat (limited to 'nixos/tests/systemd-coredump.nix')
-rw-r--r-- | nixos/tests/systemd-coredump.nix | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/nixos/tests/systemd-coredump.nix b/nixos/tests/systemd-coredump.nix new file mode 100644 index 0000000000000..62137820878bd --- /dev/null +++ b/nixos/tests/systemd-coredump.nix @@ -0,0 +1,44 @@ +import ./make-test-python.nix ({ pkgs, ... }: + +let + + crasher = pkgs.writeCBin "crasher" "int main;"; + + commonConfig = { + systemd.services.crasher.serviceConfig = { + ExecStart = "${crasher}/bin/crasher"; + StateDirectory = "crasher"; + WorkingDirectory = "%S/crasher"; + Restart = "no"; + }; + }; + +in + +{ + name = "systemd-coredump"; + meta = with pkgs.lib.maintainers; { + maintainers = [ squalus ]; + }; + + nodes.machine1 = { pkgs, lib, ... }: commonConfig; + nodes.machine2 = { pkgs, lib, ... }: lib.recursiveUpdate commonConfig { + systemd.coredump.enable = false; + systemd.package = pkgs.systemd.override { + withCoredump = false; + }; + }; + + testScript = '' + with subtest("systemd-coredump enabled"): + machine1.wait_for_unit("multi-user.target") + machine1.wait_for_unit("systemd-coredump.socket") + machine1.systemctl("start crasher"); + machine1.wait_until_succeeds("coredumpctl list | grep crasher", timeout=10) + machine1.fail("stat /var/lib/crasher/core") + + with subtest("systemd-coredump disabled"): + machine2.systemctl("start crasher"); + machine2.wait_until_succeeds("stat /var/lib/crasher/core", timeout=10) + ''; +}) |