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