summary refs log tree commit diff
path: root/lib/test-driver/Machine.pm
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2010-12-16 15:54:15 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2010-12-16 15:54:15 +0000
commit445827ad450741fe79e25824f050da5b703bad20 (patch)
tree2e39f0680971b7c6b2b6f8dfe45d1425a4eeea17 /lib/test-driver/Machine.pm
parent8496dbf350c5a6692e293107e0e5ce5b0bee40b9 (diff)
downloadnixpkgs-445827ad450741fe79e25824f050da5b703bad20.tar
nixpkgs-445827ad450741fe79e25824f050da5b703bad20.tar.gz
nixpkgs-445827ad450741fe79e25824f050da5b703bad20.tar.bz2
nixpkgs-445827ad450741fe79e25824f050da5b703bad20.tar.lz
nixpkgs-445827ad450741fe79e25824f050da5b703bad20.tar.xz
nixpkgs-445827ad450741fe79e25824f050da5b703bad20.tar.zst
nixpkgs-445827ad450741fe79e25824f050da5b703bad20.zip
* Added a convenience derivation for running the test driver
  interactively on a network specification.  For instance:

  $ nix-build tests/ -A quake3.driver
  $ ./result/bin/nixos-test-driver
  > startAll;
  client1: starting vm
  client1: QEMU running (pid 14971)
  server: starting vm
  server: QEMU running (pid 14982)
  ...
  > $client1->execute("quake3 ...");

* Use the GNU readline library in interactive mode.

svn path=/nixos/trunk/; revision=25156
Diffstat (limited to 'lib/test-driver/Machine.pm')
-rw-r--r--lib/test-driver/Machine.pm8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/test-driver/Machine.pm b/lib/test-driver/Machine.pm
index 28596a5d634..b9dae819b49 100644
--- a/lib/test-driver/Machine.pm
+++ b/lib/test-driver/Machine.pm
@@ -251,7 +251,8 @@ sub execute {
     my $out = "";
 
     while (1) {
-        my $line = readline($self->{socket}) or die "connection to VM lost unexpectedly";
+        my $line = readline($self->{socket});
+        die "connection to VM lost unexpectedly" unless defined $line;
         #$self->log("got line: $line");
         if ($line =~ /^(.*)\|\!\=EOF\s+(\d+)$/) {
             $out .= $1;
@@ -270,7 +271,7 @@ sub succeed {
         my ($status, $out) = $self->execute($command);
         if ($status != 0) {
             $self->log("output: $out");
-            die "command `$command' did not succeed (exit code $status)";
+            die "command `$command' did not succeed (exit code $status)\n";
         }
         $res .= $out;
     }
@@ -407,7 +408,8 @@ sub unblock {
 # Take a screenshot of the X server on :0.0.
 sub screenshot {
     my ($self, $filename) = @_;
-    $filename = "$ENV{'out'}/${filename}.png" if $filename =~ /^\w+$/;
+    my $dir = $ENV{'out'} || Cwd::abs_path(".");
+    $filename = "$dir/${filename}.png" if $filename =~ /^\w+$/;
     my $tmp = "${filename}.ppm";
     $self->sendMonitorCommand("screendump $tmp");
     system("convert $tmp ${filename}") == 0