2021-03-22 12:19:47 +00:00
|
|
|
pkgs:
|
2020-01-12 19:52:40 +00:00
|
|
|
let
|
2022-10-22 17:37:47 +00:00
|
|
|
pythonTesting = import (pkgs.path + "/nixos/lib/testing-python.nix") {
|
2021-03-22 12:19:48 +00:00
|
|
|
system = pkgs.stdenv.hostPlatform.system;
|
2021-03-22 12:19:47 +00:00
|
|
|
inherit pkgs;
|
|
|
|
};
|
|
|
|
in
|
2020-01-12 19:52:40 +00:00
|
|
|
|
2022-12-18 12:13:44 +00:00
|
|
|
module:
|
2021-03-22 12:19:47 +00:00
|
|
|
let
|
2022-12-18 12:13:44 +00:00
|
|
|
test = (pythonTesting.evalTest module).config;
|
2020-01-12 19:52:40 +00:00
|
|
|
|
2022-12-18 12:13:44 +00:00
|
|
|
runTest = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "vm-test-run-${test.name}";
|
|
|
|
|
|
|
|
requiredSystemFeatures = [ "kvm" "nixos-test" ];
|
|
|
|
|
|
|
|
# 1. Save test logging output
|
|
|
|
# 2. Add link to driver so that a gcroot to a test prevents the driver from
|
|
|
|
# being garbage-collected
|
2021-03-22 12:19:47 +00:00
|
|
|
buildCommand = ''
|
2022-08-16 19:00:00 +00:00
|
|
|
mkdir "$out"
|
2021-08-04 22:49:08 +00:00
|
|
|
LOGFILE=$out/output.xml tests='exec(os.environ["testScript"])' ${test.driver}/bin/nixos-test-driver
|
2022-08-16 19:00:00 +00:00
|
|
|
ln -s ${test.driver} "$out/driver"
|
2021-03-22 12:19:47 +00:00
|
|
|
'';
|
2022-12-18 12:13:44 +00:00
|
|
|
|
|
|
|
inherit (test) meta passthru;
|
|
|
|
} // test;
|
2020-01-12 19:52:40 +00:00
|
|
|
in
|
2022-12-12 10:57:15 +00:00
|
|
|
runTest // {
|
|
|
|
# A VM runner for interactive use
|
|
|
|
run = pkgs.writers.writeBashBin "run-vm" ''
|
|
|
|
. ${./run-vm.sh} ${runTest.driver} "$@"
|
|
|
|
'';
|
|
|
|
}
|