From: Jarkko Hietaniemi Date: Mon, 21 May 2001 13:17:28 +0000 (+0000) Subject: Add a test of its very own for Fcntl. Hopefully portable. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a39702a6da8149b0e83e3e68ac9d18576a5199c1;p=p5sagit%2Fp5-mst-13.2.git Add a test of its very own for Fcntl. Hopefully portable. p4raw-id: //depot/perl@10175 --- diff --git a/MANIFEST b/MANIFEST index e6c5179..21792ab 100644 --- 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 index 0000000..24ade27 --- /dev/null +++ b/t/lib/fcntl.t @@ -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$$"; +} +