summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMichael Weiss <dev.primeos@gmail.com>2021-12-28 21:32:26 +0100
committerMichael Weiss <dev.primeos@gmail.com>2022-01-06 17:31:57 +0100
commite9efbc0bbb222cc90d14ba919f77bb198dd2d55f (patch)
tree6710cf64f4afe111fd163c10fdefb8303f6d6693 /nixos
parent2bc8eed5b92a27a361553dbabc81c2ffb56971f0 (diff)
downloadnixpkgs-e9efbc0bbb222cc90d14ba919f77bb198dd2d55f.tar
nixpkgs-e9efbc0bbb222cc90d14ba919f77bb198dd2d55f.tar.gz
nixpkgs-e9efbc0bbb222cc90d14ba919f77bb198dd2d55f.tar.bz2
nixpkgs-e9efbc0bbb222cc90d14ba919f77bb198dd2d55f.tar.lz
nixpkgs-e9efbc0bbb222cc90d14ba919f77bb198dd2d55f.tar.xz
nixpkgs-e9efbc0bbb222cc90d14ba919f77bb198dd2d55f.tar.zst
nixpkgs-e9efbc0bbb222cc90d14ba919f77bb198dd2d55f.zip
nixos/tests/tinywl: init
This adds a very minimalistic (in terms of functionality and
dependencies) test for wlroots, Wayland, and related packages.

The Sway test covers more functionality and packages (e.g. XWayland) but
this test has tree advantages:
- Less dependencies: Much fewer rebuilds are required when testing core
  changes that need to go through staging.
- Testing wlroots updates: The Sway package isn't immediately updated
  after a new wlroots version is released and a lot of other packages
  depend on wlroots as well.
- Determining whether a bug only affects Sway or wlroots/TinyWL as well.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/tinywl.nix56
2 files changed, 57 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 4f62980e8e9..dc28b3d6478 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -476,6 +476,7 @@ in
   timezone = handleTest ./timezone.nix {};
   tinc = handleTest ./tinc {};
   tinydns = handleTest ./tinydns.nix {};
+  tinywl = handleTest ./tinywl.nix {};
   tor = handleTest ./tor.nix {};
   # traefik test relies on docker-containers
   traefik = handleTestOn ["x86_64-linux"] ./traefik.nix {};
diff --git a/nixos/tests/tinywl.nix b/nixos/tests/tinywl.nix
new file mode 100644
index 00000000000..b286cab7794
--- /dev/null
+++ b/nixos/tests/tinywl.nix
@@ -0,0 +1,56 @@
+import ./make-test-python.nix ({ pkgs, lib, ... }:
+
+  {
+    name = "tinywl";
+    meta = {
+      maintainers = with lib.maintainers; [ primeos ];
+    };
+
+    machine = { config, ... }: {
+      # Automatically login on tty1 as a normal user:
+      imports = [ ./common/user-account.nix ];
+      services.getty.autologinUser = "alice";
+
+      environment = {
+        systemPackages = with pkgs; [ tinywl foot wayland-utils ];
+      };
+
+      # Automatically start TinyWL when logging in on tty1:
+      programs.bash.loginShellInit = ''
+        if [ "$(tty)" = "/dev/tty1" ]; then
+          set -e
+          test ! -e /tmp/tinywl.log # Only start tinywl once
+          readonly TEST_CMD="wayland-info |& tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok; read"
+          readonly FOOT_CMD="foot sh -c '$TEST_CMD'"
+          tinywl -s "$FOOT_CMD" |& tee /tmp/tinywl.log
+          touch /tmp/tinywl-exit-ok
+        fi
+      '';
+
+      # Switch to a different GPU driver (default: -vga std), otherwise TinyWL segfaults:
+      virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
+    };
+
+    testScript = { nodes, ... }: ''
+      start_all()
+      machine.wait_for_unit("multi-user.target")
+
+      # Wait for complete startup:
+      machine.wait_until_succeeds("pgrep tinywl")
+      machine.wait_for_file("/run/user/1000/wayland-0")
+      machine.wait_until_succeeds("pgrep foot")
+      machine.wait_for_file("/tmp/test-wayland-exit-ok")
+
+      # Make a screenshot and save the result:
+      machine.screenshot("tinywl_foot")
+      print(machine.succeed("cat /tmp/test-wayland.out"))
+      machine.copy_from_vm("/tmp/test-wayland.out")
+
+      # Terminate cleanly:
+      machine.send_key("alt-esc")
+      machine.wait_until_fails("pgrep foot")
+      machine.wait_until_fails("pgrep tinywl")
+      machine.wait_for_file("/tmp/tinywl-exit-ok")
+      machine.copy_from_vm("/tmp/tinywl.log")
+    '';
+  })