Add test for Net::protoent.
[p5sagit/p5-mst-13.2.git] / t / lib / fcntl.t
CommitLineData
a39702a6 1#!./perl
2
3# A modest test: exercises only O_WRONLY, O_CREAT, and O_RDONLY.
4# Have to be modest to be portable: could possibly extend testing
5# also to O_RDWR and O_APPEND, but dunno about the portability of,
6# say, O_TRUNC and O_EXCL, not to mention O_NONBLOCK.
7
8use Fcntl;
9
10print "1..6\n";
11
12print "ok 1\n";
13
14if (sysopen(my $wo, "fcntl$$", O_WRONLY|O_CREAT)) {
15 print "ok 2\n";
16 if (syswrite($wo, "foo") == 3) {
17 print "ok 3\n";
18 close($wo);
19 if (sysopen(my $ro, "fcntl$$", O_RDONLY)) {
20 print "ok 4\n";
21 if (sysread($ro, my $read, 3)) {
22 print "ok 5\n";
23 if ($read eq "foo") {
24 print "ok 6\n";
25 } else {
26 print "not ok 6 # content '$read' not ok\n";
27 }
28 } else {
29 print "not ok 5 # sysread failed: $!\n";
30 }
31 } else {
32 print "not ok 4 # sysopen O_RDONLY failed: $!\n";
33 }
34 close($ro);
35 } else {
36 print "not ok 3 # syswrite failed: $!\n";
37 }
38 close($wo);
39} else {
40 print "not ok 2 # sysopen O_WRONLY failed: $!\n";
41}
42
43END {
44 1 while unlink "fcntl$$";
45}
46