* 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; 1;

View File

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

View File

@ -32,8 +32,6 @@
useDefaultShell = true; useDefaultShell = true;
password = "foobar"; password = "foobar";
}; };
environment.systemPackages = [ pkgs.scrot ];
}; };
testScript = testScript =
@ -49,8 +47,8 @@
print STDERR $machine->execute("su - alice -c 'DISPLAY=:0.0 konqueror http://localhost/ &'"); print STDERR $machine->execute("su - alice -c 'DISPLAY=:0.0 konqueror http://localhost/ &'");
sleep 10; 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.enable = true;
services.xserver.driSupport = true; services.xserver.driSupport = true;
services.xserver.defaultDepth = pkgs.lib.mkOverride 0 {} 16; services.xserver.defaultDepth = pkgs.lib.mkOverride 0 {} 16;
environment.systemPackages = [ pkgs.scrot pkgs.icewm pkgs.quake3demo ]; environment.systemPackages = [ pkgs.icewm pkgs.quake3demo ];
}; };
nodes = nodes =
@ -48,9 +48,9 @@ rec {
$server->mustSucceed("grep -q 'Foo.*entered the game' /tmp/log"); $server->mustSucceed("grep -q 'Foo.*entered the game' /tmp/log");
$server->mustSucceed("grep -q 'Bar.*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"); $client1->screenshot("screen1");
print STDERR $client2->mustSucceed("DISPLAY=:0.0 scrot /hostfs/$ENV{out}/screen2.png"); $client2->screenshot("screen2");
''; '';
} }