python310Packages.pydeconz: 104 -> 105
[NixPkgs.git] / nixos / tests / quake3.nix
blob82af1af463d03f2d80c583ba90c9f00724f3d8db
1 import ./make-test-python.nix ({ pkgs, ...} :
3 let
5   # Build Quake with coverage instrumentation.
6   overrides = pkgs:
7     {
8       quake3game = pkgs.quake3game.override (args: {
9         stdenv = pkgs.stdenvAdapters.addCoverageInstrumentation args.stdenv;
10       });
11     };
13   # Only allow the demo data to be used (only if it's unfreeRedistributable).
14   unfreePredicate = pkg: with pkgs.lib; let
15     allowPackageNames = [ "quake3-demodata" "quake3-pointrelease" ];
16     allowLicenses = [ pkgs.lib.licenses.unfreeRedistributable ];
17   in elem pkg.pname allowPackageNames &&
18      elem (pkg.meta.license or null) allowLicenses;
20   client =
21     { pkgs, ... }:
23     { imports = [ ./common/x11.nix ];
24       hardware.opengl.driSupport = true;
25       environment.systemPackages = [ pkgs.quake3demo ];
26       nixpkgs.config.packageOverrides = overrides;
27       nixpkgs.config.allowUnfreePredicate = unfreePredicate;
28     };
32 rec {
33   name = "quake3";
34   meta = with pkgs.stdenv.lib.maintainers; {
35     maintainers = [ domenkozar eelco ];
36   };
38   # TODO: lcov doesn't work atm
39   #makeCoverageReport = true;
41   nodes =
42     { server =
43         { pkgs, ... }:
45         { systemd.services.quake3-server =
46             { wantedBy = [ "multi-user.target" ];
47               script =
48                 "${pkgs.quake3demo}/bin/quake3-server +set g_gametype 0 " +
49                 "+map q3dm7 +addbot grunt +addbot daemia 2> /tmp/log";
50             };
51           nixpkgs.config.packageOverrides = overrides;
52           nixpkgs.config.allowUnfreePredicate = unfreePredicate;
53           networking.firewall.allowedUDPPorts = [ 27960 ];
54         };
56       client1 = client;
57       client2 = client;
58     };
60   testScript =
61     ''
62       start_all()
64       server.wait_for_unit("quake3-server")
65       client1.wait_for_x()
66       client2.wait_for_x()
68       client1.execute("quake3 +set r_fullscreen 0 +set name Foo +connect server &")
69       client2.execute("quake3 +set r_fullscreen 0 +set name Bar +connect server &")
71       server.wait_until_succeeds("grep -q 'Foo.*entered the game' /tmp/log")
72       server.wait_until_succeeds("grep -q 'Bar.*entered the game' /tmp/log")
74       server.sleep(10)  # wait for a while to get a nice screenshot
76       client1.block()
78       server.sleep(20)
80       client1.screenshot("screen1")
81       client2.screenshot("screen2")
83       client1.unblock()
85       server.sleep(10)
87       client1.screenshot("screen3")
88       client2.screenshot("screen4")
90       client1.shutdown()
91       client2.shutdown()
92       server.stop_job("quake3-server")
93     '';