nixosTests.xss-lock: migrate to runTest

Part Of #386873
This commit is contained in:
Martin Weinelt 2025-03-14 23:07:18 +01:00
parent 20ad3329fe
commit 650ab40c81
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
2 changed files with 39 additions and 42 deletions

View file

@ -1295,7 +1295,7 @@ in {
xrdp = handleTest ./xrdp.nix {}; xrdp = handleTest ./xrdp.nix {};
xrdp-with-audio-pulseaudio = handleTest ./xrdp-with-audio-pulseaudio.nix {}; xrdp-with-audio-pulseaudio = handleTest ./xrdp-with-audio-pulseaudio.nix {};
xscreensaver = handleTest ./xscreensaver.nix {}; xscreensaver = handleTest ./xscreensaver.nix {};
xss-lock = handleTest ./xss-lock.nix {}; xss-lock = runTest ./xss-lock.nix;
xterm = runTest ./xterm.nix; xterm = runTest ./xterm.nix;
xxh = runTest ./xxh.nix; xxh = runTest ./xxh.nix;
yabar = runTest ./yabar.nix; yabar = runTest ./yabar.nix;

View file

@ -1,54 +1,51 @@
import ./make-test-python.nix ( {
{ pkgs, lib, ... }: name = "xss-lock";
{ meta.maintainers = [ ];
name = "xss-lock";
meta.maintainers = [ ];
nodes = { nodes = {
simple = { simple = {
imports = [
./common/x11.nix
./common/user-account.nix
];
programs.xss-lock.enable = true;
test-support.displayManager.auto.user = "alice";
};
custom_lockcmd =
{ pkgs, ... }:
{
imports = [ imports = [
./common/x11.nix ./common/x11.nix
./common/user-account.nix ./common/user-account.nix
]; ];
programs.xss-lock.enable = true;
test-support.displayManager.auto.user = "alice"; test-support.displayManager.auto.user = "alice";
};
custom_lockcmd = programs.xss-lock = {
{ pkgs, ... }: enable = true;
{ extraOptions = [
imports = [ "-n"
./common/x11.nix "${pkgs.libnotify}/bin/notify-send 'About to sleep!'"
./common/user-account.nix
]; ];
test-support.displayManager.auto.user = "alice"; lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
programs.xss-lock = {
enable = true;
extraOptions = [
"-n"
"${pkgs.libnotify}/bin/notify-send 'About to sleep!'"
];
lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
};
}; };
}; };
};
testScript = '' testScript = ''
def perform_xsslock_test(machine, lockCmd): def perform_xsslock_test(machine, lockCmd):
machine.start() machine.start()
machine.wait_for_x() machine.wait_for_x()
machine.wait_for_unit("xss-lock.service", "alice") machine.wait_for_unit("xss-lock.service", "alice")
machine.fail(f"pgrep {lockCmd}") machine.fail(f"pgrep {lockCmd}")
machine.succeed("su -l alice -c 'xset dpms force standby'") machine.succeed("su -l alice -c 'xset dpms force standby'")
machine.wait_until_succeeds(f"pgrep {lockCmd}") machine.wait_until_succeeds(f"pgrep {lockCmd}")
with subtest("simple"): with subtest("simple"):
perform_xsslock_test(simple, "i3lock") perform_xsslock_test(simple, "i3lock")
with subtest("custom_cmd"): with subtest("custom_cmd"):
perform_xsslock_test(custom_lockcmd, "xlock") perform_xsslock_test(custom_lockcmd, "xlock")
''; '';
} }
)