2015-07-12 13:09:40 +03:00
|
|
|
import ./make-test.nix ({ pkgs, ...} :
|
2009-09-03 03:16:33 +04:00
|
|
|
|
2011-01-10 01:21:22 +03:00
|
|
|
let
|
|
|
|
|
|
|
|
# Build Quake with coverage instrumentation.
|
|
|
|
overrides = pkgs:
|
|
|
|
rec {
|
|
|
|
quake3game = pkgs.quake3game.override (args: {
|
|
|
|
stdenv = pkgs.stdenvAdapters.addCoverageInstrumentation args.stdenv;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-01-15 20:25:16 +03:00
|
|
|
# Only allow the demo data to be used (only if it's unfreeRedistributable).
|
|
|
|
unfreePredicate = pkg: with pkgs.lib; let
|
|
|
|
allowDrvPredicates = [ "quake3-demo" "quake3-pointrelease" ];
|
|
|
|
allowLicenses = [ pkgs.lib.licenses.unfreeRedistributable ];
|
|
|
|
in any (flip hasPrefix pkg.name) allowDrvPredicates &&
|
|
|
|
elem (pkg.meta.license or null) allowLicenses;
|
|
|
|
|
2011-01-10 01:21:22 +03:00
|
|
|
in
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2009-09-03 03:16:33 +04:00
|
|
|
rec {
|
2014-06-28 18:04:49 +04:00
|
|
|
name = "quake3";
|
2015-07-12 13:09:40 +03:00
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2016-05-17 14:57:28 +03:00
|
|
|
maintainers = [ domenkozar eelco chaoflow ];
|
2015-07-12 13:09:40 +03:00
|
|
|
};
|
2009-09-03 03:16:33 +04:00
|
|
|
|
2014-12-14 15:34:04 +03:00
|
|
|
# TODO: lcov doesn't work atm
|
|
|
|
#makeCoverageReport = true;
|
2014-03-03 16:39:30 +04:00
|
|
|
|
2011-09-14 22:20:50 +04:00
|
|
|
client =
|
2009-09-03 04:04:43 +04:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
2013-09-04 15:05:09 +04:00
|
|
|
{ imports = [ ./common/x11.nix ];
|
2014-03-03 16:39:30 +04:00
|
|
|
hardware.opengl.driSupport = true;
|
2010-10-13 02:04:10 +04:00
|
|
|
environment.systemPackages = [ pkgs.quake3demo ];
|
2011-01-10 01:21:22 +03:00
|
|
|
nixpkgs.config.packageOverrides = overrides;
|
2016-01-15 20:25:16 +03:00
|
|
|
nixpkgs.config.allowUnfreePredicate = unfreePredicate;
|
2009-09-03 04:04:43 +04:00
|
|
|
};
|
|
|
|
|
2009-09-03 03:16:33 +04:00
|
|
|
nodes =
|
2009-09-03 04:04:43 +04:00
|
|
|
{ server =
|
2009-09-03 03:16:33 +04:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
2016-01-06 09:50:18 +03:00
|
|
|
{ systemd.services."quake3-server" =
|
|
|
|
{ wantedBy = [ "multi-user.target" ];
|
|
|
|
script =
|
2016-01-16 03:01:28 +03:00
|
|
|
"${pkgs.quake3demo}/bin/quake3-server +set g_gametype 0 " +
|
|
|
|
"+map q3dm7 +addbot grunt +addbot daemia 2> /tmp/log";
|
2009-09-03 04:04:43 +04:00
|
|
|
};
|
2011-01-10 01:21:22 +03:00
|
|
|
nixpkgs.config.packageOverrides = overrides;
|
2016-01-15 20:25:16 +03:00
|
|
|
nixpkgs.config.allowUnfreePredicate = unfreePredicate;
|
2014-04-11 19:15:56 +04:00
|
|
|
networking.firewall.allowedUDPPorts = [ 27960 ];
|
2009-09-03 03:16:33 +04:00
|
|
|
};
|
2009-09-03 04:04:43 +04:00
|
|
|
|
|
|
|
client1 = client;
|
|
|
|
client2 = client;
|
2009-09-03 03:16:33 +04:00
|
|
|
};
|
|
|
|
|
2010-01-05 14:18:43 +03:00
|
|
|
testScript =
|
2009-09-03 03:16:33 +04:00
|
|
|
''
|
|
|
|
startAll;
|
|
|
|
|
2012-10-24 20:22:53 +04:00
|
|
|
$server->waitForUnit("quake3-server");
|
2010-01-06 02:59:29 +03:00
|
|
|
$client1->waitForX;
|
|
|
|
$client2->waitForX;
|
2009-09-03 03:16:33 +04:00
|
|
|
|
2016-01-16 03:01:28 +03: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 &");
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2010-02-04 16:59:31 +03:00
|
|
|
$server->waitUntilSucceeds("grep -q 'Foo.*entered the game' /tmp/log");
|
|
|
|
$server->waitUntilSucceeds("grep -q 'Bar.*entered the game' /tmp/log");
|
2009-09-03 04:04:43 +04:00
|
|
|
|
2011-01-10 17:41:16 +03:00
|
|
|
$server->sleep(10); # wait for a while to get a nice screenshot
|
2011-01-09 21:17:17 +03:00
|
|
|
|
|
|
|
$client1->block();
|
|
|
|
|
2011-01-10 17:41:16 +03:00
|
|
|
$server->sleep(20);
|
2010-01-05 14:35:59 +03:00
|
|
|
|
|
|
|
$client1->screenshot("screen1");
|
|
|
|
$client2->screenshot("screen2");
|
2011-01-09 21:17:17 +03:00
|
|
|
|
|
|
|
$client1->unblock();
|
|
|
|
|
2011-01-10 17:41:16 +03:00
|
|
|
$server->sleep(10);
|
2011-01-09 21:17:17 +03:00
|
|
|
|
|
|
|
$client1->screenshot("screen3");
|
|
|
|
$client2->screenshot("screen4");
|
2011-01-10 01:33:21 +03:00
|
|
|
|
|
|
|
$client1->shutdown();
|
|
|
|
$client2->shutdown();
|
2012-10-24 20:11:21 +04:00
|
|
|
$server->stopJob("quake3-server");
|
2009-09-03 03:16:33 +04:00
|
|
|
'';
|
2011-09-14 22:20:50 +04:00
|
|
|
|
2014-04-14 16:02:44 +04:00
|
|
|
})
|