diff options
author | Rob Vermaas <rob.vermaas@gmail.com> | 2010-03-11 13:11:06 +0000 |
---|---|---|
committer | Rob Vermaas <rob.vermaas@gmail.com> | 2010-03-11 13:11:06 +0000 |
commit | 3fae175c104c43159ff1c3ac52effd7625f96b29 (patch) | |
tree | a2410848bb909a7ce3bd47436090e90d25e4d527 /lib | |
parent | 9f5d77f78d71a6057da556bf043f473dc035cc15 (diff) | |
download | nixlib-3fae175c104c43159ff1c3ac52effd7625f96b29.tar nixlib-3fae175c104c43159ff1c3ac52effd7625f96b29.tar.gz nixlib-3fae175c104c43159ff1c3ac52effd7625f96b29.tar.bz2 nixlib-3fae175c104c43159ff1c3ac52effd7625f96b29.tar.lz nixlib-3fae175c104c43159ff1c3ac52effd7625f96b29.tar.xz nixlib-3fae175c104c43159ff1c3ac52effd7625f96b29.tar.zst nixlib-3fae175c104c43159ff1c3ac52effd7625f96b29.zip |
* nixos/lib/testing.nix: added runinmachine function to build derivation in machine given a nixos configuration
svn path=/nixos/trunk/; revision=20556
Diffstat (limited to 'lib')
-rw-r--r-- | lib/testing.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/testing.nix b/lib/testing.nix index 5e6b20e75149..97de42f65463 100644 --- a/lib/testing.nix +++ b/lib/testing.nix @@ -99,6 +99,46 @@ rec { report = makeReport test; }; + runInMachine = { + drv + , machine + , preBuild ? "" + , postBuild ? "" + }: + let + vms = + buildVirtualNetwork { nodes = { client = machine; } ; }; + + buildrunner = writeText "vm-build" '' + source $1 + ${coreutils}/bin/mkdir -p $TMPDIR + exec $origBuilder $origArgs &> /hostfs/$TMPDIR/logzzzz + ''; + + testscript = '' + startAll; + ${preBuild} + print STDERR $client->mustSucceed("source ${buildrunner} /hostfs".$client->stateDir."/saved-env"); + ${postBuild} + ''; + + vmRunCommand = writeText "vm-run" '' + ${coreutils}/bin/mkdir -p client + export > client/saved-env + export PATH=${qemu_kvm}/bin:${coreutils}/bin + cp ${./test-driver/Machine.pm} Machine.pm + export tests='${testscript}' + ${perl}/bin/perl ${./test-driver/test-driver.pl} ${vms}/vms/*/bin/run-*-vm + ''; + + in + lib.overrideDerivation drv (attrs: { + builder = "${bash}/bin/sh"; + args = ["-e" vmRunCommand]; + origArgs = attrs.args; + origBuilder = attrs.builder; + }); + simpleTest = as: (apply ({ ... }: as)).test; } |