diff --git a/lib/test-driver/Machine.pm b/lib/test-driver/Machine.pm index dee1e4f33cb2..f0d5fbc19ead 100644 --- a/lib/test-driver/Machine.pm +++ b/lib/test-driver/Machine.pm @@ -50,6 +50,7 @@ sub new { stateDir => "$tmpDir/vm-state-$name", monitor => undef, log => $args->{log}, + redirectSerial => $args->{redirectSerial} // 1, }; mkdir $self->{stateDir}, 0700; @@ -117,10 +118,12 @@ sub start { close $serialP; close $monitorS; close $shellS; - open NUL, "{redirectSerial}) { + open NUL, "{stateDir}; $ENV{USE_TMPDIR} = 1; $ENV{QEMU_OPTS} = diff --git a/lib/test-driver/test-driver.pl b/lib/test-driver/test-driver.pl index 43f74cf404bb..fc4b7ea05551 100644 --- a/lib/test-driver/test-driver.pl +++ b/lib/test-driver/test-driver.pl @@ -50,7 +50,7 @@ my $context = ""; sub createMachine { my ($args) = @_; - my $vm = Machine->new({%{$args}, log => $log}); + my $vm = Machine->new({%{$args}, log => $log, redirectSerial => ($ENV{USE_SERIAL} // "0") ne "1"}); $vms{$vm->name} = $vm; return $vm; } diff --git a/lib/testing.nix b/lib/testing.nix index 6a39df8c865d..212c478a728b 100644 --- a/lib/testing.nix +++ b/lib/testing.nix @@ -158,7 +158,8 @@ rec { wrapProgram $out/bin/nixos-run-vms \ --add-flags "$vms" \ --set tests '"startAll; joinAll;"' \ - --set VLANS '"${toString vlans}"' + --set VLANS '"${toString vlans}"' \ + ${lib.optionalString (builtins.length vms == 1) "--set USE_SERIAL 1"} ''; # " test = runTests driver;