* runInMachine: use buildVM rather than buildVirtualNetwork since

there is only one machine.
* Add a simple test case for runInMachine.

svn path=/nixos/trunk/; revision=25535
This commit is contained in:
Eelco Dolstra
2011-01-13 10:54:07 +00:00
parent b3dbcbe249
commit 06a239a699
2 changed files with 26 additions and 13 deletions
+15 -13
View File
@@ -27,7 +27,7 @@ rec {
cp ${./test-driver/Logger.pm} $libDir/Logger.pm cp ${./test-driver/Logger.pm} $libDir/Logger.pm
wrapProgram $out/bin/nixos-test-driver \ wrapProgram $out/bin/nixos-test-driver \
--prefix PATH : "${pkgs.qemu_kvm}/bin:${pkgs.vde2}/bin:${imagemagick}/bin" \ --prefix PATH : "${pkgs.qemu_kvm}/bin:${pkgs.vde2}/bin:${imagemagick}/bin:${coreutils}/bin" \
--prefix PERL5LIB : "${lib.makePerlPath [ perlPackages.TermReadLineGnu perlPackages.XMLWriter ]}:$out/lib/perl5/site_perl" --prefix PERL5LIB : "${lib.makePerlPath [ perlPackages.TermReadLineGnu perlPackages.XMLWriter ]}:$out/lib/perl5/site_perl"
''; '';
}; };
@@ -163,11 +163,13 @@ rec {
, machine , machine
, preBuild ? "" , preBuild ? ""
, postBuild ? "" , postBuild ? ""
, ... , ... # ???
}: }:
let let
vms = vm = buildVM { }
buildVirtualNetwork { nodes = { client = machine; } ; }; [ ({ config, pkgs, ... }: { networking.hostName = "client"; })
machine
];
buildrunner = writeText "vm-build" '' buildrunner = writeText "vm-build" ''
source $1 source $1
@@ -183,16 +185,15 @@ rec {
testscript = '' testscript = ''
startAll; startAll;
${preBuild} ${preBuild}
print STDERR $client->mustSucceed("env -i ${pkgs.bash}/bin/bash ${buildrunner} /hostfs".$client->stateDir."/saved-env"); $client->succeed("env -i ${pkgs.bash}/bin/bash ${buildrunner} /hostfs".$client->stateDir."/saved-env >&2");
${postBuild} ${postBuild}
''; '';
vmRunCommand = writeText "vm-run" '' vmRunCommand = writeText "vm-run" ''
${coreutils}/bin/mkdir -p vm-state-client ${coreutils}/bin/mkdir -p vm-state-client
export > vm-state-client/saved-env export > vm-state-client/saved-env
export PATH=${qemu_kvm}/bin:${coreutils}/bin
export tests='${testscript}' export tests='${testscript}'
${testDriver}/bin/nixos-test-driver ${vms}/vms/*/bin/run-*-vm ${testDriver}/bin/nixos-test-driver ${vm.config.system.build.vm}/bin/run-*-vm
''; # */ ''; # */
in in
@@ -205,7 +206,7 @@ rec {
}); });
runInMachineWithX = { require ? [], ...}@args : runInMachineWithX = { require ? [], ... } @ args:
let let
client = client =
{ config, pkgs, ... }: { config, pkgs, ... }:
@@ -221,11 +222,12 @@ rec {
}; };
in in
runInMachine ({ runInMachine ({
machine = client; machine = client;
preBuild = '' preBuild =
$client->waitForX; ''
'' ; $client->waitForX;
} // args ); '';
} // args);
simpleTest = as: (makeTest ({ ... }: as)).test; simpleTest = as: (makeTest ({ ... }: as)).test;
+11
View File
@@ -0,0 +1,11 @@
{ nixpkgs ? ../../nixpkgs
, services ? ../../services
, system ? builtins.currentSystem
}:
with import ../lib/testing.nix { inherit nixpkgs services system; };
runInMachine {
drv = (import nixpkgs { }).aterm;
machine = { config, pkgs, ... }: { };
}