5 unshift @INC, '../lib';
6 require Config; import Config;
7 if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
13 use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write);
19 $Is_W32 = $^O eq 'MSWin32';
21 $testfd = open("TEST", O_RDONLY, 0) and print "ok 1\n";
22 read($testfd, $buffer, 9) if $testfd > 2;
23 print $buffer eq "#!./perl\n" ? "ok 2\n" : "not ok 2\n";
25 write(1,"ok 3\nnot ok 3\n", 5);
28 print $fds[0] > $testfd ? "ok 4\n" : "not ok 4\n";
29 CORE::open($reader = \*READER, "<&=".$fds[0]);
30 CORE::open($writer = \*WRITER, ">&=".$fds[1]);
31 print $writer "ok 5\n";
38 print "ok $_ # skipped, no sigaction support on win32\n";
42 $sigset = new POSIX::SigSet 1,3;
44 if (!ismember $sigset 1) { print "ok 6\n" }
45 if (ismember $sigset 3) { print "ok 7\n" }
46 $mask = new POSIX::SigSet &SIGINT;
47 $action = new POSIX::SigAction 'main::SigHUP', $mask, 0;
48 sigaction(&SIGHUP, $action);
49 $SIG{'INT'} = 'SigINT';
66 print &_POSIX_OPEN_MAX > $fds[1] ? "ok 12\n" : "not ok 12\n";
68 print getcwd() =~ m#/t$# ? "ok 13\n" : "not ok 13\n";
70 # Check string conversion functions.
72 if ($Config{d_strtod}) {
73 $lc = &POSIX::setlocale(&POSIX::LC_NUMERIC, 'C') if $Config{d_setlocale};
74 ($n, $x) = &POSIX::strtod('3.14159_OR_SO');
75 # Using long double NVs may introduce greater accuracy than wanted.
76 $n =~ s/^3.14158999\d*$/3.14159/
77 if $Config{uselongdouble} eq 'define';
78 print (($n == 3.14159) && ($x == 6) ? "ok 14\n" : "not ok 14\n");
79 &POSIX::setlocale(&POSIX::LC_NUMERIC, $lc) if $Config{d_setlocale};
80 } else { print "# strtod not present\n", "ok 14\n"; }
82 if ($Config{d_strtol}) {
83 ($n, $x) = &POSIX::strtol('21_PENGUINS');
84 print (($n == 21) && ($x == 9) ? "ok 15\n" : "not ok 15\n");
85 } else { print "# strtol not present\n", "ok 15\n"; }
87 if ($Config{d_strtoul}) {
88 ($n, $x) = &POSIX::strtoul('88_TEARS');
89 print (($n == 88) && ($x == 6) ? "ok 16\n" : "not ok 16\n");
90 } else { print "# strtoul not present\n", "ok 16\n"; }
92 # Pick up whether we're really able to dynamically load everything.
93 print &POSIX::acos(1.0) == 0.0 ? "ok 17\n" : "not ok 17\n";
95 # This can coredump if struct tm has a timezone field and we
96 # didn't detect it. If this fails, try adding
97 # -DSTRUCT_TM_HASZONE to your cflags when compiling ext/POSIX/POSIX.c.
98 # See ext/POSIX/hints/sunos_4.pl and ext/POSIX/hints/linux.pl
99 print POSIX::strftime("ok 18 # %H:%M, on %D\n", localtime());
101 # If that worked, validate the mini_mktime() routine's normalisation of
102 # input fields to strftime().
106 my $got = POSIX::strftime("%a %b %d %H:%M:%S %Y %j", @_);
107 if ($got eq $expect) {
111 print "# expected: $expect\n# got: $got\nnot ok $num\n";
115 $lc = &POSIX::setlocale(&POSIX::LC_TIME, 'C') if $Config{d_setlocale};
116 try_strftime(19, "Wed Feb 28 00:00:00 1996 059", 0,0,0, 28,1,96);
117 try_strftime(20, "Thu Feb 29 00:00:60 1996 060", 60,0,-24, 30,1,96);
118 try_strftime(21, "Fri Mar 01 00:00:00 1996 061", 0,0,-24, 31,1,96);
119 try_strftime(22, "Sun Feb 28 00:00:00 1999 059", 0,0,0, 28,1,99);
120 try_strftime(23, "Mon Mar 01 00:00:00 1999 060", 0,0,24, 28,1,99);
121 try_strftime(24, "Mon Feb 28 00:00:00 2000 059", 0,0,0, 28,1,100);
122 try_strftime(25, "Tue Feb 29 00:00:00 2000 060", 0,0,0, 0,2,100);
123 try_strftime(26, "Wed Mar 01 00:00:00 2000 061", 0,0,0, 1,2,100);
124 &POSIX::setlocale(&POSIX::LC_TIME, $lc) if $Config{d_setlocale};
127 # The following line assumes buffered output, which may be not true with EMX:
128 print '@#!*$@(!@#$' unless ($^O eq 'os2' || $^O eq 'uwin' || $^O eq 'os390');