nixos/tests/aaaaxy: init

Add a simple VM test for the game AAAAXY.
This commit is contained in:
Luflosi 2023-04-04 20:18:38 +02:00
parent 0b57240111
commit 6032e00504
No known key found for this signature in database
GPG Key ID: 4E41E29EDCC345D0
3 changed files with 43 additions and 11 deletions

28
nixos/tests/aaaaxy.nix Normal file
View File

@ -0,0 +1,28 @@
{ pkgs, lib, ... }: {
name = "aaaaxy";
meta.maintainers = with lib.maintainers; [ Luflosi ];
nodes.machine = {
hardware.opengl.enable = true;
};
# This starts the game from a known state, feeds it a prerecorded set of button presses
# and then checks if the final game state is identical to the expected state.
# This is also what AAAAXY's CI system does and serves as a good sanity check.
testScript = ''
machine.wait_for_unit("basic.target")
machine.succeed(
# benchmark.dem needs to be in a mutable directory,
# so we can't just refer to the file in the Nix store directly
"mkdir -p '/tmp/aaaaxy/assets/demos/'",
"ln -s '${pkgs.aaaaxy.testing_infra}/assets/demos/benchmark.dem' '/tmp/aaaaxy/assets/demos/'",
"""
'${pkgs.xvfb-run}/bin/xvfb-run' \
'${pkgs.aaaaxy.testing_infra}/scripts/regression-test-demo.sh' \
'aaaaxy' 'on track for Any%, All Paths and No Teleports' \
'${pkgs.aaaaxy}/bin/aaaaxy' '/tmp/aaaaxy/assets/demos/benchmark.dem'
""",
)
'';
}

View File

@ -67,6 +67,7 @@ let
in {
_3proxy = runTest ./3proxy.nix;
aaaaxy = runTest ./aaaaxy.nix;
acme = runTest ./acme.nix;
adguardhome = runTest ./adguardhome.nix;
aesmd = runTestOn ["x86_64-linux"] ./aesmd.nix;

View File

@ -12,6 +12,7 @@
, libXxf86vm
, go-licenses
, pkg-config
, nixosTests
}:
buildGoModule rec {
@ -40,11 +41,17 @@ buildGoModule rec {
pkg-config
];
outputs = [ "out" "testing_infra" ];
postPatch = ''
# Without patching, "go run" fails with the error message:
# package github.com/google/go-licenses: no Go files in /build/source/vendor/github.com/google/go-licenses
substituteInPlace scripts/build-licenses.sh --replace \
'$GO run ''${GO_FLAGS} github.com/google/go-licenses' 'go-licenses'
patchShebangs scripts/
substituteInPlace scripts/regression-test-demo.sh \
--replace 'sh scripts/run-timedemo.sh' "$testing_infra/scripts/run-timedemo.sh"
'';
makeFlags = [
@ -63,19 +70,15 @@ buildGoModule rec {
install -Dm644 'aaaaxy.png' -t "$out/share/icons/hicolor/128x128/apps/"
install -Dm644 'aaaaxy.desktop' -t "$out/share/applications/"
install -Dm644 'io.github.divverent.aaaaxy.metainfo.xml' -t "$out/share/metainfo/"
install -Dm755 'scripts/run-timedemo.sh' -t "$testing_infra/scripts/"
install -Dm755 'scripts/regression-test-demo.sh' -t "$testing_infra/scripts/"
install -Dm644 'assets/demos/benchmark.dem' -t "$testing_infra/assets/demos/"
'';
checkPhase = ''
runHook preCheck
# Can't get GLX to work even though it seems to work in their CI system:
# [FATAL] RunGame exited abnormally: APIUnavailable: GLX: GLX extension not found
# xvfb-run sh scripts/regression-test-demo.sh aaaaxy \
# "on track for Any%, All Paths and No Teleports" \
# ./aaaaxy assets/demos/benchmark.dem
runHook postCheck
'';
passthru.tests = {
aaaaxy = nixosTests.aaaaxy;
};
strictDeps = true;