Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean & harden normal tests #583

Merged
merged 3 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions integration/common.pl
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,35 @@ sub sizeVerify
return $ok;
}

# Wait for a file to appear
# Helper to check a file's content
sub checkContents
{
my ($file, $expected, $testName) = @_;

open(IN, "< $file");
my $line = <IN>;
is($line, $expected, $testName);

close IN;
}

# Wait for a file to (dis)appear
use Time::HiRes qw(usleep);
sub waitForFile
{
my $file = shift;
my $timeout;
$timeout = shift or $timeout = 5;
for(my $i = $timeout*10; $i > 0; $i--)
my $gone;
$gone = shift or $gone = 0;
for(my $i = $timeout*2; $i > 0; $i--)
{
-f $file and return 1;
usleep(100000); # 0.1 seconds
if (-f $file) {
($gone == 0) and return 1;
} elsif ($gone == 1) {
return 1;
}
usleep(500000); # 0.5 seconds
}
print "# timeout waiting for '$file' to appear\n";
return 0;
Expand Down
Loading