* 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:
Eelco Dolstra
2011-01-10 14:41:16 +00:00
parent 8db3bdc4fc
commit 60b6eb7579
7 changed files with 32 additions and 21 deletions

View File

@@ -467,10 +467,12 @@ sub screenshot {
# testing the existence of /tmp/.X11-unix/X0 is insufficient.
sub waitForX {
my ($self, $regexp) = @_;
retry sub {
my ($status, $out) = $self->execute("xwininfo -root > /dev/null 2>&1");
return 1 if $status == 0;
}
$self->nest("waiting for the X11 server", sub {
retry sub {
my ($status, $out) = $self->execute("xwininfo -root > /dev/null 2>&1");
return 1 if $status == 0;
}
});
}
@@ -484,12 +486,14 @@ sub getWindowNames {
sub waitForWindow {
my ($self, $regexp) = @_;
retry sub {
my @names = $self->getWindowNames;
foreach my $n (@names) {
return 1 if $n =~ /$regexp/;
$self->nest("waiting for a window to appear", sub {
retry sub {
my @names = $self->getWindowNames;
foreach my $n (@names) {
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;