3
0
Fork 0
forked from mirrors/nixpkgs

nixos/tests: make the driver attribute use a rich qemu

Since we previously stripped down the features of `qemu_test` some of
the features users are used to while running tests through the (impure)
driver didn't work anymore. Most notably we lost support for graphical
output and audio. With this change the `driver` attribute uses are more
feature complete version of QEmu compared to the one used in the pure
Nix builds.

This gives us the best of both worlds. Users are able to see the
graphical windows of VMs while CI and regular nix builds do not have to
download all the (unnecessary) dependencies.
This commit is contained in:
Andreas Rammhold 2020-10-05 15:52:27 +02:00
parent e79eed4840
commit c096880d46
No known key found for this signature in database
GPG key ID: E432E410B5E48C86

View file

@ -17,9 +17,9 @@ rec {
inherit pkgs;
testDriver = let
mkTestDriver = let
testDriverScript = ./test-driver/test-driver.py;
in stdenv.mkDerivation {
in qemu_pkg: stdenv.mkDerivation {
name = "nixos-test-driver";
nativeBuildInputs = [ makeWrapper ];
@ -47,10 +47,12 @@ rec {
# TODO: copy user script part into this file (append)
wrapProgram $out/bin/nixos-test-driver \
--prefix PATH : "${lib.makeBinPath [ qemu_test vde2 netpbm coreutils ]}" \
--prefix PATH : "${lib.makeBinPath [ qemu_pkg vde2 netpbm coreutils ]}" \
'';
};
testDriver = mkTestDriver qemu_test;
testDriverInteractive = mkTestDriver qemu_kvm;
# Run an automated test suite in the given virtual network.
# `driver' is the script that runs the network.
@ -113,7 +115,11 @@ rec {
# Generate convenience wrappers for running the test driver
# interactively with the specified network, and for starting the
# VMs from the command line.
driver = let warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; in warn (runCommand testDriverName
driver = testDriver:
let
warn = if skipLint then lib.warn "Linting is disabled!" else lib.id;
in
warn (runCommand testDriverName
{ buildInputs = [ makeWrapper];
testScript = testScript';
preferLocalBuild = true;
@ -148,7 +154,7 @@ rec {
meta = (drv.meta or {}) // t.meta;
};
test = passMeta (runTests driver);
test = passMeta (runTests (driver testDriver));
nodeNames = builtins.attrNames nodes;
invalidNodeNames = lib.filter
@ -165,7 +171,8 @@ rec {
''
else
test // {
inherit nodes driver test;
inherit nodes test;
driver = driver testDriverInteractive;
};
runInMachine =