8 # A modest test: exercises only O_WRONLY, O_CREAT, and O_RDONLY.
9 # Have to be modest to be portable: could possibly extend testing
10 # also to O_RDWR and O_APPEND, but dunno about the portability of,
11 # say, O_TRUNC and O_EXCL, not to mention O_NONBLOCK.
19 if (sysopen(my $wo, "fcntl$$", O_WRONLY|O_CREAT)) {
21 if (syswrite($wo, "foo") == 3) {
24 if (sysopen(my $ro, "fcntl$$", O_RDONLY)) {
26 if (sysread($ro, my $read, 3)) {
31 print "not ok 6 # content '$read' not ok\n";
34 print "not ok 5 # sysread failed: $!\n";
37 print "not ok 4 # sysopen O_RDONLY failed: $!\n";
41 print "not ok 3 # syswrite failed: $!\n";
45 print "not ok 2 # sysopen O_WRONLY failed: $!\n";
48 # Opening of character special devices gets special treatment in doio.c
49 # Didn't work as of perl-5.8.0-RC2.
50 use File::Spec; # To portably get /dev/null
52 my $devnull = File::Spec->devnull;
54 if (sysopen(my $wo, $devnull, O_WRONLY)) {
55 print "ok 7 # open /dev/null O_WRONLY\n";
59 print "not ok 7 # open /dev/null O_WRONLY\n";
63 print "ok 7 # Skipping /dev/null sysopen O_WRONLY test\n";
67 1 while unlink "fcntl$$";