* Test driver: write structured log info to $out/log.xml (not finished

yet).
* Machine->new -> createMachine (because VMs must be tracked in the
  %vms hash).

svn path=/nixos/trunk/; revision=25427
This commit is contained in:
Eelco Dolstra 2011-01-05 15:27:21 +00:00
parent 0966854590
commit 7378e17f74
3 changed files with 20 additions and 8 deletions

View File

@ -1,4 +1,4 @@
#! /somewhere/perl
#! /somewhere/perl -w
use strict;
use Machine;
@ -10,13 +10,23 @@ $SIG{PIPE} = 'IGNORE'; # because Unix domain sockets may die unexpectedly
STDERR->autoflush(1);
my $logFile = defined $ENV{LOGFILE} ? "$ENV{LOGFILE}" : "/dev/null";
my $log = new XML::Writer(OUTPUT => new IO::File(">$logFile"));
$log->startTag("logfile");
my %vms;
my $context = "";
foreach my $vmScript (@ARGV) {
my $vm = Machine->new({startCommand => $vmScript});
sub createMachine {
my ($args) = @_;
my $vm = Machine->new($args);
$vms{$vm->name} = $vm;
return $vm;
}
foreach my $vmScript (@ARGV) {
my $vm = createMachine({startCommand => $vmScript});
$context .= "my \$" . $vm->name . " = \$vms{'" . $vm->name . "'}; ";
}
@ -86,6 +96,8 @@ END {
kill 9, $vm->{pid};
}
}
$log->endTag("logfile");
$log->end;
}

View File

@ -50,7 +50,7 @@ rec {
''
ensureDir $out/nix-support
${testDriver}/bin/nixos-test-driver ${network}/vms/*/bin/run-*-vm
LOGFILE=$out/log.xml ${testDriver}/bin/nixos-test-driver ${network}/vms/*/bin/run-*-vm
for i in */coverage-data; do
ensureDir $out/coverage-data

View File

@ -93,7 +93,7 @@ let
''
createDisk("harddisk", 4 * 1024);
my $machine = Machine->new({ hda => "harddisk", cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '${qemuNICFlags 1 1 1}' });
my $machine = createMachine({ hda => "harddisk", cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '${qemuNICFlags 1 1 1}' });
$machine->start;
${optionalString testChannel ''
@ -158,7 +158,7 @@ let
$machine->shutdown;
# Now see if we can boot the installation.
my $machine = Machine->new({ hda => "harddisk" });
my $machine = createMachine({ hda => "harddisk" });
# Did /boot get mounted, if appropriate?
# !!! There is currently no good way to wait for the
@ -181,7 +181,7 @@ let
# And just to be sure, check that the machine still boots after
# "nixos-rebuild switch".
my $machine = Machine->new({ hda => "harddisk" });
my $machine = createMachine({ hda => "harddisk" });
$machine->mustSucceed("echo hello");
$machine->shutdown;
'';
@ -304,7 +304,7 @@ in {
testScript =
''
# damn, it's costly to evaluate nixos-rebuild (1G of ram)
my $machine = Machine->new({ cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '${qemuNICFlags 1 1 1} -m 1024' });
my $machine = createMachine({ cdrom => glob("${iso}/iso/*.iso"), qemuFlags => '${qemuNICFlags 1 1 1} -m 1024' });
$machine->start;
# Make sure that we don't try to download anything.