From 5af12b6afe03f7627867b817c2cda52686828b36 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Jan 2010 11:35:59 +0000 Subject: [PATCH] * Provide a function for taking a screenshot. svn path=/nixos/trunk/; revision=19225 --- lib/test-driver/Machine.pm | 8 ++++++++ lib/testing.nix | 1 + tests/kde4.nix | 6 ++---- tests/quake3.nix | 8 ++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/test-driver/Machine.pm b/lib/test-driver/Machine.pm index cc965517d916..34ea4e5e65ce 100644 --- a/lib/test-driver/Machine.pm +++ b/lib/test-driver/Machine.pm @@ -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; diff --git a/lib/testing.nix b/lib/testing.nix index cbd7077eeaaf..28ee564517e3 100644 --- a/lib/testing.nix +++ b/lib/testing.nix @@ -14,6 +14,7 @@ rec { stdenv.mkDerivation { name = "vm-test-run"; inherit tests; + scrot = "${pkgs.scrot}/bin/scrot"; buildCommand = '' mkdir $out diff --git a/tests/kde4.nix b/tests/kde4.nix index 44b8cda038b0..e1e323f4a6f0 100644 --- a/tests/kde4.nix +++ b/tests/kde4.nix @@ -32,8 +32,6 @@ useDefaultShell = true; password = "foobar"; }; - - environment.systemPackages = [ pkgs.scrot ]; }; testScript = @@ -49,8 +47,8 @@ print STDERR $machine->execute("su - alice -c 'DISPLAY=:0.0 konqueror http://localhost/ &'"); sleep 10; - - print STDERR $machine->mustSucceed("DISPLAY=:0.0 scrot /hostfs/$ENV{out}/screen.png"); + + $machine->screenshot("screen"); ''; } diff --git a/tests/quake3.nix b/tests/quake3.nix index c3c047bdab86..ee95d95a98a1 100644 --- a/tests/quake3.nix +++ b/tests/quake3.nix @@ -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 = @@ -48,9 +48,9 @@ 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"); ''; }