diff --git a/lib/test-driver/test-driver.pl b/lib/test-driver/test-driver.pl index 362572205242..77df6cd2bd2c 100644 --- a/lib/test-driver/test-driver.pl +++ b/lib/test-driver/test-driver.pl @@ -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; } diff --git a/lib/testing.nix b/lib/testing.nix index 46ca9954ccde..4d1c389de488 100644 --- a/lib/testing.nix +++ b/lib/testing.nix @@ -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 diff --git a/tests/installer.nix b/tests/installer.nix index 994d1173c2d0..f4d4281a0736 100644 --- a/tests/installer.nix +++ b/tests/installer.nix @@ -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.