Skip to content

Commit ba37ddb

Browse files
committed
nixosTests/monado: add xrgears test
1 parent 40c175a commit ba37ddb

2 files changed

Lines changed: 79 additions & 32 deletions

File tree

nixos/tests/common/openxr.nix

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
lib,
3+
pkgs,
4+
config,
5+
...
6+
}:
7+
8+
{
9+
imports = [
10+
./user-account.nix
11+
./x11.nix
12+
];
13+
test-support.displayManager.auto.user = "alice";
14+
systemd.user.targets.xdg-desktop-autostart = {
15+
wantedBy = [ "graphical-session.target" ];
16+
after = [ "graphical-session.target" ];
17+
};
18+
19+
hardware.graphics.enable = true;
20+
21+
services.monado = {
22+
enable = true;
23+
defaultRuntime = true;
24+
forceDefaultRuntime = true;
25+
};
26+
systemd.user.services.monado = {
27+
requires = [ "graphical-session.target" ];
28+
environment = {
29+
# Stop Monado from probing for any hardware
30+
SIMULATED_ENABLE = "1";
31+
# Run as X11 client rather than using direct mode
32+
XRT_COMPOSITOR_FORCE_XCB = "1";
33+
# And run fullscreen so that we can hide the DE
34+
XRT_COMPOSITOR_XCB_FULLSCREEN = "1";
35+
};
36+
};
37+
}

nixos/tests/monado.nix

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,57 @@
33
name = "monado";
44

55
nodes.machine =
6-
{ pkgs, ... }:
6+
{
7+
lib,
8+
pkgs,
9+
config,
10+
...
11+
}:
712

813
{
9-
hardware.graphics.enable = true;
10-
users.users.alice = {
11-
isNormalUser = true;
12-
uid = 1000;
14+
imports = [ ./common/openxr.nix ];
15+
16+
systemd.user.services.print-openxr-info = {
17+
wantedBy = [ "xdg-desktop-autostart.target" ];
18+
requires = [ "monado.service" ];
19+
script = lib.getExe' pkgs.openxr-loader "openxr_runtime_list";
20+
serviceConfig = {
21+
Type = "oneshot";
22+
RemainAfterExit = true;
23+
};
1324
};
1425

15-
services.monado = {
16-
enable = true;
17-
defaultRuntime = true;
18-
19-
forceDefaultRuntime = true;
26+
systemd.user.services.xrgears = {
27+
wantedBy = [ "xdg-desktop-autostart.target" ];
28+
requires = [ "monado.service" ];
29+
script = lib.getExe pkgs.xrgears;
2030
};
21-
# Stop Monado from probing for any hardware
22-
systemd.user.services.monado.environment.SIMULATED_ENABLE = "1";
23-
24-
environment.systemPackages = with pkgs; [ openxr-loader ];
2531
};
2632

2733
testScript =
2834
{ nodes, ... }:
29-
let
30-
userId = toString nodes.machine.users.users.alice.uid;
31-
runtimePath = "/run/user/${userId}";
32-
in
3335
''
34-
# for defaultRuntime
35-
machine.succeed("stat /etc/xdg/openxr/1/active_runtime.json")
36-
37-
machine.succeed("loginctl enable-linger alice")
38-
machine.wait_for_unit("user@${userId}.service")
39-
40-
machine.wait_for_unit("monado.socket", "alice")
41-
machine.systemctl("start monado.service", "alice")
42-
machine.wait_for_unit("monado.service", "alice")
43-
44-
# for forceDefaultRuntime
45-
machine.succeed("stat /home/alice/.config/openxr/1/active_runtime.json")
46-
47-
machine.succeed("su -- alice -c env XDG_RUNTIME_DIR=${runtimePath} openxr_runtime_list")
36+
with subtest("Ensure X11 starts"):
37+
start_all()
38+
machine.succeed("loginctl enable-linger alice")
39+
machine.wait_for_x()
40+
41+
with subtest("Ensure default runtime present"):
42+
machine.succeed("stat /etc/xdg/openxr/1/active_runtime.json")
43+
44+
with subtest("Ensure forced runtime present"):
45+
# Monado needs to be started to create the forced runtime file
46+
machine.systemctl("start monado.service", "alice")
47+
machine.wait_for_unit("monado.service", "alice")
48+
machine.succeed("stat /home/alice/.config/openxr/1/active_runtime.json")
49+
50+
with subtest("Ensure openxr_runtime_list can find runtime"):
51+
machine.wait_for_unit("print-openxr-info.service", "alice")
52+
53+
with subtest("Ensure xrgears launches"):
54+
machine.wait_for_unit("xrgears.service", "alice")
55+
# TODO: 10 seconds should be long enough for anything, but this is theoretically flaky
56+
machine.sleep(10)
57+
machine.screenshot("screen")
4858
'';
4959
}

0 commit comments

Comments
 (0)