|
| 1 | +import ./make-test-python.nix ( |
| 2 | + { |
| 3 | + pkgs, |
| 4 | + lib ? pkgs.lib, |
| 5 | + ... |
| 6 | + }: |
| 7 | + |
| 8 | + let |
| 9 | + inherit (pkgs) |
| 10 | + writeShellScript |
| 11 | + gnome-shell |
| 12 | + gnome-backgrounds |
| 13 | + stardust-xr-server |
| 14 | + stardust-xr-flatland |
| 15 | + weston |
| 16 | + monado |
| 17 | + ; |
| 18 | + sleepScript = writeShellScript "sleep" "sleep 3"; |
| 19 | + in |
| 20 | + { |
| 21 | + name = "stardust-xr-server"; |
| 22 | + meta = { |
| 23 | + maintainers = with lib.maintainers; [ |
| 24 | + pandapip1 |
| 25 | + technobaboo |
| 26 | + matthewcroughan |
| 27 | + ]; |
| 28 | + }; |
| 29 | + nodes.machine = |
| 30 | + { ... }: |
| 31 | + { |
| 32 | + imports = [ ./common/user-account.nix ]; |
| 33 | + virtualisation.qemu.options = [ |
| 34 | + "-device virtio-gpu-pci" |
| 35 | + ]; |
| 36 | + environment.systemPackages = [ monado ]; |
| 37 | + services = { |
| 38 | + xserver = { |
| 39 | + enable = true; |
| 40 | + desktopManager.gnome = { |
| 41 | + enable = true; |
| 42 | + debug = true; |
| 43 | + # Set a nice desktop background that is pleasing to the eyes |
| 44 | + extraGSettingsOverrides = '' |
| 45 | + [org.gnome.desktop.background] |
| 46 | + picture-uri='file://${gnome-backgrounds}/share/backgrounds/gnome/blobs-l.svg' |
| 47 | + picture-uri-dark='file://${gnome-backgrounds}/share/backgrounds/gnome/blobs-l.svg' |
| 48 | + ''; |
| 49 | + }; |
| 50 | + displayManager = { |
| 51 | + gdm = { |
| 52 | + enable = true; |
| 53 | + debug = true; |
| 54 | + }; |
| 55 | + }; |
| 56 | + }; |
| 57 | + displayManager = { |
| 58 | + autoLogin = { |
| 59 | + enable = true; |
| 60 | + user = "alice"; |
| 61 | + }; |
| 62 | + }; |
| 63 | + }; |
| 64 | + systemd.user.services = { |
| 65 | + monado = { |
| 66 | + after = [ |
| 67 | + "graphical-session.target" |
| 68 | + "default.target" |
| 69 | + "org.gnome.Shell@wayland.service" |
| 70 | + ]; |
| 71 | + environment = { |
| 72 | + XRT_COMPOSITOR_FORCE_WAYLAND = "1"; |
| 73 | + WAYLAND_DISPLAY = "wayland-0"; |
| 74 | + }; |
| 75 | + serviceConfig = { |
| 76 | + ExecStartPre = sleepScript; |
| 77 | + # stdin disappears in NixOS test driver ( machine.succeed() ), requiring us to specify < /dev/ttyS0 to fake stdin |
| 78 | + ExecStart = "${lib.getExe' pkgs.monado "monado-service"} < /dev/ttyS0"; |
| 79 | + }; |
| 80 | + }; |
| 81 | + stardust-xr-server = { |
| 82 | + after = [ "monado.service" ]; |
| 83 | + serviceConfig = { |
| 84 | + Type = "notify"; |
| 85 | + NotifyAccess = "all"; |
| 86 | + ExecStartPre = sleepScript; |
| 87 | + ExecStart = "${lib.getExe stardust-xr-server} -e ${writeShellScript "notifyReady" "systemd-notify --ready"}"; |
| 88 | + }; |
| 89 | + }; |
| 90 | + weston-cliptest = { |
| 91 | + after = [ "flatland.service" ]; |
| 92 | + environment.WAYLAND_DISPLAY = "wayland-1"; |
| 93 | + serviceConfig = { |
| 94 | + ExecStart = lib.getExe' weston "weston-cliptest"; |
| 95 | + }; |
| 96 | + }; |
| 97 | + flatland = { |
| 98 | + after = [ "stardust-xr-server.service" ]; |
| 99 | + serviceConfig = { |
| 100 | + ExecStart = lib.getExe stardust-xr-flatland; |
| 101 | + }; |
| 102 | + }; |
| 103 | + "org.gnome.Shell@wayland" = { |
| 104 | + wants = [ |
| 105 | + "monado.service" |
| 106 | + "stardust-xr-server.service" |
| 107 | + "flatland.service" |
| 108 | + "weston-cliptest.service" |
| 109 | + ]; |
| 110 | + serviceConfig = { |
| 111 | + ExecStart = [ |
| 112 | + # Clear the list before overriding it. |
| 113 | + "" |
| 114 | + # Eval API is now internal so Shell needs to run in unsafe mode. |
| 115 | + # TODO: improve test driver so that it supports openqa-like manipulation |
| 116 | + # that would allow us to drop this mess. |
| 117 | + "${lib.getExe pkgs.gnome-shell} --unsafe-mode" |
| 118 | + ]; |
| 119 | + }; |
| 120 | + }; |
| 121 | + }; |
| 122 | + }; |
| 123 | + |
| 124 | + testScript = |
| 125 | + { nodes, ... }: |
| 126 | + let |
| 127 | + # Keep line widths somewhat managable |
| 128 | + user = nodes.machine.users.users.alice; |
| 129 | + uid = toString user.uid; |
| 130 | + bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus"; |
| 131 | + gdbus = "${bus} gdbus"; |
| 132 | + su = command: "su ${user.name} -c '${command}'"; |
| 133 | + |
| 134 | + # Call javascript in gnome shell, returns a tuple (success, output), where |
| 135 | + # `success` is true if the dbus call was successful and output is what the |
| 136 | + # javascript evaluates to. |
| 137 | + eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval"; |
| 138 | + |
| 139 | + # False when startup is done |
| 140 | + startingUp = su "${gdbus} ${eval} Main.layoutManager._startingUp"; |
| 141 | + in |
| 142 | + '' |
| 143 | + with subtest("Login to GNOME with GDM"): |
| 144 | + # wait for gdm to start |
| 145 | + machine.wait_for_unit("display-manager.service") |
| 146 | + # wait for the wayland server |
| 147 | + machine.wait_for_file("/run/user/${uid}/wayland-0") |
| 148 | + # wait for alice to be logged in |
| 149 | + machine.wait_for_unit("default.target", "${user.name}") |
| 150 | + # check that logging in has given the user ownership of devices |
| 151 | + assert "alice" in machine.succeed("getfacl -p /dev/snd/timer") |
| 152 | +
|
| 153 | + with subtest("Wait for GNOME Shell"): |
| 154 | + # correct output should be (true, 'false') |
| 155 | + machine.wait_until_succeeds( |
| 156 | + "${startingUp} | grep -q 'true,..false'" |
| 157 | + ) |
| 158 | +
|
| 159 | + # To allow monado-service to use < /dev/ttyS0 |
| 160 | + machine.succeed("chown alice /dev/ttyS0") |
| 161 | +
|
| 162 | + with subtest("Open Monado and StardustXR"): |
| 163 | + # Close the Activities view so that Shell can correctly track the focused window. |
| 164 | + machine.send_key("esc") |
| 165 | + machine.wait_for_unit("monado.service", "${user.name}") |
| 166 | + machine.wait_for_unit("stardust-xr-server.service", "${user.name}") |
| 167 | + machine.wait_for_unit("flatland.service", "${user.name}") |
| 168 | + machine.wait_for_unit("weston-cliptest.service", "${user.name}") |
| 169 | + machine.sleep(3) |
| 170 | + machine.screenshot("screen") |
| 171 | + ''; |
| 172 | + } |
| 173 | +) |
0 commit comments