update Changes, perlhist.pod, beginnings of perldelta.pod
[p5sagit/p5-mst-13.2.git] / t / lib / posix.t
CommitLineData
a0d0e21e 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
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
84ef74c4 13use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write);
a0d0e21e 14use strict subs;
15
c07a80fd 16$| = 1;
84ef74c4 17print "1..18\n";
a0d0e21e 18
6dead956 19$Is_W32 = $^O eq 'MSWin32';
20
c07a80fd 21$testfd = open("TEST", O_RDONLY, 0) and print "ok 1\n";
a0d0e21e 22read($testfd, $buffer, 9) if $testfd > 2;
c07a80fd 23print $buffer eq "#!./perl\n" ? "ok 2\n" : "not ok 2\n";
24
25write(1,"ok 3\nnot ok 3\n", 5);
a0d0e21e 26
27@fds = POSIX::pipe();
c07a80fd 28print $fds[0] > $testfd ? "ok 4\n" : "not ok 4\n";
29CORE::open($reader = \*READER, "<&=".$fds[0]);
30CORE::open($writer = \*WRITER, ">&=".$fds[1]);
31print $writer "ok 5\n";
a0d0e21e 32close $writer;
33print <$reader>;
34close $reader;
35
6dead956 36if ($Is_W32) {
37 for (6..11) {
38 print "ok $_ # skipped, no sigaction support on win32\n";
39 }
40}
41else {
a0d0e21e 42$sigset = new POSIX::SigSet 1,3;
43delset $sigset 1;
c07a80fd 44if (!ismember $sigset 1) { print "ok 6\n" }
45if (ismember $sigset 3) { print "ok 7\n" }
a0d0e21e 46$mask = new POSIX::SigSet &SIGINT;
47$action = new POSIX::SigAction 'main::SigHUP', $mask, 0;
48sigaction(&SIGHUP, $action);
49$SIG{'INT'} = 'SigINT';
50kill 'HUP', $$;
51sleep 1;
c07a80fd 52print "ok 11\n";
a0d0e21e 53
54sub SigHUP {
c07a80fd 55 print "ok 8\n";
5e8184af 56 $n = 8;
a0d0e21e 57 kill 'INT', $$;
58 sleep 2;
5e8184af 59 ++$n;
60 print "ok $n\n";
a0d0e21e 61}
62
63sub SigINT {
5e8184af 64 ++$n;
65 print "ok $n\n";
a0d0e21e 66}
6dead956 67}
a0d0e21e 68
c07a80fd 69print &_POSIX_OPEN_MAX > $fds[1] ? "ok 12\n" : "not ok 12\n";
a0d0e21e 70
c07a80fd 71print getcwd() =~ m#/t$# ? "ok 13\n" : "not ok 13\n";
a0d0e21e 72
a89d8a78 73# Check string conversion functions.
74
75if ($Config{d_strtod}) {
ff68c719 76 $lc = &POSIX::setlocale(&POSIX::LC_NUMERIC, 'C') if $Config{d_setlocale};
a89d8a78 77 ($n, $x) = &POSIX::strtod('3.14159_OR_SO');
78 print (($n == 3.14159) && ($x == 6) ? "ok 14\n" : "not ok 14\n");
ff68c719 79 &POSIX::setlocale(&POSIX::LC_NUMERIC, $lc) if $Config{d_setlocale};
a89d8a78 80} else { print "# strtod not present\n", "ok 14\n"; }
81
82if ($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"; }
86
87if ($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"; }
91
a0d0e21e 92# Pick up whether we're really able to dynamically load everything.
a89d8a78 93print &POSIX::acos(1.0) == 0.0 ? "ok 17\n" : "not ok 17\n";
a0d0e21e 94
84ef74c4 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
99print POSIX::strftime("ok 18 # %H:%M, on %D\n", localtime());
100
c07a80fd 101$| = 0;
a0d0e21e 102print '@#!*$@(!@#$';
103_exit(0);