about summary refs log tree commit diff
path: root/nixos/tests/openarena.nix
blob: 63dc1b9a68570c214ba5031a6ddc833eba800bd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import ./make-test-python.nix ({ pkgs, ...} :

let
  client =
    { pkgs, ... }:

    { imports = [ ./common/x11.nix ];
      hardware.opengl.driSupport = true;
      environment.systemPackages = [ pkgs.openarena ];
    };

in {
  name = "openarena";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ fpletz ];
  };

  nodes =
    { server =
        { services.openarena = {
            enable = true;
            extraFlags = [ "+set g_gametype 0" "+map oa_dm7" "+addbot Angelyss" "+addbot Arachna" ];
            openPorts = true;
          };
        };

      client1 = client;
      client2 = client;
    };

  testScript =
    ''
      start_all()

      server.wait_for_unit("openarena")
      server.wait_until_succeeds("ss --numeric --udp --listening | grep -q 27960")

      client1.wait_for_x()
      client2.wait_for_x()

      client1.execute("openarena +set r_fullscreen 0 +set name Foo +connect server >&2 &")
      client2.execute("openarena +set r_fullscreen 0 +set name Bar +connect server >&2 &")

      server.wait_until_succeeds(
          "journalctl -u openarena -e | grep -q 'Foo.*entered the game'"
      )
      server.wait_until_succeeds(
          "journalctl -u openarena -e | grep -q 'Bar.*entered the game'"
      )

      server.sleep(10)  # wait for a while to get a nice screenshot

      client1.screenshot("screen_client1_1")
      client2.screenshot("screen_client2_1")

      client1.block()

      server.sleep(10)

      client1.screenshot("screen_client1_2")
      client2.screenshot("screen_client2_2")

      client1.unblock()

      server.sleep(10)

      client1.screenshot("screen_client1_3")
      client2.screenshot("screen_client2_3")
    '';

})