Subject: | t/40profile.t fails with $shortest < 0 |
There's a test in t/40profile.t that emits a warning if the shortest timing in the profile is less
than zero seconds. This line is apparently supposed to make that into a nonfatal error:
$shortest = 0 if $shortest > -0.008;
However, when that happens, the test before has already failed:
ok((grep { $_ >= 0 } @$data) == 7)...
If faster-than-light timing is not actually an error at all, I question the need for this test, but
since it's there it might as well correctly handle the case when it happens. I'm running the
tests on a fresh installation of Ubuntu "Dapper Drake," running in a Parallels virtual machine
(latest version) on a 2x2.66 dual-core xeon Mac Pro (OS X 10.4.8). That might not be the
most normal run environment in the world. The test fails every time for me, typically claiming
to go back in time about 5 ms.
Here's a patch that fixes it for me:
--- t/40profile.t 2006-08-06 19:36:51.000000000 -0400
+++ /root/40profile.t 2006-10-20 12:24:42.000000000 -0400
@@ -133,16 +133,20 @@
ok(@$data == 7);
ok((grep { defined($_) } @$data) == 7);
ok((grep { DBI::looks_like_number($_) } @$data) == 7);
-ok((grep { $_ >= 0 } @$data) == 7) or warn "profile data: [@$data]\n";
+use constant BUGGYZERO => -0.008;
+ok((grep { $_ >= BUGGYZERO } @$data) == 7) or warn "profile data: [@$data]\n";
my ($count, $total, $first, $shortest, $longest, $time1, $time2) = @$data;
if ($shortest < 0) {
- my $sys = "$Config{archname} $Config{osvers}"; # sparc-linux 2.4.20-2.3sparcsmp
- warn "Time went backwards at some point during the test on this $sys system!\n";
- warn "Perhaps you have time sync software (like NTP) that adjusted the clock\n";
- warn "backwards by more than $shortest seconds during the test. PLEASE RETRY.\n";
# Don't treat very small negative amounts as a failure - it's always been due
# due to NTP or buggy multiprocessor systems.
- $shortest = 0 if $shortest > -0.008;
+ my $sys = "$Config{archname} $Config{osvers}"; # sparc-linux 2.4.20-2.3sparcsmp
+ warn <<EOT;
+
+Time went backwards at some point during the test on this $sys system!
+Perhaps you have time sync software (like NTP) that adjusted the clock
+backwards by more than $shortest seconds during the test. PLEASE RETRY.
+EOT
+ $shortest = 0 if $shortest > BUGGYZERO;
}
ok($count > 3);
ok($total > $first);