summaryrefslogtreecommitdiff
path: root/ext/Time
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-11-25 23:43:30 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-11-25 23:43:30 +0000
commitc7f7de79b29dbf9dc4dad160031670476cc2ac71 (patch)
treee1c6f0ca7f45838738f58b11c98265a6ec214c9f /ext/Time
parent5655ed86abaf0d94bea5cf33403d6fe9ab5c6a5e (diff)
downloadperl-c7f7de79b29dbf9dc4dad160031670476cc2ac71.tar.gz
Can't do subsecond alarms without ualarm; and break out
early if alarms do not seem to be coming in as expected. p4raw-id: //depot/perl@13278
Diffstat (limited to 'ext/Time')
-rw-r--r--ext/Time/HiRes/HiRes.t26
1 files changed, 20 insertions, 6 deletions
diff --git a/ext/Time/HiRes/HiRes.t b/ext/Time/HiRes/HiRes.t
index ad0dcc32ba..2046fed39a 100644
--- a/ext/Time/HiRes/HiRes.t
+++ b/ext/Time/HiRes/HiRes.t
@@ -146,14 +146,15 @@ if (!$have_time) {
unless (defined &Time::HiRes::gettimeofday
&& defined &Time::HiRes::ualarm
- && defined &Time::HiRes::usleep) {
+ && defined &Time::HiRes::usleep
+ && $Config{d_ualarm}) {
for (15..17) {
print "ok $_ # skipped\n";
}
} else {
use Time::HiRes qw (time alarm sleep);
- my ($f, $r, $i);
+ my ($f, $r, $i, $not);
$f = time;
print "# time...$f\n";
@@ -169,18 +170,31 @@ unless (defined &Time::HiRes::gettimeofday
while ($i > 0)
{
alarm(0.3);
- select (undef, undef, undef, 10);
- print "# Select returned! $i ", Time::HiRes::tv_interval ($r), "\n";
+ select (undef, undef, undef, 3);
+ my $ival = Time::HiRes::tv_interval ($r);
+ print "# Select returned! $i $ival\n";
+ my $exp = 0.3 * (5 - $i);
+ if (abs($ival/$exp) - 1 > 0.1) {
+ $not = "$exp sleep took $ival";
+ last;
+ }
}
sub tick
{
$i--;
- print "# Tick! $i ", Time::HiRes::tv_interval ($r), "\n";
+ my $ival = Time::HiRes::tv_interval ($r);
+ print "# Tick! $i $ival\n";
+ my $exp = 0.3 * (5 - $i);
+ if (abs($ival/$exp) - 1 > 0.1) {
+ $not = "$exp sleep took $ival";
+ $i = 0;
+ }
}
+
alarm(0); # can't cancel usig %SIG
- print "ok 17\n";
+ print $not ? "not ok 17 # $not\n" : "ok 17\n";
}
unless (defined &Time::HiRes::setitimer