about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/openarena.nix
blob: b315426532baea25fe6d10578f21a6c3858a8b19 (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
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "openarena";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ tomfitzhenry ];
  };

  machine =
    { pkgs, ... }:

    { imports = [];
      environment.systemPackages = with pkgs; [
        socat
      ];
      services.openarena = {
        enable = true;
        extraFlags = [
          "+set dedicated 2"
          "+set sv_hostname 'My NixOS server'"
          "+map oa_dm1"
        ];
      };
    };

  testScript =
    ''
      machine.wait_for_unit("openarena.service")
      machine.wait_until_succeeds("ss --numeric --udp --listening | grep -q 27960")

      # The log line containing 'resolve address' is last and only message that occurs after
      # the server starts accepting clients.
      machine.wait_until_succeeds(
          "journalctl -u openarena.service | grep 'resolve address: dpmaster.deathmask.net'"
      )

      # Check it's possible to join the server.
      # Can't use substring match instead of grep because the output is not utf-8
      machine.succeed(
          "echo -n -e '\\xff\\xff\\xff\\xffgetchallenge' | socat - UDP4-DATAGRAM:127.0.0.1:27960 | grep -q challengeResponse"
      )
    '';
})