diff --git a/lib/test-driver/Machine.pm b/lib/test-driver/Machine.pm index a3c714b3a86a..8f0bd0a88bc3 100644 --- a/lib/test-driver/Machine.pm +++ b/lib/test-driver/Machine.pm @@ -134,11 +134,6 @@ sub connect { $self->log("connected"); $self->{connected} = 1; - - print { $self->{socket} } "PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin:\$PATH\n"; - print { $self->{socket} } "export GCOV_PREFIX=/tmp/coverage-data\n"; - print { $self->{socket} } "cd /tmp\n"; - # !!! Should make sure the commands above don't produce output, otherwise we're out of sync. } @@ -283,14 +278,26 @@ sub unblock { sub screenshot { my ($self, $filename) = @_; my $scrot = $ENV{'scrot'} or die; - $self->mustSucceed("DISPLAY=:0.0 $scrot /hostfs/$ENV{out}/${filename}.png"); + $self->mustSucceed("$scrot /hostfs/$ENV{out}/${filename}.png"); } +# Wait until it is possible to connect to the X server. Note that +# testing the existence of /tmp/.X11-unix/X0 is insufficient. +sub waitForX { + my ($self, $regexp) = @_; + while (1) { + my ($status, $out) = $self->execute("xwininfo -root > /dev/null 2>&1"); + return if $status == 0; + sleep 1; + } +}; + + sub getWindowNames { my ($self) = @_; my $res = $self->mustSucceed( - q{DISPLAY=:0.0 xwininfo -root -tree | sed 's/.*0x[0-9a-f]* \"\([^\"]*\)\".*/\1/; t; d'}); + q{xwininfo -root -tree | sed 's/.*0x[0-9a-f]* \"\([^\"]*\)\".*/\1/; t; d'}); return split /\n/, $res; } diff --git a/modules/testing/test-instrumentation.nix b/modules/testing/test-instrumentation.nix index a563852e22c0..fb807060df39 100644 --- a/modules/testing/test-instrumentation.nix +++ b/modules/testing/test-instrumentation.nix @@ -18,7 +18,15 @@ with pkgs.lib; echo "===UP===" > dev/ttyS0 ''; - exec = "${pkgs.socat}/bin/socat tcp-listen:514,fork exec:/bin/sh 2> /dev/ttyS0"; + script = + '' + export HOME=/root + export DISPLAY=:0.0 + export GCOV_PREFIX=/tmp/coverage-data + source /etc/bashrc + cd /tmp + exec ${pkgs.socat}/bin/socat tcp-listen:514,fork exec:/bin/sh 2> /dev/ttyS0 + ''; }; boot.postBootCommands = diff --git a/release.nix b/release.nix index ec5e5aeccfae..8180df3dc4bd 100644 --- a/release.nix +++ b/release.nix @@ -119,6 +119,7 @@ let system = "i686-linux"; }; in { + firefox = t.firefox.test; kde4 = t.kde4.test; quake3 = t.quake3.test; subversion = t.subversion.report; diff --git a/tests/default.nix b/tests/default.nix index 206db700b194..833d06b1f5df 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -23,8 +23,8 @@ let in { - kde4 = apply (import ./kde4.nix); firefox = apply (import ./firefox.nix); + kde4 = apply (import ./kde4.nix); quake3 = apply (import ./quake3.nix); subversion = apply (import ./subversion.nix); trac = apply (import ./trac.nix); diff --git a/tests/firefox.nix b/tests/firefox.nix index 46b5d8c2631d..e2f10fa97ab4 100644 --- a/tests/firefox.nix +++ b/tests/firefox.nix @@ -11,14 +11,10 @@ testScript = '' - $machine->waitForFile("/tmp/.X11-unix/X0"); - - sleep 10; - - $machine->execute("DISPLAY=:0.0 HOME=/root firefox file://${pkgs.valgrind}/share/doc/valgrind/html/index.html &"); - - sleep 30; - + $machine->waitForX; + $machine->execute("firefox file://${pkgs.valgrind}/share/doc/valgrind/html/index.html &"); + $machine->waitForWindow(/Valgrind.*Shiretoko/); + sleep 30; # wait until Firefox has finished loading the page $machine->screenshot("screen"); ''; diff --git a/tests/quake3.nix b/tests/quake3.nix index f743b9d8e91c..e3a190dda7a5 100644 --- a/tests/quake3.nix +++ b/tests/quake3.nix @@ -33,14 +33,11 @@ rec { startAll; $server->waitForJob("quake3-server"); - $client1->waitForFile("/tmp/.X11-unix/X0"); - $client2->waitForFile("/tmp/.X11-unix/X0"); + $client1->waitForX; + $client2->waitForX; - sleep 20; - - $client1->execute("DISPLAY=:0.0 quake3 '+set r_fullscreen 0' '+set name Foo' '+connect server' &"); - - $client2->execute("DISPLAY=:0.0 quake3 '+set r_fullscreen 0' '+set name Bar' '+connect server' &"); + $client1->execute("quake3 '+set r_fullscreen 0' '+set name Foo' '+connect server' &"); + $client2->execute("quake3 '+set r_fullscreen 0' '+set name Bar' '+connect server' &"); sleep 40; diff --git a/tests/trac.nix b/tests/trac.nix index e5127a522a53..6bb3413cea9e 100644 --- a/tests/trac.nix +++ b/tests/trac.nix @@ -65,11 +65,10 @@ $webserver->mustSucceed("mkdir -p /var/trac/projects/test"); $webserver->mustSucceed("PYTHONPATH=${pkgs.pythonPackages.psycopg2}/lib/python2.5/site-packages trac-admin /var/trac/projects/test initenv Test postgres://root\@postgresql/trac svn /repos/trac"); - $client->waitForFile("/tmp/.X11-unix/X0"); - sleep 20; - - $client->execute("su - root -c 'DISPLAY=:0.0 konqueror http://webserver/projects/test &'"); - sleep 90; + $client->waitForX; + $client->execute("konqueror http://webserver/projects/test &"); + $client->waitForWindow(qr/Test.*Konqueror/); + sleep 30; # loading takes a long time $client->screenshot("screen"); '';