Subject: | Disable user/system timing tests if workload accumulate too little time |
One of our Linux boxes started failing these tests about half the time because the string
operations in perl-5.12 are now too fast. It ended up with ratio 1/165 for user/system time
spent in the work loop while with perl-5.10 we had a ratio of 1/26. The ideal ratio ought to be
something like 1/1.
Here I just disable the tests if the accumulated user or system time is too low.
Patch relative to BSD-Resource-1.29.4
Subject: | 0001-Disable-user-system-timing-tests-if-workload-accumul.patch |
From 302f32c08d38e381b8cc01f7cdd8168e0d8af8d7 Mon Sep 17 00:00:00 2001
From: Gisle Aas <gisle@activestate.com>
Date: Wed, 27 Oct 2010 12:09:35 -0700
Subject: [PATCH] Disable user/system timing tests if workload accumulate too little time
One of our Linux boxes started failing these tests because the
string operations in perl-5.12 are now too fast. It ended up with
ratio 1/165 for user/system time spent in the work loop while with
perl-5.10 we had a ratio of 1/26. The ideal ratio ought to be something
like 1/1.
Here I just disable the tests if the accumulated user or system time
is too low.
---
INSTALL | 19 +------------------
t/getrusage.t | 8 ++++++--
t/times.t | 11 ++++++++---
3 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/INSTALL b/INSTALL
index 31fbd88..6be46dd 100644
--- a/INSTALL
+++ b/INSTALL
@@ -32,24 +32,7 @@ Especially if your system does support these BSD functions but
the Makefile.PL fails to locate them, please let me know.
Remember to send the outputs of 'perl -v' and 'uname -a' (or equivalent).
-NOTE 1: The test t/getrusage.t is known to be tricky and to fail once
-in a while. This is because the results depend on timing issues and
-the activity of the operating system, it is moderately icky to
-guestimate such tolerances that leave some slack while still proving
-anything. Please retry 'make test' for a couple times, "eventually"
-the test should pass. If even that fails, please see that the $debug
-in the script is 1 and then run the test separately:
-
- perl -Mblib t/getrusage.t
-
-or (if the above does not work)
-
- perl -Iblib/arch -Iblib/lib t/getrusage.t
-
-and send the results to me. Ditto for the other tests: running them
-separately with the $debug on is useful for, well, debugging.
-
-NOTE 2: The test t/getpriority may fail because in some systems the
+NOTE: The test t/getpriority may fail because in some systems the
login shell may have an initial priority that is not 0 or 19, the
usual values and this priority may be inherited by your Perl process
doing the testing. Please run the test like this
diff --git a/t/getrusage.t b/t/getrusage.t
index 6d4a7ad..1dea7bc 100755
--- a/t/getrusage.t
+++ b/t/getrusage.t
@@ -12,8 +12,6 @@ my $debug = 1;
$| = 1 if ($debug);
-print "1..2\n";
-
$time0 = time();
# burn some time and CPU
@@ -46,6 +44,12 @@ eval '($tsu, $tss) = times()';
print "# tsu = $tsu, tss = $tss\n" if ($debug);
+if ($ru[0] < 0.5 || $ru[1] < 0.5) {
+ print "1..0 # SKIP Not enough user or system time accumulated for test\n";
+ exit;
+}
+print "1..2\n";
+
# and to the real (wallclock) time returned by time()
$nap = 6;
diff --git a/t/times.t b/t/times.t
index 6d2107c..1041ff7 100644
--- a/t/times.t
+++ b/t/times.t
@@ -12,8 +12,6 @@ my $debug = 1;
$| = 1 if ($debug);
-print "1..2\n";
-
# burn some time and CPU
my $t0 = time();
@@ -34,6 +32,13 @@ if ($debug) {
print "# BSD::Resource::times() = @t2\n";
}
+if ($t0[0] < 0.5 || $t0[1] < 0.5) {
+ print "1..0 # SKIP Not enough user or system time accumulated for test\n";
+ exit;
+}
+
+print "1..2\n";
+
sub far ($$$) {
my ($a, $b, $r) = @_;
@@ -42,7 +47,7 @@ sub far ($$$) {
$b == 0 ? 0 : (abs($a/$b-1) > $r);
}
-print 'not ' if far($t1[0], $t0[0], 0.10) or
+print 'not ' if far($t1[0], $t0[0], 0.20) or
far($t1[1], $t0[1], 0.50);
print "ok 1\n";
--
1.7.0.5