summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2019-11-26 21:57:07 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2019-11-26 21:58:30 +0100
commit696b44013eeae4668c1b7f0cf0d88fd81958fc0b (patch)
tree1717f3d1014e266590b0fccfb4786d08710b74ea /nixos/tests
parentad80b0a4c3b2d4f35fc363d1afe02db89096633a (diff)
downloadnixpkgs-696b44013eeae4668c1b7f0cf0d88fd81958fc0b.tar
nixpkgs-696b44013eeae4668c1b7f0cf0d88fd81958fc0b.tar.gz
nixpkgs-696b44013eeae4668c1b7f0cf0d88fd81958fc0b.tar.bz2
nixpkgs-696b44013eeae4668c1b7f0cf0d88fd81958fc0b.tar.lz
nixpkgs-696b44013eeae4668c1b7f0cf0d88fd81958fc0b.tar.xz
nixpkgs-696b44013eeae4668c1b7f0cf0d88fd81958fc0b.tar.zst
nixpkgs-696b44013eeae4668c1b7f0cf0d88fd81958fc0b.zip
nixos/xss-lock: port test to python test-driver
Also refactored the test script to have different subtests for different
configurations.
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/xss-lock.nix26
1 files changed, 15 insertions, 11 deletions
diff --git a/nixos/tests/xss-lock.nix b/nixos/tests/xss-lock.nix
index 0d757e8cef3..3a7dea07d53 100644
--- a/nixos/tests/xss-lock.nix
+++ b/nixos/tests/xss-lock.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, lib, ... }:
+import ./make-test-python.nix ({ pkgs, lib, ... }:
 
 with lib;
 
@@ -26,15 +26,19 @@ with lib;
   };
 
   testScript = ''
-    startAll;
-
-    ${concatStringsSep "\n" (mapAttrsToList (name: lockCmd: ''
-      ${"$"+name}->start;
-      ${"$"+name}->waitForX;
-      ${"$"+name}->waitForUnit("xss-lock.service", "alice");
-      ${"$"+name}->fail("pgrep ${lockCmd}");
-      ${"$"+name}->succeed("su -l alice -c 'xset dpms force standby'");
-      ${"$"+name}->waitUntilSucceeds("pgrep ${lockCmd}");
-    '') { simple = "i3lock"; custom_lockcmd = "xlock"; })}
+    def perform_xsslock_test(machine, lockCmd):
+        machine.start()
+        machine.wait_for_x()
+        machine.wait_for_unit("xss-lock.service", "alice")
+        machine.fail(f"pgrep {lockCmd}")
+        machine.succeed("su -l alice -c 'xset dpms force standby'")
+        machine.wait_until_succeeds(f"pgrep {lockCmd}")
+
+
+    with subtest("simple"):
+        perform_xsslock_test(simple, "i3lock")
+
+    with subtest("custom_cmd"):
+        perform_xsslock_test(custom_lockcmd, "xlock")
   '';
 })