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