* Added a function waitForX, which returns when the X server accepts

connections.
* In the root shell, source /etc/bashrc and set $HOME and $DISPLAY.  

svn path=/nixos/trunk/; revision=19247
wip/yesman
Eelco Dolstra 15 years ago
parent 5cc99487cb
commit bc68c2985c
  1. 21
      lib/test-driver/Machine.pm
  2. 10
      modules/testing/test-instrumentation.nix
  3. 1
      release.nix
  4. 2
      tests/default.nix
  5. 12
      tests/firefox.nix
  6. 11
      tests/quake3.nix
  7. 9
      tests/trac.nix

@ -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;
}

@ -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 =

@ -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;

@ -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);

@ -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");
'';

@ -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;

@ -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");
'';

Loading…
Cancel
Save