From 7be89c1891dff3a1e24a821fa483eaae091ce8ab Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:57:36 +0200 Subject: [PATCH] nixosTests.xscreensaver: migrate to runTest Part of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/xscreensaver.nix | 150 +++++++++++++++++------------------ 2 files changed, 76 insertions(+), 76 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 7d8af87cd9eb..fe7043b81fc7 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1337,7 +1337,7 @@ in { xpadneo = runTest ./xpadneo.nix; xrdp = runTest ./xrdp.nix; xrdp-with-audio-pulseaudio = runTest ./xrdp-with-audio-pulseaudio.nix; - xscreensaver = handleTest ./xscreensaver.nix {}; + xscreensaver = runTest ./xscreensaver.nix; xss-lock = runTest ./xss-lock.nix; xterm = runTest ./xterm.nix; xxh = runTest ./xxh.nix; diff --git a/nixos/tests/xscreensaver.nix b/nixos/tests/xscreensaver.nix index a8ac81e08fd6..27f496cb9def 100644 --- a/nixos/tests/xscreensaver.nix +++ b/nixos/tests/xscreensaver.nix @@ -1,81 +1,81 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: - { - name = "pass-secret-service"; - meta.maintainers = with lib.maintainers; [ - vancluever - ]; +{ lib, ... }: +{ + name = "pass-secret-service"; + meta.maintainers = with lib.maintainers; [ + vancluever + ]; - nodes = { - ok = - { nodes, pkgs, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; - test-support.displayManager.auto.user = "alice"; - services.xscreensaver.enable = true; - }; + node.pkgsReadOnly = false; - empty_wrapperPrefix = - { nodes, pkgs, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; - test-support.displayManager.auto.user = "alice"; - services.xscreensaver.enable = true; - nixpkgs.overlays = [ - (self: super: { - xscreensaver = super.xscreensaver.override { - wrapperPrefix = ""; - }; - }) - ]; - }; + nodes = { + ok = + { nodes, pkgs, ... }: + { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; + test-support.displayManager.auto.user = "alice"; + services.xscreensaver.enable = true; + }; - bad_wrapperPrefix = - { nodes, pkgs, ... }: - { - imports = [ - ./common/x11.nix - ./common/user-account.nix - ]; - test-support.displayManager.auto.user = "alice"; - services.xscreensaver.enable = true; - nixpkgs.overlays = [ - (self: super: { - xscreensaver = super.xscreensaver.override { - wrapperPrefix = "/a/bad/path"; - }; - }) - ]; - }; - }; + empty_wrapperPrefix = + { nodes, pkgs, ... }: + { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; + test-support.displayManager.auto.user = "alice"; + services.xscreensaver.enable = true; + nixpkgs.overlays = [ + (self: super: { + xscreensaver = super.xscreensaver.override { + wrapperPrefix = ""; + }; + }) + ]; + }; - testScript = '' - ok.wait_for_x() - ok.wait_for_unit("xscreensaver", "alice") - _, output_ok = ok.systemctl("status xscreensaver", "alice") - assert 'To prevent the kernel from randomly unlocking' not in output_ok - assert 'your screen via the out-of-memory killer' not in output_ok - assert '"xscreensaver-auth" must be setuid root' not in output_ok + bad_wrapperPrefix = + { nodes, pkgs, ... }: + { + imports = [ + ./common/x11.nix + ./common/user-account.nix + ]; + test-support.displayManager.auto.user = "alice"; + services.xscreensaver.enable = true; + nixpkgs.overlays = [ + (self: super: { + xscreensaver = super.xscreensaver.override { + wrapperPrefix = "/a/bad/path"; + }; + }) + ]; + }; + }; - empty_wrapperPrefix.wait_for_x() - empty_wrapperPrefix.wait_for_unit("xscreensaver", "alice") - _, output_empty_wrapperPrefix = empty_wrapperPrefix.systemctl("status xscreensaver", "alice") - assert 'To prevent the kernel from randomly unlocking' in output_empty_wrapperPrefix - assert 'your screen via the out-of-memory killer' in output_empty_wrapperPrefix - assert '"xscreensaver-auth" must be setuid root' in output_empty_wrapperPrefix + testScript = '' + ok.wait_for_x() + ok.wait_for_unit("xscreensaver", "alice") + _, output_ok = ok.systemctl("status xscreensaver", "alice") + assert 'To prevent the kernel from randomly unlocking' not in output_ok + assert 'your screen via the out-of-memory killer' not in output_ok + assert '"xscreensaver-auth" must be setuid root' not in output_ok - bad_wrapperPrefix.wait_for_x() - bad_wrapperPrefix.wait_for_unit("xscreensaver", "alice") - _, output_bad_wrapperPrefix = bad_wrapperPrefix.systemctl("status xscreensaver", "alice") - assert 'To prevent the kernel from randomly unlocking' in output_bad_wrapperPrefix - assert 'your screen via the out-of-memory killer' in output_bad_wrapperPrefix - assert '"xscreensaver-auth" must be setuid root' in output_bad_wrapperPrefix - ''; - } -) + empty_wrapperPrefix.wait_for_x() + empty_wrapperPrefix.wait_for_unit("xscreensaver", "alice") + _, output_empty_wrapperPrefix = empty_wrapperPrefix.systemctl("status xscreensaver", "alice") + assert 'To prevent the kernel from randomly unlocking' in output_empty_wrapperPrefix + assert 'your screen via the out-of-memory killer' in output_empty_wrapperPrefix + assert '"xscreensaver-auth" must be setuid root' in output_empty_wrapperPrefix + + bad_wrapperPrefix.wait_for_x() + bad_wrapperPrefix.wait_for_unit("xscreensaver", "alice") + _, output_bad_wrapperPrefix = bad_wrapperPrefix.systemctl("status xscreensaver", "alice") + assert 'To prevent the kernel from randomly unlocking' in output_bad_wrapperPrefix + assert 'your screen via the out-of-memory killer' in output_bad_wrapperPrefix + assert '"xscreensaver-auth" must be setuid root' in output_bad_wrapperPrefix + ''; +}