Add a test of its very own for Fcntl. Hopefully portable.
Jarkko Hietaniemi [Mon, 21 May 2001 13:17:28 +0000 (13:17 +0000)]
p4raw-id: //depot/perl@10175

MANIFEST
t/lib/fcntl.t [new file with mode: 0644]

index e6c5179..21792ab 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1505,6 +1505,7 @@ t/lib/env.t               See if Env works
 t/lib/errno.t          See if Errno works
 t/lib/exporter.t        See if Exporter works
 t/lib/fatal.t           See if Fatal works
+t/lib/fcntl.t           See if Fcntl works
 t/lib/fields.t          See if base/fields works
 t/lib/filecache.t      See if FileCache works
 t/lib/filecopy.t       See if File::Copy works
diff --git a/t/lib/fcntl.t b/t/lib/fcntl.t
new file mode 100644 (file)
index 0000000..24ade27
--- /dev/null
@@ -0,0 +1,46 @@
+#!./perl
+
+# A modest test: exercises only O_WRONLY, O_CREAT, and O_RDONLY.
+# Have to be modest to be portable: could possibly extend testing
+# also to O_RDWR and O_APPEND, but dunno about the portability of,
+# say, O_TRUNC and O_EXCL, not to mention O_NONBLOCK.
+
+use Fcntl;
+
+print "1..6\n";
+
+print "ok 1\n";
+
+if (sysopen(my $wo, "fcntl$$", O_WRONLY|O_CREAT)) {
+    print "ok 2\n";
+    if (syswrite($wo, "foo") == 3) {
+       print "ok 3\n";
+       close($wo);
+       if (sysopen(my $ro, "fcntl$$", O_RDONLY)) {
+           print "ok 4\n";
+           if (sysread($ro, my $read, 3)) {
+               print "ok 5\n";
+               if ($read eq "foo") {
+                   print "ok 6\n";
+               } else {
+                   print "not ok 6 # content '$read' not ok\n";
+               }
+           } else {
+               print "not ok 5 # sysread failed: $!\n";
+           }
+       } else {
+           print "not ok 4 # sysopen O_RDONLY failed: $!\n";
+       }
+       close($ro);
+    } else {
+       print "not ok 3 # syswrite failed: $!\n";
+    }
+    close($wo);
+} else {
+    print "not ok 2 # sysopen O_WRONLY failed: $!\n";
+}
+
+END {
+    1 while unlink "fcntl$$";
+}
+