Skip to content

Commit db55b51

Browse files
author
Abigail
committed
t/io/eintr.t: Skip some tests on pre-16 Darwin.
The tests where we write a string larger than the pipe size to a pipe hang on 15.6.0, while they seem to work on Darwin 17.7.0. So we will skip these tests on Darwin, if the major version is less than 16. (We may adjust this is we have more reports on which versions between 15.6.0 and 17.7.0 success/fail). Note that the tests hang even if we send a string of 512 characters, which is much, much smaller than the actual size of the string in the test.
1 parent 72b2b1d commit db55b51

File tree

1 file changed

+62
-55
lines changed

1 file changed

+62
-55
lines changed

t/io/eintr.t

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'cygwin' || $^O =~ /freebsd/ || $
5959
exit 0;
6060
}
6161

62+
63+
6264
my ($in, $out, $st, $sigst, $buf);
6365

6466
plan(tests => 10);
@@ -96,60 +98,65 @@ alarm(0);
9698
ok(!$st, 'read/die: read status');
9799
ok(close($in), 'read/die: close status');
98100

99-
# This used to be 1_000_000, but on Linux/ppc64 (POWER7) this kept
100-
# consistently failing. At exactly 0x100000 it started passing
101-
# again. Now we're asking the kernel what the pipe buffer is, and if
102-
# that fails, hoping this number is bigger than any pipe buffer.
103-
my $surely_this_arbitrary_number_is_fine = (eval {
104-
use Fcntl qw(F_GETPIPE_SZ);
105-
fcntl($out, F_GETPIPE_SZ, 0);
106-
} || 0xfffff) + 1;
107-
108-
# close during print
109-
110-
fresh_io;
111-
$SIG{ALRM} = sub { $sigst = close($out) ? "ok" : "nok" };
112-
$buf = "a" x $surely_this_arbitrary_number_is_fine . "\n";
113-
select $out; $| = 1; select STDOUT;
114-
alarm(1);
115-
$st = print $out $buf;
116-
alarm(0);
117-
is($sigst, 'nok', 'print/close: sig handler close status');
118-
ok(!$st, 'print/close: print status');
119-
ok(!close($out), 'print/close: close status');
120-
121-
# die during print
122-
123-
fresh_io;
124-
$SIG{ALRM} = sub { die };
125-
$buf = "a" x $surely_this_arbitrary_number_is_fine . "\n";
126-
select $out; $| = 1; select STDOUT;
127-
alarm(1);
128-
$st = eval { print $out $buf };
129-
alarm(0);
130-
ok(!$st, 'print/die: print status');
131-
# the close will hang since there's data to flush, so use alarm
132-
alarm(1);
133-
ok(!eval {close($out)}, 'print/die: close status');
134-
alarm(0);
135-
136-
# close during close
137-
138-
# Apparently there's nothing in standard Linux that can cause an
139-
# EINTR in close(2); but run the code below just in case it does on some
140-
# platform, just to see if it segfaults.
141-
fresh_io;
142-
$SIG{ALRM} = sub { $sigst = close($in) ? "ok" : "nok" };
143-
alarm(1);
144-
close $in;
145-
alarm(0);
146-
147-
# die during close
148-
149-
fresh_io;
150-
$SIG{ALRM} = sub { die };
151-
alarm(1);
152-
eval { close $in };
153-
alarm(0);
101+
SKIP: {
102+
skip "Tests hang on older versions of Darwin", 5
103+
if $^O eq 'darwin' && $osmajmin < 16;
104+
105+
# This used to be 1_000_000, but on Linux/ppc64 (POWER7) this kept
106+
# consistently failing. At exactly 0x100000 it started passing
107+
# again. Now we're asking the kernel what the pipe buffer is, and if
108+
# that fails, hoping this number is bigger than any pipe buffer.
109+
my $surely_this_arbitrary_number_is_fine = (eval {
110+
use Fcntl qw(F_GETPIPE_SZ);
111+
fcntl($out, F_GETPIPE_SZ, 0);
112+
} || 0xfffff) + 1;
113+
114+
# close during print
115+
116+
fresh_io;
117+
$SIG{ALRM} = sub { $sigst = close($out) ? "ok" : "nok" };
118+
$buf = "a" x $surely_this_arbitrary_number_is_fine . "\n";
119+
select $out; $| = 1; select STDOUT;
120+
alarm(1);
121+
$st = print $out $buf;
122+
alarm(0);
123+
is($sigst, 'nok', 'print/close: sig handler close status');
124+
ok(!$st, 'print/close: print status');
125+
ok(!close($out), 'print/close: close status');
126+
127+
# die during print
128+
129+
fresh_io;
130+
$SIG{ALRM} = sub { die };
131+
$buf = "a" x $surely_this_arbitrary_number_is_fine . "\n";
132+
select $out; $| = 1; select STDOUT;
133+
alarm(1);
134+
$st = eval { print $out $buf };
135+
alarm(0);
136+
ok(!$st, 'print/die: print status');
137+
# the close will hang since there's data to flush, so use alarm
138+
alarm(1);
139+
ok(!eval {close($out)}, 'print/die: close status');
140+
alarm(0);
141+
142+
# close during close
143+
144+
# Apparently there's nothing in standard Linux that can cause an
145+
# EINTR in close(2); but run the code below just in case it does on some
146+
# platform, just to see if it segfaults.
147+
fresh_io;
148+
$SIG{ALRM} = sub { $sigst = close($in) ? "ok" : "nok" };
149+
alarm(1);
150+
close $in;
151+
alarm(0);
152+
153+
# die during close
154+
155+
fresh_io;
156+
$SIG{ALRM} = sub { die };
157+
alarm(1);
158+
eval { close $in };
159+
alarm(0);
160+
}
154161

155162
# vim: ts=4 sts=4 sw=4:

0 commit comments

Comments
 (0)