summaryrefslogtreecommitdiff
path: root/ext/Time
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-11-30 04:34:40 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-11-30 04:34:40 +0000
commit2c6849273365be75a7ac83e5e330764cae283237 (patch)
tree218bdcf076b0178f6f6ebed29257497342748244 /ext/Time
parent817b30378b17666393d3d2116b1c97873962996c (diff)
downloadperl-2c6849273365be75a7ac83e5e330764cae283237.tar.gz
Whether select() gets restarted on signals is
implementation dependent. p4raw-id: //depot/perl@13378
Diffstat (limited to 'ext/Time')
-rw-r--r--ext/Time/HiRes/HiRes.t20
1 files changed, 16 insertions, 4 deletions
diff --git a/ext/Time/HiRes/HiRes.t b/ext/Time/HiRes/HiRes.t
index 489829ec9d..e246d82f62 100644
--- a/ext/Time/HiRes/HiRes.t
+++ b/ext/Time/HiRes/HiRes.t
@@ -166,7 +166,7 @@ unless (defined &Time::HiRes::gettimeofday
} else {
use Time::HiRes qw (time alarm sleep);
- my ($f, $r, $i, $not);
+ my ($f, $r, $i, $not, $ok);
$f = time;
print "# time...$f\n";
@@ -185,13 +185,25 @@ unless (defined &Time::HiRes::gettimeofday
select (undef, undef, undef, 3);
my $ival = Time::HiRes::tv_interval ($r);
print "# Select returned! $i $ival\n";
+ print "# ", abs($ival/3 - 1), "\n";
+ # Whether select() gets restarted after signals is
+ # implementation dependent. If it is restarted, we
+ # will get about 3.3 seconds: 3 from the select, 0.3
+ # from the alarm. If this happens, let's just skip
+ # this particular test. --jhi
+ if (abs($ival/3.3 - 1) < $limit) {
+ $ok = "Skip: your select() seems to get restarted by your SIGALRM";
+ undef $not;
+ last;
+ }
my $exp = 0.3 * (5 - $i);
# This test is more sensitive, so impose a softer limit.
- if (abs($ival/$exp) - 1 > 3*$limit) {
+ if (abs($ival/$exp - 1) > 3*$limit) {
my $ratio = abs($ival/$exp);
$not = "while: $exp sleep took $ival ratio $ratio";
last;
}
+ $ok = $i;
}
sub tick
@@ -201,7 +213,7 @@ unless (defined &Time::HiRes::gettimeofday
print "# Tick! $i $ival\n";
my $exp = 0.3 * (5 - $i);
# This test is more sensitive, so impose a softer limit.
- if (abs($ival/$exp) - 1 > 3*$limit) {
+ if (abs($ival/$exp - 1) > 3*$limit) {
my $ratio = abs($ival/$exp);
$not = "tick: $exp sleep took $ival ratio $ratio";
$i = 0;
@@ -210,7 +222,7 @@ unless (defined &Time::HiRes::gettimeofday
alarm(0); # can't cancel usig %SIG
- print $not ? "not ok 17 # $not\n" : "ok 17\n";
+ print $not ? "not ok 17 # $not\n" : "ok 17 # $ok\n";
}
unless (defined &Time::HiRes::setitimer