···95959696make_path("/run/nixos", { mode => oct(755) });
9797open(my $stc_lock, '>>', '/run/nixos/switch-to-configuration.lock') or die "Could not open lock - $!";
9898-flock($stc_lock, LOCK_EX) or die "Could not acquire lock - $!";
9898+flock($stc_lock, LOCK_EX|LOCK_NB) or die "Could not acquire lock - $!";
9999openlog("nixos", "", LOG_USER);
100100101101# run pre-switch checks
+17
nixos/tests/switch-test.nix
···732732 out = switch_to_specialisation("${machine}", "modifiedSystemConf")
733733 assert_contains(out, "starting the following units: ${dbusService}\n")
734734735735+ with subtest("aborts on already locked lock file"):
736736+ (exitcode, _) = machine.execute(
737737+ 'flock -x --nb /run/nixos/switch-to-configuration.lock -c "${otherSystem}/bin/switch-to-configuration test"',
738738+ timeout=5
739739+ )
740740+ # See man timeout, exit codes above 124 come from the timeout command
741741+ # We want to make sure that stc actually exited with an error code,
742742+ # if instead we hit the timeout, then it means that stc hangs, which is
743743+ # what we don't want
744744+ # TODO: We cannot match on the exact exit code since it's not consistent between
745745+ # stc and stc-ng, since errno/last_os_error is not a very stable interface,
746746+ # we should probably get rid of that in stc-ng once we got rid of the
747747+ # perl implementation
748748+ assert exitcode < 124, \
749749+ "switch-to-configuration did not abort as expected, " + \
750750+ f"probably it timed out instead (exit code: {exitcode}), 124 means timeout"
751751+735752 with subtest("fstab mounts"):
736753 switch_to_specialisation("${machine}", "")
737754 # add a mountpoint