Restore tests and script deleted in b8661825

This commit is contained in:
Xavier Vello 2019-12-14 22:19:57 +01:00
parent 14cabd62e5
commit 81e4a49708
12 changed files with 573 additions and 0 deletions

11
tests/lib/config.nix Normal file
View file

@ -0,0 +1,11 @@
{
security.dhparams.defaultBitSize = 16; # really low for quicker tests
# For slow non-kvm tests.
# nixos/modules/testing/test-instrumentation.nix also sets this. I don't know if there's a better way than etc to override theirs.
environment.etc."systemd/system.conf.d/bigdefaulttimeout.conf".text = ''
[Manager]
# Allow extremely slow start (default for test-VMs is 5 minutes)
DefaultTimeoutStartSec=15min
'';
}

31
tests/lib/pkgs.nokvm.nix Normal file
View file

@ -0,0 +1,31 @@
let
pkgs = (import <nixpkgs> { system = builtins.currentSystem; config = {}; });
patchedMachinePM = pkgs.writeTextFile {
name = "Machine.pm.patched-to-wait-longer-for-vm";
text = builtins.replaceStrings ["alarm 600;"] ["alarm 1200;"] (builtins.readFile (<nixpkgs>+"/nixos/lib/test-driver/Machine.pm"));
};
in
(pkgs // {
qemu_test = with pkgs; stdenv.mkDerivation {
name = "qemu_test_no_kvm";
buildInputs = [ coreutils qemu_test ];
inherit qemu_test;
inherit coreutils;
builder = builtins.toFile "builder.sh" ''
PATH=$coreutils/bin:$PATH
mkdir -p $out/bin
cp $qemu_test/bin/* $out/bin/
ln -sf $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} $out/bin/qemu-kvm
'';
};
stdenv = pkgs.stdenv // {
mkDerivation = args: (pkgs.stdenv.mkDerivation (args // (
pkgs.lib.optionalAttrs (args.name == "nixos-test-driver") {
installPhase = args.installPhase + ''
rm $libDir/Machine.pm
cp ${patchedMachinePM} $libDir/Machine.pm
'';
}
)));
};
})