From: Jan Dubois Date: Wed, 24 Mar 2010 16:54:24 +0000 (-0700) Subject: Add fudge to timing checks on Windows X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0ebb4f02532851260491496174fb796b13b8b961;p=p5sagit%2Fp5-mst-13.2.git Add fudge to timing checks on Windows sleep() time on Win32 may be rounded down to multiple of the clock tick interval. http://www.nntp.perl.org/group/perl.perl5.porters/2010/03/msg157878.html --- diff --git a/t/op/sselect.t b/t/op/sselect.t index 332b7c0..f4c95d4 100644 --- a/t/op/sselect.t +++ b/t/op/sselect.t @@ -32,12 +32,17 @@ eval {select $blank, $blank, "a", 0}; like ($@, qr/^Modification of a read-only value attempted/); my $sleep = 3; +# Actual sleep time on Windows may be rounded down to an integral +# multiple of the system clock tick interval. Clock tick interval +# is configurable, but usually about 15.625 milliseconds. +my $fudge = $^O eq "MSWin32" ? 0.1 : 0; + my $t = time; select(undef, undef, undef, $sleep); -ok(time-$t >= $sleep, "$sleep seconds have passed"); +ok(time-$t >= $sleep-$fudge, "$sleep seconds have passed"); my $empty = ""; vec($empty,0,1) = 0; $t = time; select($empty, undef, undef, $sleep); -ok(time-$t >= $sleep, "$sleep seconds have passed"); +ok(time-$t >= $sleep-$fudge, "$sleep seconds have passed");