Time::HiRes disable a flapping test for CI

When running this test under heavy load
we cannot assume the delta between two system calls...
even when using a (nano)sleep

Most Continuous Integration system will fail on this
test at one point or the other.
This commit is contained in:
Nicolas R 2017-11-13 16:40:31 -06:00
parent 71aef03063
commit cd2a978d22
2 changed files with 16 additions and 3 deletions

View File

@ -36,4 +36,15 @@ standalone Perl script.
perl -x patchlevel.h "This is a custom patch"
=head1 Disabling known flapping tests
Some tests could fail under heavy load, whereas in most cases
they would simply succeed. Usually, continuous integration systems
will at one point or the other reach that problem.
To disable these known tests, please set the environment
variable CI to true.
CI=true
=cut

View File

@ -8,7 +8,7 @@ BEGIN {
}
}
use Test::More tests => 3;
use Test::More tests => 4;
BEGIN { push @INC, '.' }
use t::Watchdog;
@ -25,12 +25,14 @@ ok $one == $two || $two == $three
or print("# slept too long, $one $two $three\n");
SKIP: {
skip "no gettimeofday", 1 unless &Time::HiRes::d_gettimeofday;
skip "no gettimeofday", 2 unless &Time::HiRes::d_gettimeofday;
my $f = Time::HiRes::time();
Time::HiRes::nanosleep(500_000_000);
my $f2 = Time::HiRes::time();
my $d = $f2 - $f;
ok $d > 0.4 && $d < 0.9 or print("# slept $d secs $f to $f2\n");
cmp_ok $d, '>', 0.4, "nanosleep for more than 0.4 sec";
skip "flapping test - more than 0.9 sec could be necessary...", 1 if $ENV{CI};
cmp_ok $d, '<', 0.9 or diag("# slept $d secs $f to $f2\n");
}
1;