* Add a method Machine::sleep to sleep N seconds in virtual (guest)
time rather than host real time. svn path=/nixos/trunk/; revision=25491
This commit is contained in:
parent
8db3bdc4fc
commit
60b6eb7579
@ -467,10 +467,12 @@ sub screenshot {
|
|||||||
# testing the existence of /tmp/.X11-unix/X0 is insufficient.
|
# testing the existence of /tmp/.X11-unix/X0 is insufficient.
|
||||||
sub waitForX {
|
sub waitForX {
|
||||||
my ($self, $regexp) = @_;
|
my ($self, $regexp) = @_;
|
||||||
|
$self->nest("waiting for the X11 server", sub {
|
||||||
retry sub {
|
retry sub {
|
||||||
my ($status, $out) = $self->execute("xwininfo -root > /dev/null 2>&1");
|
my ($status, $out) = $self->execute("xwininfo -root > /dev/null 2>&1");
|
||||||
return 1 if $status == 0;
|
return 1 if $status == 0;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -484,12 +486,14 @@ sub getWindowNames {
|
|||||||
|
|
||||||
sub waitForWindow {
|
sub waitForWindow {
|
||||||
my ($self, $regexp) = @_;
|
my ($self, $regexp) = @_;
|
||||||
|
$self->nest("waiting for a window to appear", sub {
|
||||||
retry sub {
|
retry sub {
|
||||||
my @names = $self->getWindowNames;
|
my @names = $self->getWindowNames;
|
||||||
foreach my $n (@names) {
|
foreach my $n (@names) {
|
||||||
return 1 if $n =~ /$regexp/;
|
return 1 if $n =~ /$regexp/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -518,4 +522,11 @@ sub sendChars {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Sleep N seconds (in virtual guest time, not real time).
|
||||||
|
sub sleep {
|
||||||
|
my ($self, $time) = @_;
|
||||||
|
$self->succeed("sleep $time");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -46,7 +46,7 @@ with pkgs;
|
|||||||
|
|
||||||
# More DNS-SD.
|
# More DNS-SD.
|
||||||
$one->execute("avahi-publish -s \"This is a test\" _test._tcp 123 one=1 &");
|
$one->execute("avahi-publish -s \"This is a test\" _test._tcp 123 one=1 &");
|
||||||
sleep 5;
|
$one->sleep(5);
|
||||||
print STDERR
|
print STDERR
|
||||||
$two->mustSucceed("avahi-browse -r -t _test._tcp | tee out");
|
$two->mustSucceed("avahi-browse -r -t _test._tcp | tee out");
|
||||||
$two->mustSucceed("test `wc -l < out` -gt 0");
|
$two->mustSucceed("test `wc -l < out` -gt 0");
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
''
|
''
|
||||||
$machine->waitForX;
|
$machine->waitForX;
|
||||||
$machine->execute("firefox file://${pkgs.valgrind}/share/doc/valgrind/html/index.html &");
|
$machine->execute("firefox file://${pkgs.valgrind}/share/doc/valgrind/html/index.html &");
|
||||||
$machine->waitForWindow(/Valgrind.*Shiretoko/);
|
$machine->waitForWindow(qr/Valgrind/);
|
||||||
sleep 40; # wait until Firefox has finished loading the page
|
$machine->sleep(40); # wait until Firefox has finished loading the page
|
||||||
$machine->screenshot("screen");
|
$machine->screenshot("screen");
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
$machine->waitForWindow(qr/messages.*KWrite/);
|
$machine->waitForWindow(qr/messages.*KWrite/);
|
||||||
$machine->waitForWindow(qr/Valgrind.*Konqueror/);
|
$machine->waitForWindow(qr/Valgrind.*Konqueror/);
|
||||||
|
|
||||||
sleep 5;
|
$machine->sleep(5);
|
||||||
|
|
||||||
$machine->screenshot("screen");
|
$machine->screenshot("screen");
|
||||||
'';
|
'';
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
$machine->waitForJob("tty1");
|
$machine->waitForJob("tty1");
|
||||||
$machine->sendChars("alice\n");
|
$machine->sendChars("alice\n");
|
||||||
$machine->waitUntilSucceeds("pgrep login");
|
$machine->waitUntilSucceeds("pgrep login");
|
||||||
$machine->execute("sleep 2"); # urgh: wait for `Password:'
|
$machine->sleep(2); # urgh: wait for `Password:'
|
||||||
$machine->sendChars("foobar\n");
|
$machine->sendChars("foobar\n");
|
||||||
$machine->waitUntilSucceeds("pgrep -u alice bash");
|
$machine->waitUntilSucceeds("pgrep -u alice bash");
|
||||||
$machine->sendChars("touch done\n");
|
$machine->sendChars("touch done\n");
|
||||||
@ -27,7 +27,7 @@
|
|||||||
subtest "virtual console switching", sub {
|
subtest "virtual console switching", sub {
|
||||||
$machine->sendKeys("alt-f10");
|
$machine->sendKeys("alt-f10");
|
||||||
$machine->waitUntilSucceeds("[ \$(fgconsole) = 10 ]");
|
$machine->waitUntilSucceeds("[ \$(fgconsole) = 10 ]");
|
||||||
$machine->execute("sleep 2"); # allow fbcondecor to catch up (not important)
|
$machine->sleep(2); # allow fbcondecor to catch up (not important)
|
||||||
$machine->screenshot("syslog");
|
$machine->screenshot("syslog");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,10 +35,10 @@
|
|||||||
# ownership as needed.
|
# ownership as needed.
|
||||||
subtest "device permissions", sub {
|
subtest "device permissions", sub {
|
||||||
$machine->succeed("chvt 1");
|
$machine->succeed("chvt 1");
|
||||||
$machine->execute("sleep 1"); # urgh
|
$machine->sleep(1); # urgh
|
||||||
$machine->succeed("getfacl /dev/snd/timer | grep -q alice");
|
$machine->succeed("getfacl /dev/snd/timer | grep -q alice");
|
||||||
$machine->succeed("chvt 2");
|
$machine->succeed("chvt 2");
|
||||||
$machine->execute("sleep 1"); # urgh
|
$machine->sleep(1); # urgh
|
||||||
$machine->fail("getfacl /dev/snd/timer | grep -q alice");
|
$machine->fail("getfacl /dev/snd/timer | grep -q alice");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,18 +56,18 @@ rec {
|
|||||||
$server->waitUntilSucceeds("grep -q 'Foo.*entered the game' /tmp/log");
|
$server->waitUntilSucceeds("grep -q 'Foo.*entered the game' /tmp/log");
|
||||||
$server->waitUntilSucceeds("grep -q 'Bar.*entered the game' /tmp/log");
|
$server->waitUntilSucceeds("grep -q 'Bar.*entered the game' /tmp/log");
|
||||||
|
|
||||||
sleep 10; # wait for a while to get a nice screenshot
|
$server->sleep(10); # wait for a while to get a nice screenshot
|
||||||
|
|
||||||
$client1->block();
|
$client1->block();
|
||||||
|
|
||||||
sleep 20;
|
$server->sleep(20);
|
||||||
|
|
||||||
$client1->screenshot("screen1");
|
$client1->screenshot("screen1");
|
||||||
$client2->screenshot("screen2");
|
$client2->screenshot("screen2");
|
||||||
|
|
||||||
$client1->unblock();
|
$client1->unblock();
|
||||||
|
|
||||||
sleep 10;
|
$server->sleep(10);
|
||||||
|
|
||||||
$client1->screenshot("screen3");
|
$client1->screenshot("screen3");
|
||||||
$client2->screenshot("screen4");
|
$client2->screenshot("screen4");
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
$client->waitForX;
|
$client->waitForX;
|
||||||
$client->execute("konqueror http://webserver/projects/test &");
|
$client->execute("konqueror http://webserver/projects/test &");
|
||||||
$client->waitForWindow(qr/Test.*Konqueror/);
|
$client->waitForWindow(qr/Test.*Konqueror/);
|
||||||
sleep 30; # loading takes a long time
|
$client->sleep(30); # loading takes a long time
|
||||||
|
|
||||||
$client->screenshot("screen");
|
$client->screenshot("screen");
|
||||||
'';
|
'';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user