about summary refs log tree commit diff
path: root/nixos/tests/teeworlds.nix
diff options
context:
space:
mode:
authorGeorg Haas <hax404foogit@hax404.de>2020-03-29 20:50:14 +0200
committerGeorg Haas <hax404foogit@hax404.de>2020-06-06 17:06:23 +0200
commit6d1ca7db4abbc7c8851df8c89683763396aebb83 (patch)
tree6c56d7d58ded2a714869e1a540f6e954729bfa16 /nixos/tests/teeworlds.nix
parentf0bee9760fa194c2a6c5e7a636d2aa63b99242da (diff)
nixos/{modules,tests}/teeworlds: init
add module and test
Diffstat (limited to 'nixos/tests/teeworlds.nix')
-rw-r--r--nixos/tests/teeworlds.nix55
1 files changed, 55 insertions, 0 deletions
diff --git a/nixos/tests/teeworlds.nix b/nixos/tests/teeworlds.nix
new file mode 100644
index 0000000000000..edf588968788c
--- /dev/null
+++ b/nixos/tests/teeworlds.nix
@@ -0,0 +1,55 @@
+import ./make-test-python.nix ({ pkgs, ... }:
+
+let
+  client =
+    { pkgs, ... }:
+
+    { imports = [ ./common/x11.nix ];
+      environment.systemPackages = [ pkgs.teeworlds ];
+    };
+
+in {
+  name = "teeworlds";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ hax404 ];
+  };
+
+  nodes =
+    { server =
+      { services.teeworlds = {
+          enable = true;
+          openPorts = true;
+        };
+      };
+
+      client1 = client;
+      client2 = client;
+    };
+
+    testScript =
+    ''
+      start_all()
+
+      server.wait_for_unit("teeworlds.service")
+      server.wait_until_succeeds("ss --numeric --udp --listening | grep -q 8303")
+
+      client1.wait_for_x()
+      client2.wait_for_x()
+
+      client1.execute("teeworlds 'player_name Alice;connect server'&")
+      server.wait_until_succeeds(
+          'journalctl -u teeworlds -e | grep --extended-regexp -q "team_join player=\'[0-9]:Alice"'
+      )
+
+      client2.execute("teeworlds 'player_name Bob;connect server'&")
+      server.wait_until_succeeds(
+          'journalctl -u teeworlds -e | grep --extended-regexp -q "team_join player=\'[0-9]:Bob"'
+      )
+
+      server.sleep(10)  # wait for a while to get a nice screenshot
+
+      client1.screenshot("screen_client1")
+      client2.screenshot("screen_client2")
+    '';
+
+})