X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Falarm.t;h=8be24db99607fb812bd5ecb8422872e3ecd3b7ec;hb=bd7d4f4d586a396d1b104a293cce339c8d63ce5a;hp=12c8c264c446ca321c18320ff01b90cec8800ecb;hpb=1689481e5512794ca867be78f00013097fdd63c0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/alarm.t b/t/op/alarm.t index 12c8c26..8be24db 100644 --- a/t/op/alarm.t +++ b/t/op/alarm.t @@ -13,7 +13,7 @@ BEGIN { } } -plan tests => 4; +plan tests => 5; my $Perl = which_perl(); my $start_time = time; @@ -29,7 +29,7 @@ my $diff = time - $start_time; # alarm time might be one second less than you said. is( $@, "ALARM!\n", 'alarm w/$SIG{ALRM} vs inf loop' ); -ok( $diff == 3 || $diff == 2, ' right time' ); +ok( abs($diff - 3) <= 1, " right time" ); my $start_time = time; @@ -44,4 +44,16 @@ $diff = time - $start_time; # alarm time might be one second less than you said. is( $@, "ALARM!\n", 'alarm w/$SIG{ALRM} vs system()' ); -ok( $diff == 3 || $diff == 2, ' right time' ); +{ + local $TODO = "Why does system() block alarm() on $^O?" + if $^O eq 'VMS' || $^O eq'MacOS' || $^O eq 'dos'; + ok( abs($diff - 3) <= 1, " right time (waited $diff secs for 3-sec alarm)" ); +} + + +{ + local $SIG{"ALRM"} = sub { die }; + eval { alarm(1); my $x = qx($Perl -e "sleep 3") }; + chomp (my $foo = "foo\n"); + ok($foo eq "foo", '[perl #33928] chomp() fails after alarm(), `sleep`'); +}