Skip to content

Commit 1aa7e7a

Browse files
committed
switch-to-configuration: add a test to make sure that we don't block on the lockfile
We should exit with a clear error message instead.
1 parent 125edf8 commit 1aa7e7a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

nixos/tests/switch-test.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,23 @@ in {
732732
out = switch_to_specialisation("${machine}", "modifiedSystemConf")
733733
assert_contains(out, "starting the following units: ${dbusService}\n")
734734
735+
with subtest("aborts on already locked lock file"):
736+
(exitcode, _) = machine.execute(
737+
'flock -x --nb /run/nixos/switch-to-configuration.lock -c "${otherSystem}/bin/switch-to-configuration test"',
738+
timeout=5
739+
)
740+
# See man timeout, exit codes above 124 come from the timeout command
741+
# We want to make sure that stc actually exited with an error code,
742+
# if instead we hit the timeout, then it means that stc hangs, which is
743+
# what we don't want
744+
# TODO: We cannot match on the exact exit code since it's not consistent between
745+
# stc and stc-ng, since errno/last_os_error is not a very stable interface,
746+
# we should probably get rid of that in stc-ng once we got rid of the
747+
# perl implementation
748+
assert exitcode < 124, \
749+
"switch-to-configuration did not abort as expected, " + \
750+
f"probably it timed out instead (exit code: {exitcode}), 124 means timeout"
751+
735752
with subtest("fstab mounts"):
736753
switch_to_specialisation("${machine}", "")
737754
# add a mountpoint

0 commit comments

Comments
 (0)