From c096880d46115c43ea254efc52de32dc3fe58913 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Mon, 5 Oct 2020 15:52:27 +0200 Subject: 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. --- nixos/lib/testing-python.nix | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'nixos') diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index 498f97336c02..69cad8cdceb1 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -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 = -- cgit v1.2.3