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