Commit | Line | Data |
a0d0e21e |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
a0d0e21e |
6 | require Config; import Config; |
fa6b8193 |
7 | if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) { |
c764b42b |
8 | print "1..0\n"; |
a0d0e21e |
9 | exit 0; |
10 | } |
11 | } |
c07a80fd |
12 | |
212caf55 |
13 | use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write |
14 | errno); |
a0d0e21e |
15 | use strict subs; |
16 | |
c07a80fd |
17 | $| = 1; |
212caf55 |
18 | print "1..29\n"; |
a0d0e21e |
19 | |
6dead956 |
20 | $Is_W32 = $^O eq 'MSWin32'; |
2986a63f |
21 | $Is_NetWare = $^O eq 'NetWare'; |
6bbf1b34 |
22 | $Is_Dos = $^O eq 'dos'; |
c9ff6e92 |
23 | $Is_MPE = $^O eq 'mpeix'; |
6dead956 |
24 | |
c07a80fd |
25 | $testfd = open("TEST", O_RDONLY, 0) and print "ok 1\n"; |
a0d0e21e |
26 | read($testfd, $buffer, 9) if $testfd > 2; |
c07a80fd |
27 | print $buffer eq "#!./perl\n" ? "ok 2\n" : "not ok 2\n"; |
28 | |
29 | write(1,"ok 3\nnot ok 3\n", 5); |
a0d0e21e |
30 | |
6bbf1b34 |
31 | if ($Is_Dos) { |
32 | for (4..5) { |
33 | print "ok $_ # skipped, no pipe() support on dos\n"; |
34 | } |
35 | } else { |
a0d0e21e |
36 | @fds = POSIX::pipe(); |
c07a80fd |
37 | print $fds[0] > $testfd ? "ok 4\n" : "not ok 4\n"; |
38 | CORE::open($reader = \*READER, "<&=".$fds[0]); |
39 | CORE::open($writer = \*WRITER, ">&=".$fds[1]); |
40 | print $writer "ok 5\n"; |
a0d0e21e |
41 | close $writer; |
42 | print <$reader>; |
43 | close $reader; |
6bbf1b34 |
44 | } |
a0d0e21e |
45 | |
6bbf1b34 |
46 | if ($Is_W32 || $Is_Dos) { |
6dead956 |
47 | for (6..11) { |
6bbf1b34 |
48 | print "ok $_ # skipped, no sigaction support on win32/dos\n"; |
6dead956 |
49 | } |
50 | } |
51 | else { |
a0d0e21e |
52 | $sigset = new POSIX::SigSet 1,3; |
53 | delset $sigset 1; |
c07a80fd |
54 | if (!ismember $sigset 1) { print "ok 6\n" } |
55 | if (ismember $sigset 3) { print "ok 7\n" } |
a0d0e21e |
56 | $mask = new POSIX::SigSet &SIGINT; |
57 | $action = new POSIX::SigAction 'main::SigHUP', $mask, 0; |
58 | sigaction(&SIGHUP, $action); |
59 | $SIG{'INT'} = 'SigINT'; |
60 | kill 'HUP', $$; |
61 | sleep 1; |
c07a80fd |
62 | print "ok 11\n"; |
a0d0e21e |
63 | |
64 | sub SigHUP { |
c07a80fd |
65 | print "ok 8\n"; |
a0d0e21e |
66 | kill 'INT', $$; |
67 | sleep 2; |
0b3d46e6 |
68 | print "ok 9\n"; |
a0d0e21e |
69 | } |
70 | |
71 | sub SigINT { |
0b3d46e6 |
72 | print "ok 10\n"; |
a0d0e21e |
73 | } |
6dead956 |
74 | } |
a0d0e21e |
75 | |
c9ff6e92 |
76 | if ($Is_MPE) { |
77 | print "ok 12 # skipped, _POSIX_OPEN_MAX is inaccurate on MPE\n" |
78 | } else { |
79 | print &_POSIX_OPEN_MAX > $fds[1] ? "ok 12\n" : "not ok 12\n" |
80 | } |
a0d0e21e |
81 | |
c07a80fd |
82 | print getcwd() =~ m#/t$# ? "ok 13\n" : "not ok 13\n"; |
a0d0e21e |
83 | |
a89d8a78 |
84 | # Check string conversion functions. |
85 | |
86 | if ($Config{d_strtod}) { |
ff68c719 |
87 | $lc = &POSIX::setlocale(&POSIX::LC_NUMERIC, 'C') if $Config{d_setlocale}; |
a89d8a78 |
88 | ($n, $x) = &POSIX::strtod('3.14159_OR_SO'); |
fc68435e |
89 | # Using long double NVs may introduce greater accuracy than wanted. |
58a9a5d5 |
90 | $n =~ s/^3.1415(8999|9000)\d*$/3.14159/ |
fc68435e |
91 | if $Config{uselongdouble} eq 'define'; |
7dd955c9 |
92 | print (($n == 3.14159) && ($x == 6) ? |
56dd5b29 |
93 | "ok 14\n" : "not ok 14\n"); |
ff68c719 |
94 | &POSIX::setlocale(&POSIX::LC_NUMERIC, $lc) if $Config{d_setlocale}; |
a89d8a78 |
95 | } else { print "# strtod not present\n", "ok 14\n"; } |
96 | |
97 | if ($Config{d_strtol}) { |
98 | ($n, $x) = &POSIX::strtol('21_PENGUINS'); |
99 | print (($n == 21) && ($x == 9) ? "ok 15\n" : "not ok 15\n"); |
100 | } else { print "# strtol not present\n", "ok 15\n"; } |
101 | |
102 | if ($Config{d_strtoul}) { |
103 | ($n, $x) = &POSIX::strtoul('88_TEARS'); |
104 | print (($n == 88) && ($x == 6) ? "ok 16\n" : "not ok 16\n"); |
105 | } else { print "# strtoul not present\n", "ok 16\n"; } |
106 | |
a0d0e21e |
107 | # Pick up whether we're really able to dynamically load everything. |
a89d8a78 |
108 | print &POSIX::acos(1.0) == 0.0 ? "ok 17\n" : "not ok 17\n"; |
a0d0e21e |
109 | |
84ef74c4 |
110 | # This can coredump if struct tm has a timezone field and we |
111 | # didn't detect it. If this fails, try adding |
112 | # -DSTRUCT_TM_HASZONE to your cflags when compiling ext/POSIX/POSIX.c. |
113 | # See ext/POSIX/hints/sunos_4.pl and ext/POSIX/hints/linux.pl |
114 | print POSIX::strftime("ok 18 # %H:%M, on %D\n", localtime()); |
115 | |
33c0e3ec |
116 | # If that worked, validate the mini_mktime() routine's normalisation of |
117 | # input fields to strftime(). |
118 | sub try_strftime { |
119 | my $num = shift; |
120 | my $expect = shift; |
121 | my $got = POSIX::strftime("%a %b %d %H:%M:%S %Y %j", @_); |
122 | if ($got eq $expect) { |
123 | print "ok $num\n"; |
124 | } |
125 | else { |
126 | print "# expected: $expect\n# got: $got\nnot ok $num\n"; |
127 | } |
128 | } |
129 | |
130 | $lc = &POSIX::setlocale(&POSIX::LC_TIME, 'C') if $Config{d_setlocale}; |
131 | try_strftime(19, "Wed Feb 28 00:00:00 1996 059", 0,0,0, 28,1,96); |
132 | try_strftime(20, "Thu Feb 29 00:00:60 1996 060", 60,0,-24, 30,1,96); |
133 | try_strftime(21, "Fri Mar 01 00:00:00 1996 061", 0,0,-24, 31,1,96); |
134 | try_strftime(22, "Sun Feb 28 00:00:00 1999 059", 0,0,0, 28,1,99); |
135 | try_strftime(23, "Mon Mar 01 00:00:00 1999 060", 0,0,24, 28,1,99); |
136 | try_strftime(24, "Mon Feb 28 00:00:00 2000 059", 0,0,0, 28,1,100); |
137 | try_strftime(25, "Tue Feb 29 00:00:00 2000 060", 0,0,0, 0,2,100); |
138 | try_strftime(26, "Wed Mar 01 00:00:00 2000 061", 0,0,0, 1,2,100); |
d0e85dce |
139 | try_strftime(27, "Fri Mar 31 00:00:00 2000 091", 0,0,0, 31,2,100); |
33c0e3ec |
140 | &POSIX::setlocale(&POSIX::LC_TIME, $lc) if $Config{d_setlocale}; |
141 | |
212caf55 |
142 | { |
143 | for my $test (0, 1) { |
144 | $! = 0; |
145 | # POSIX::errno is autoloaded. |
146 | # Autoloading requires many system calls. |
147 | # errno() looks at $! to generate its result. |
148 | # Autoloading should not munge the value. |
149 | my $foo = $!; |
150 | my $errno = POSIX::errno(); |
151 | print "not " unless $errno == $foo; |
152 | print "ok ", 28 + $test, "\n"; |
153 | } |
154 | } |
155 | |
c07a80fd |
156 | $| = 0; |
ec40c0cd |
157 | # The following line assumes buffered output, which may be not true with EMX: |
601f2d16 |
158 | print '@#!*$@(!@#$' unless ($^O eq 'os2' || $^O eq 'uwin' || $^O eq 'os390' || |
159 | (defined $ENV{PERLIO} && |
160 | $ENV{PERLIO} eq 'unix' && |
161 | $Config::Config{useperlio})); |
a0d0e21e |
162 | _exit(0); |