Not having POSIX shouldn't result in test failing TEST harness.
[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;
7 if ($Config{'extensions'} !~ /\bPOSIX\b/) {
c764b42b 8 print "1..0\n";
a0d0e21e 9 exit 0;
10 }
11}
12use FileHandle;
13use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read write);
14use strict subs;
15
16$mystdout = new_from_fd FileHandle 1,"w";
17autoflush STDOUT;
18autoflush $mystdout;
19print "1..16\n";
20
21print $mystdout "ok ",fileno($mystdout),"\n";
22write(1,"ok 2\nnot ok 2\n", 5);
23
24$testfd = open("TEST", O_RDONLY, 0) and print "ok 3\n";
25read($testfd, $buffer, 9) if $testfd > 2;
26print $buffer eq "#!./perl\n" ? "ok 4\n" : "not ok 4\n";
27
28@fds = POSIX::pipe();
748a9306 29print $fds[0] > $testfd ? "ok 5\n" : "not ok 5\n";
a0d0e21e 30$writer = FileHandle->new_from_fd($fds[1], "w");
31$reader = FileHandle->new_from_fd($fds[0], "r");
32print $writer "ok 6\n";
33close $writer;
34print <$reader>;
35close $reader;
36
37$sigset = new POSIX::SigSet 1,3;
38delset $sigset 1;
39if (!ismember $sigset 1) { print "ok 7\n" }
40if (ismember $sigset 3) { print "ok 8\n" }
41$mask = new POSIX::SigSet &SIGINT;
42$action = new POSIX::SigAction 'main::SigHUP', $mask, 0;
43sigaction(&SIGHUP, $action);
44$SIG{'INT'} = 'SigINT';
45kill 'HUP', $$;
46sleep 1;
47print "ok 12\n";
48
49sub SigHUP {
50 print "ok 9\n";
51 kill 'INT', $$;
52 sleep 2;
53 print "ok 10\n";
54}
55
56sub SigINT {
57 print "ok 11\n";
58}
59
60print &_POSIX_OPEN_MAX > $fds[1] ? "ok 13\n" : "not ok 13\n";
61
62print getcwd() =~ m#/t$# ? "ok 14\n" : "not ok 14\n";
63
64# Pick up whether we're really able to dynamically load everything.
65print &POSIX::acos(1.0) == 0.0 ? "ok 15\n" : "not ok 15\n";
66
67ungetc STDIN 65;
68CORE::read(STDIN, $buf,1);
69print $buf eq 'A' ? "ok 16\n" : "not ok 16\n";
70
71flush STDOUT;
72autoflush STDOUT 0;
73print '@#!*$@(!@#$';
74_exit(0);