nixpkgs/nixos/tests/quake3.nix

96 lines
2.5 KiB
Nix
Raw Normal View History

2019-10-27 11:08:55 +00:00
import ./make-test-python.nix ({ pkgs, ...} :
let
# Build Quake with coverage instrumentation.
overrides = pkgs:
2019-08-13 22:52:01 +01:00
{
quake3game = pkgs.quake3game.override (args: {
stdenv = pkgs.stdenvAdapters.addCoverageInstrumentation args.stdenv;
});
};
# Only allow the demo data to be used (only if it's unfreeRedistributable).
unfreePredicate = pkg: with pkgs.lib; let
allowPackageNames = [ "quake3-demodata" "quake3-pointrelease" ];
allowLicenses = [ pkgs.lib.licenses.unfreeRedistributable ];
in elem pkg.pname allowPackageNames &&
elem (pkg.meta.license or null) allowLicenses;
in
rec {
2014-06-28 15:04:49 +01:00
name = "quake3";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ domenkozar eelco ];
};
# TODO: lcov doesn't work atm
#makeCoverageReport = true;
client =
{ pkgs, ... }:
{ imports = [ ./common/x11.nix ];
hardware.opengl.driSupport = true;
environment.systemPackages = [ pkgs.quake3demo ];
nixpkgs.config.packageOverrides = overrides;
nixpkgs.config.allowUnfreePredicate = unfreePredicate;
};
nodes =
{ server =
{ pkgs, ... }:
2019-08-13 22:52:01 +01:00
{ systemd.services.quake3-server =
2016-01-06 06:50:18 +00:00
{ wantedBy = [ "multi-user.target" ];
script =
"${pkgs.quake3demo}/bin/quake3-server +set g_gametype 0 " +
"+map q3dm7 +addbot grunt +addbot daemia 2> /tmp/log";
};
nixpkgs.config.packageOverrides = overrides;
nixpkgs.config.allowUnfreePredicate = unfreePredicate;
networking.firewall.allowedUDPPorts = [ 27960 ];
};
client1 = client;
client2 = client;
};
testScript =
''
2019-10-27 11:08:55 +00:00
start_all()
2019-10-27 11:08:55 +00:00
server.wait_for_unit("quake3-server")
client1.wait_for_x()
client2.wait_for_x()
2019-10-27 11:08:55 +00:00
client1.execute("quake3 +set r_fullscreen 0 +set name Foo +connect server &")
client2.execute("quake3 +set r_fullscreen 0 +set name Bar +connect server &")
2019-10-27 11:08:55 +00:00
server.wait_until_succeeds("grep -q 'Foo.*entered the game' /tmp/log")
server.wait_until_succeeds("grep -q 'Bar.*entered the game' /tmp/log")
2019-10-27 11:08:55 +00:00
server.sleep(10) # wait for a while to get a nice screenshot
2019-10-27 11:08:55 +00:00
client1.block()
2019-10-27 11:08:55 +00:00
server.sleep(20)
2019-10-27 11:08:55 +00:00
client1.screenshot("screen1")
client2.screenshot("screen2")
2019-10-27 11:08:55 +00:00
client1.unblock()
2019-10-27 11:08:55 +00:00
server.sleep(10)
2019-10-27 11:08:55 +00:00
client1.screenshot("screen3")
client2.screenshot("screen4")
2019-10-27 11:08:55 +00:00
client1.shutdown()
client2.shutdown()
server.stop_job("quake3-server")
'';
})