* Provide a function for taking a screenshot.

svn path=/nixos/trunk/; revision=19225
This commit is contained in:
Eelco Dolstra 2010-01-05 11:35:59 +00:00
parent fbda972090
commit 5af12b6afe
4 changed files with 15 additions and 8 deletions

View File

@ -279,4 +279,12 @@ sub unblock {
}
# Take a screenshot of the X server on :0.0.
sub screenshot {
my ($self, $filename) = @_;
my $scrot = $ENV{'scrot'} or die;
$self->mustSucceed("DISPLAY=:0.0 $scrot /hostfs/$ENV{out}/${filename}.png");
}
1;

View File

@ -14,6 +14,7 @@ rec {
stdenv.mkDerivation {
name = "vm-test-run";
inherit tests;
scrot = "${pkgs.scrot}/bin/scrot";
buildCommand =
''
mkdir $out

View File

@ -32,8 +32,6 @@
useDefaultShell = true;
password = "foobar";
};
environment.systemPackages = [ pkgs.scrot ];
};
testScript =
@ -50,7 +48,7 @@
sleep 10;
print STDERR $machine->mustSucceed("DISPLAY=:0.0 scrot /hostfs/$ENV{out}/screen.png");
$machine->screenshot("screen");
'';
}

View File

@ -8,7 +8,7 @@ rec {
{ services.xserver.enable = true;
services.xserver.driSupport = true;
services.xserver.defaultDepth = pkgs.lib.mkOverride 0 {} 16;
environment.systemPackages = [ pkgs.scrot pkgs.icewm pkgs.quake3demo ];
environment.systemPackages = [ pkgs.icewm pkgs.quake3demo ];
};
nodes =
@ -49,8 +49,8 @@ rec {
$server->mustSucceed("grep -q 'Foo.*entered the game' /tmp/log");
$server->mustSucceed("grep -q 'Bar.*entered the game' /tmp/log");
print STDERR $client1->mustSucceed("DISPLAY=:0.0 scrot /hostfs/$ENV{out}/screen1.png");
print STDERR $client2->mustSucceed("DISPLAY=:0.0 scrot /hostfs/$ENV{out}/screen2.png");
$client1->screenshot("screen1");
$client2->screenshot("screen2");
'';
}