about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-07-20 17:00:09 +0200
committerGitHub <noreply@github.com>2021-07-20 17:00:09 +0200
commit72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e (patch)
treef47a42f3f6545be93279849b4b2ea946a0b47891 /nixos
parentb4aa9877d3ca954d03b234938eb900ad43910b39 (diff)
parentcfb935c54940115751270011a569ba3214984f5a (diff)
downloadnixlib-72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e.tar
nixlib-72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e.tar.gz
nixlib-72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e.tar.bz2
nixlib-72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e.tar.lz
nixlib-72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e.tar.xz
nixlib-72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e.tar.zst
nixlib-72d1d4cb20b23b1ffaf37c23c7d8376def9fc49e.zip
Merge pull request #130778 from mayflower/tigervnc-tests-and-no-proprietary-fonts
Tigervnc tests and no proprietary fonts
Diffstat (limited to 'nixos')
-rw-r--r--nixos/lib/test-driver/test-driver.py4
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/tigervnc.nix53
3 files changed, 56 insertions, 2 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index 15eaba88476f..2a3e4d94b948 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -499,7 +499,7 @@ class Machine:
                 output += out
         return output
 
-    def wait_until_succeeds(self, command: str) -> str:
+    def wait_until_succeeds(self, command: str, timeout: int = 900) -> str:
         """Wait until a command returns success and return its output.
         Throws an exception on timeout.
         """
@@ -511,7 +511,7 @@ class Machine:
             return status == 0
 
         with self.nested("waiting for success: {}".format(command)):
-            retry(check_success)
+            retry(check_success, timeout)
             return output
 
     def wait_until_fails(self, command: str) -> str:
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 746139c48169..0e2104a20e2d 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -424,6 +424,7 @@ in
   taskserver = handleTest ./taskserver.nix {};
   telegraf = handleTest ./telegraf.nix {};
   tiddlywiki = handleTest ./tiddlywiki.nix {};
+  tigervnc = handleTest ./tigervnc.nix {};
   timezone = handleTest ./timezone.nix {};
   tinc = handleTest ./tinc {};
   tinydns = handleTest ./tinydns.nix {};
diff --git a/nixos/tests/tigervnc.nix b/nixos/tests/tigervnc.nix
new file mode 100644
index 000000000000..c0a52808b279
--- /dev/null
+++ b/nixos/tests/tigervnc.nix
@@ -0,0 +1,53 @@
+{ system ? builtins.currentSystem
+, config ? {}
+, pkgs ? import ../.. { inherit system config; }
+}:
+
+with import ../lib/testing-python.nix { inherit system pkgs; };
+makeTest {
+  name = "tigervnc";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ lheckemann ];
+  };
+
+  nodes = {
+    server = { pkgs, ...}: {
+      environment.systemPackages = with pkgs; [
+        tigervnc # for Xvnc
+        xorg.xwininfo
+        imagemagickBig # for display with working label: support
+      ];
+      networking.firewall.allowedTCPPorts = [ 5901 ];
+    };
+
+    client = { pkgs, ... }: {
+      imports = [ ./common/x11.nix ];
+      # for vncviewer
+      environment.systemPackages = [ pkgs.tigervnc ];
+    };
+  };
+
+  enableOCR = true;
+
+  testScript = ''
+    start_all()
+
+    for host in [server, client]:
+        host.succeed("echo foobar | vncpasswd -f > vncpasswd")
+
+    server.succeed("Xvnc -geometry 720x576 :1 -PasswordFile vncpasswd &")
+    server.wait_until_succeeds("nc -z localhost 5901", timeout=10)
+    server.succeed("DISPLAY=:1 xwininfo -root | grep 720x576")
+    server.execute("DISPLAY=:1 display -size 360x200 -font sans -gravity south label:'HELLO VNC WORLD' &")
+
+    client.wait_for_x()
+    client.execute("vncviewer server:1 -PasswordFile vncpasswd &")
+    client.wait_for_window(r"VNC")
+    client.screenshot("screenshot")
+    text = client.get_screen_text()
+    # Displayed text
+    assert 'HELLO VNC WORLD' in text
+    # Client window title
+    assert 'TigerVNC' in text
+  '';
+}