Mailing List Archive

user rudly barges in with a test script
I have perl5.001m installed on both a HP-UX box and a machine running SunOS.
Also perl 4.036 is running on the sun. Test 2 fails on both perls on the Sun
but not the HP. I'm not asking for help with this, but you may want to
include these tests or some variation in the make test suite.

-yary



#!./perl
print "1..4\n";

# Test the alarm mechanism

sub alarm {$wentoff = 1;}
$SIG{'ALRM'}='alarm';
alarm 2;
$interval = sleep 5;

if ($interval >= 2 && $interval <= 3) {print "ok 1\n";}
else {print "not ok 1 '$interval' should be 2 or 3 seconds\n";}

if ($wentoff) {print "ok 2\n";}
else {print "not ok 2 The alarm signal handler was not called.\n";}


# Do some testing of select (and time)

$start = time;
($num, $timeleft) = select (undef, undef, undef, 1.5);
$interval = time - $start;

if ($timeleft == 1.5 || $timeleft == 0) {print "ok 3\n";}
else {print "not ok 3 '$timeleft' should be 0 or 1.5 seconds\n";}

if ($interval >= 1 && $interval <= 2) {print "ok 4\n";}
else {print "not ok 4 select should have waited between 1 and 2 seconds, not
$interval seconds\n";}
Re: user rudly barges in with a test script [ In reply to ]
In <9508302200.AA01588@shawnee.raynet.com>
On Wed, 30 Aug 1995 15:00:04 -0700
Yary Hluchan <yhluchan@ops.raynet.com> writes:
>I have perl5.001m installed on both a HP-UX box and a machine running SunOS.
>Also perl 4.036 is running on the sun. Test 2 fails on both perls on the Sun
>but not the HP. I'm not asking for help with this, but you may want to
>include these tests or some variation in the make test suite.
>
That is a difference between SunOS's BSD-ish sleep() and HP-UX's SYSV-ish
sleep - from man 3 sleep on SunOS:

DESCRIPTION
sleep() suspends the current process from execution for the
number of seconds specified by the argument. The actual
suspension time may be an arbitrary amount longer because of
other activity in the system.

sleep() is implemented by setting an interval timer and
pausing until it expires. The previous state of this timer
is saved and restored. If the sleep time exceeds the time
to the expiration of the previous value of the timer, the
process sleeps only until the timer would have expired, and
the signal which occurs with the expiration of the timer is
sent one second later.

That is sleep() re-uses same signal as alarm uses, and then re-issues
the alarm signal 'later'.