Commit 40f95978 authored by Yarny0's avatar Yarny0
Browse files

zoom-us: add simple test

This test starts zoom with an Xvfb X server and
verifies that the "Zoom Workplace" window is created.
zoom is started with `prlimit` to avoid problems like
https://github.com/NixOS/nixpkgs/issues/371488 .

Note: During my experiments, it turned out that if certain
libraries are missing (I don't recall which ones),
then zoom still opens its Workplace window,
then immediatelly closes it again.
To reduce the likelihood of the test passing in
that scenario, another "sleep 20" is included.
parent 64e75cd4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
  pulseaudioSupport ? true,
  libpulseaudio,
  pulseaudio,
  callPackage,
}:

let
@@ -220,6 +221,7 @@ stdenv.mkDerivation {
  dontPatchELF = true;

  passthru.updateScript = ./update.sh;
  passthru.tests.startwindow = callPackage ./test.nix { };

  meta = with lib; {
    homepage = "https://zoom.us/";
+44 −0
Original line number Diff line number Diff line
{
  lib,
  xvfb-run,
  zoom-us,
  runCommand,
  writeShellApplication,
  xorg,
}:

let
  testScript = writeShellApplication {
    name = "zoom-us-test-script";
    runtimeInputs = [
      xorg.xwininfo
      zoom-us
    ];
    text = ''
      function is_zoom_window_present {
        echo
        xwininfo -root -tree  \
            | sed 's/.*0x[0-9a-f]* \"\([^\"]*\)\".*/\1/; t; d'  \
            | tee window-names
        grep -q "Zoom Workplace" window-names
      }
      # don't let zoom eat all RAM, like it did
      # https://github.com/NixOS/nixpkgs/issues/371488
      prlimit --{as,data}=$((4*2**30)):$((4*2**30)) zoom-us &
      for _ in {0..900} ; do
        if is_zoom_window_present ; then
          break
        fi
        sleep 1
      done
      # if libraries are missing, the window still appears,
      # but disappears again immediatelly; check for that too:
      sleep 20
      is_zoom_window_present
    '';
  };
in
runCommand "zoom-us-test" { buildInputs = [ xvfb-run ]; } ''
  HOME=$PWD xvfb-run ${lib.getExe testScript}
  touch ${placeholder "out"}
''