xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/io/binmode.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl -w
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = qw(. ../lib);
6*0Sstevel@tonic-gate    require './test.pl';
7*0Sstevel@tonic-gate}
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gateuse Config;
10*0Sstevel@tonic-gateBEGIN {
11*0Sstevel@tonic-gate    eval {require Errno; Errno->import;};
12*0Sstevel@tonic-gate}
13*0Sstevel@tonic-gateplan(tests => 9);
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gateok( binmode(STDERR),            'STDERR made binary' );
16*0Sstevel@tonic-gateif (find PerlIO::Layer 'perlio') {
17*0Sstevel@tonic-gate  ok( binmode(STDERR, ":unix"),   '  with unix discipline' );
18*0Sstevel@tonic-gate} else {
19*0Sstevel@tonic-gate  ok(1,   '  skip unix discipline without PerlIO layers' );
20*0Sstevel@tonic-gate}
21*0Sstevel@tonic-gateok( binmode(STDERR, ":raw"),    '  raw' );
22*0Sstevel@tonic-gateok( binmode(STDERR, ":crlf"),   '  and crlf' );
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gate# If this one fails, we're in trouble.  So we just bail out.
25*0Sstevel@tonic-gateok( binmode(STDOUT),            'STDOUT made binary' )      || exit(1);
26*0Sstevel@tonic-gateif (find PerlIO::Layer 'perlio') {
27*0Sstevel@tonic-gate  ok( binmode(STDOUT, ":unix"),   '  with unix discipline' );
28*0Sstevel@tonic-gate} else {
29*0Sstevel@tonic-gate  ok(1,   '  skip unix discipline without PerlIO layers' );
30*0Sstevel@tonic-gate}
31*0Sstevel@tonic-gateok( binmode(STDOUT, ":raw"),    '  raw' );
32*0Sstevel@tonic-gateok( binmode(STDOUT, ":crlf"),   '  and crlf' );
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateSKIP: {
35*0Sstevel@tonic-gate    skip "minitest", 1 if $ENV{PERL_CORE_MINITEST};
36*0Sstevel@tonic-gate    skip "no EBADF", 1 if (!exists &Errno::EBADF);
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate    no warnings 'io';
39*0Sstevel@tonic-gate    $! = 0;
40*0Sstevel@tonic-gate    binmode(B);
41*0Sstevel@tonic-gate    ok($! == &Errno::EBADF);
42*0Sstevel@tonic-gate}
43