1import ./make-test-python.nix ({ pkgs, lib, ... }:
2
3 {
4 name = "tinywl";
5 meta = {
6 maintainers = with lib.maintainers; [ primeos ];
7 };
8
9 nodes.machine = { config, ... }: {
10 # Automatically login on tty1 as a normal user:
11 imports = [ ./common/user-account.nix ];
12 services.getty.autologinUser = "alice";
13 security.polkit.enable = true;
14
15 environment = {
16 systemPackages = with pkgs; [ tinywl foot wayland-utils ];
17 };
18
19 hardware.opengl.enable = true;
20
21 # Automatically start TinyWL when logging in on tty1:
22 programs.bash.loginShellInit = ''
23 if [ "$(tty)" = "/dev/tty1" ]; then
24 set -e
25 test ! -e /tmp/tinywl.log # Only start tinywl once
26 readonly TEST_CMD="wayland-info |& tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok; read"
27 readonly FOOT_CMD="foot sh -c '$TEST_CMD'"
28 tinywl -s "$FOOT_CMD" |& tee /tmp/tinywl.log
29 touch /tmp/tinywl-exit-ok
30 fi
31 '';
32
33 # Switch to a different GPU driver (default: -vga std), otherwise TinyWL segfaults:
34 virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
35 };
36
37 testScript = { nodes, ... }: ''
38 start_all()
39 machine.wait_for_unit("multi-user.target")
40
41 # Wait for complete startup:
42 machine.wait_until_succeeds("pgrep tinywl")
43 machine.wait_for_file("/run/user/1000/wayland-0")
44 machine.wait_until_succeeds("pgrep foot")
45 machine.wait_for_file("/tmp/test-wayland-exit-ok")
46
47 # Make a screenshot and save the result:
48 machine.screenshot("tinywl_foot")
49 print(machine.succeed("cat /tmp/test-wayland.out"))
50 machine.copy_from_vm("/tmp/test-wayland.out")
51
52 # Terminate cleanly:
53 machine.send_key("alt-esc")
54 machine.wait_until_fails("pgrep foot")
55 machine.wait_until_fails("pgrep tinywl")
56 machine.wait_for_file("/tmp/tinywl-exit-ok")
57 machine.copy_from_vm("/tmp/tinywl.log")
58 '';
59 })