From 5143ab9f742d27086790e07ebf35f36cb6b26ade Mon Sep 17 00:00:00 2001 From: Ingo Blechschmidt Date: Mon, 13 Apr 2020 05:56:20 +0200 Subject: [PATCH 1/2] tigervnc, tightvnc: add basic tests Co-Authored-By: Ingo Blechschmidt --- nixos/lib/test-driver/test-driver.py | 4 +- nixos/tests/all-tests.nix | 1 + nixos/tests/tigervnc.nix | 53 +++++++++++++++++++++++++++ pkgs/tools/admin/tigervnc/default.nix | 3 ++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 nixos/tests/tigervnc.nix 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 76e5077f42d5..6abbc92d6438 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -421,6 +421,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 + ''; +} diff --git a/pkgs/tools/admin/tigervnc/default.nix b/pkgs/tools/admin/tigervnc/default.nix index 20d17b77741b..01579b059b08 100644 --- a/pkgs/tools/admin/tigervnc/default.nix +++ b/pkgs/tools/admin/tigervnc/default.nix @@ -7,6 +7,7 @@ , gnutls, pam, nettle , xterm, openssh, perl , makeWrapper +, nixosTests }: with lib; @@ -98,6 +99,8 @@ stdenv.mkDerivation rec { propagatedBuildInputs = xorg.xorgserver.propagatedBuildInputs; + passthru.tests.tigervnc = nixosTests.vnc.testTigerVNC; + meta = { homepage = "https://tigervnc.org/"; license = lib.licenses.gpl2Plus; From cfb935c54940115751270011a569ba3214984f5a Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Tue, 20 Jul 2021 15:21:49 +0200 Subject: [PATCH 2/2] tigervnc: remove fontDirectories These aren't necessary for tigervnc to function, and introduce an unfree dependency, so let's remove them. --- pkgs/tools/admin/tigervnc/default.nix | 8 -------- pkgs/top-level/all-packages.nix | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/pkgs/tools/admin/tigervnc/default.nix b/pkgs/tools/admin/tigervnc/default.nix index 01579b059b08..1ef584ec977f 100644 --- a/pkgs/tools/admin/tigervnc/default.nix +++ b/pkgs/tools/admin/tigervnc/default.nix @@ -1,7 +1,6 @@ { lib, stdenv, fetchFromGitHub , xorg, xkeyboard_config, zlib , libjpeg_turbo, pixman, fltk -, fontDirectories , cmake, gettext, libtool , libGLU , gnutls, pam, nettle @@ -23,17 +22,10 @@ stdenv.mkDerivation rec { sha256 = "sha256-IX39oEhTyk7NV+9dD9mFtes22fBdMTAVIv5XkqFK560="; }; - inherit fontDirectories; postPatch = '' sed -i -e '/^\$cmd \.= " -pn";/a$cmd .= " -xkbdir ${xkeyboard_config}/etc/X11/xkb";' unix/vncserver/vncserver.in fontPath= - for i in $fontDirectories; do - for j in $(find $i -name fonts.dir); do - addToSearchPathWithCustomDelimiter "," fontPath $(dirname $j) - done - done - sed -i -e '/^\$cmd \.= " -pn";/a$cmd .= " -fp '"$fontPath"'";' unix/vncserver/vncserver.in substituteInPlace vncviewer/vncviewer.cxx \ --replace '"/usr/bin/ssh' '"${openssh}/bin/ssh' ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1c3366e81d33..e2bd3bcb3210 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9878,9 +9878,7 @@ in tftp-hpa = callPackage ../tools/networking/tftp-hpa {}; - tigervnc = callPackage ../tools/admin/tigervnc { - fontDirectories = [ xorg.fontadobe75dpi xorg.fontmiscmisc xorg.fontcursormisc xorg.fontbhlucidatypewriter75dpi ]; - }; + tigervnc = callPackage ../tools/admin/tigervnc {}; tightvnc = callPackage ../tools/admin/tightvnc { fontDirectories = [ xorg.fontadobe75dpi xorg.fontmiscmisc xorg.fontcursormisc