From e90a1cfc595483bde6046461cc1351220027625f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Dec 2010 19:35:43 +0000 Subject: [PATCH] * A quick hack to enable debugging of VM test scripts: the test script is now made available in the interactive test driver. For instance, you can do $ nix-build tests/ -A quake3.driver $ ./result/bin/nixos-test-driver > eval $ENV{'testScript'}; ... see VMs + X11 + Quake get started, bots running around ... > So after this you can run commands interactively on the VMs in the state they were in after the conclusion of the test script. svn path=/nixos/trunk/; revision=25158 --- lib/testing.nix | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/testing.nix b/lib/testing.nix index f7c25d938a8..6c7a9edac69 100644 --- a/lib/testing.nix +++ b/lib/testing.nix @@ -117,24 +117,38 @@ rec { if t ? nodes then t.nodes else if t ? machine then { machine = t.machine; } else { }; + vms = buildVirtualNetwork { inherit nodes; }; - test = runTests vms + + testScript = # Call the test script with the computed nodes. - (if builtins.isFunction t.testScript then t.testScript { inherit (vms) nodes; } else t.testScript); + if builtins.isFunction t.testScript + then t.testScript { inherit (vms) nodes; } + else t.testScript; + + test = runTests vms testScript; + report = makeReport test; # Generate a convenience wrapper for running the test driver # interactively with the specified network. - driver = runCommand "nixos-test-driver" { buildInputs = [ makeWrapper]; } + driver = runCommand "nixos-test-driver" + { buildInputs = [ makeWrapper]; + inherit testScript; + } '' mkdir -p $out/bin ln -s ${vms}/bin/* $out/bin/ ln -s ${testDriver}/bin/* $out/bin/ wrapProgram $out/bin/nixos-test-driver \ - --add-flags "${vms}/vms/*/bin/run-*-vm" + --add-flags "${vms}/vms/*/bin/run-*-vm" \ + --run "testScript=\"\$(cat $out/test-script)\"" \ + --set testScript '"$testScript"' + echo "$testScript" > $out/test-script ''; # " }; + runInMachine = { drv , machine @@ -182,6 +196,7 @@ rec { origBuilder = attrs.builder; }); + runInMachineWithX = { require ? [], ...}@args : let client = @@ -204,6 +219,7 @@ rec { '' ; } // args ); + simpleTest = as: (makeTest ({ ... }: as)).test; }