Remove duplicate entries from MANIFEST
[p5sagit/p5-mst-13.2.git] / t / op / lfs.t
index 0ae3182..df9323f 100644 (file)
@@ -1,6 +1,6 @@
 # NOTE: this file tests how large files (>2GB) work with perlio (stdio/sfio).
 # sysopen(), sysseek(), syswrite(), sysread() are tested in t/lib/syslfs.t.
-# If you modify/add tests here, remember to update also t/lib/syslfs.t.
+# If you modify/add tests here, remember to update also ext/Fcntl/t/syslfs.t.
 
 BEGIN {
        chdir 't' if -d 't';
@@ -11,17 +11,20 @@ BEGIN {
                print "1..0 # Skip: no 64-bit file offsets\n";
                exit(0);
        }
+       require './test.pl';
 }
 
 use strict;
+
 our @s;
 our $fail;
 
+my $big0 = tempfile();
+my $big1 = tempfile();
+my $big2 = tempfile();
+
 sub zap {
     close(BIG);
-    unlink("big");
-    unlink("big1");
-    unlink("big2");
 }
 
 sub bye {
@@ -53,10 +56,12 @@ EOM
     print "1..0 # Skip: @_\n" if @_;
 }
 
+$| = 1;
+
 print "# checking whether we have sparse files...\n";
 
 # Known have-nots.
-if ($^O eq 'MSWin32' || $^O eq 'VMS') {
+if ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') {
     print "1..0 # Skip: no sparse files in $^O\n";
     bye();
 }
@@ -64,7 +69,7 @@ if ($^O eq 'MSWin32' || $^O eq 'VMS') {
 # Known haves that have problems running this test
 # (for example because they do not support sparse files, like UNICOS)
 if ($^O eq 'unicos') {
-    print "1..0 # Skip: no sparse files in $^0, unable to test large files\n";
+    print "1..0 # Skip: no sparse files in $^O, unable to test large files\n";
     bye();
 }
 
@@ -79,40 +84,41 @@ my ($SEEK_SET, $SEEK_CUR, $SEEK_END) = (0, 1, 2);
 # consume less blocks than one megabyte (assuming nobody has
 # one megabyte blocks...)
 
-open(BIG, ">big1") or
-    do { warn "open big1 failed: $!\n"; bye };
+open(BIG, ">$big1") or
+    do { warn "open $big1 failed: $!\n"; bye };
 binmode(BIG) or
-    do { warn "binmode big1 failed: $!\n"; bye };
+    do { warn "binmode $big1 failed: $!\n"; bye };
 seek(BIG, 1_000_000, $SEEK_SET) or
-    do { warn "seek big1 failed: $!\n"; bye };
+    do { warn "seek $big1 failed: $!\n"; bye };
 print BIG "big" or
-    do { warn "print big1 failed: $!\n"; bye };
+    do { warn "print $big1 failed: $!\n"; bye };
 close(BIG) or
-    do { warn "close big1 failed: $!\n"; bye };
+    do { warn "close $big1 failed: $!\n"; bye };
 
-my @s1 = stat("big1");
+my @s1 = stat($big1);
 
 print "# s1 = @s1\n";
 
-open(BIG, ">big2") or
-    do { warn "open big2 failed: $!\n"; bye };
+open(BIG, ">$big2") or
+    do { warn "open $big2 failed: $!\n"; bye };
 binmode(BIG) or
-    do { warn "binmode big2 failed: $!\n"; bye };
+    do { warn "binmode $big2 failed: $!\n"; bye };
 seek(BIG, 2_000_000, $SEEK_SET) or
-    do { warn "seek big2 failed; $!\n"; bye };
+    do { warn "seek $big2 failed; $!\n"; bye };
 print BIG "big" or
-    do { warn "print big2 failed; $!\n"; bye };
+    do { warn "print $big2 failed; $!\n"; bye };
 close(BIG) or
-    do { warn "close big2 failed; $!\n"; bye };
+    do { warn "close $big2 failed; $!\n"; bye };
 
-my @s2 = stat("big2");
+my @s2 = stat($big2);
 
 print "# s2 = @s2\n";
 
 zap();
 
 unless ($s1[7] == 1_000_003 && $s2[7] == 2_000_003 &&
-       $s1[11] == $s2[11] && $s1[12] == $s2[12]) {
+       $s1[11] == $s2[11] && $s1[12] == $s2[12] &&
+       $s1[12] > 0) {
        print "1..0 # Skip: no sparse files?\n";
        bye;
 }
@@ -126,13 +132,13 @@ print "# we seem to have sparse files...\n";
 $ENV{LC_ALL} = "C";
 
 my $r = system '../perl', '-e', <<'EOF';
-open(BIG, ">big");
+open(BIG, ">$big0");
 seek(BIG, 5_000_000_000, 0);
-print BIG "big";
+print BIG $big0;
 exit 0;
 EOF
 
-open(BIG, ">big") or do { warn "open failed: $!\n"; bye };
+open(BIG, ">$big0") or do { warn "open failed: $!\n"; bye };
 binmode BIG;
 if ($r or not seek(BIG, 5_000_000_000, $SEEK_SET)) {
     my $err = $r ? 'signal '.($r & 0x7f) : $!;
@@ -157,7 +163,7 @@ unless ($print && $close) {
     bye();
 }
 
-@s = stat("big");
+@s = stat($big0);
 
 print "# @s\n";
 
@@ -166,7 +172,7 @@ unless ($s[7] == 5_000_000_003) {
     bye();
 }
 
-sub fail () {
+sub fail {
     print "not ";
     $fail++;
 }
@@ -176,13 +182,12 @@ sub offset ($$) {
     my $offset_is = eval $offset_will_be;
     unless ($offset_is == $offset_want) {
         print "# bad offset $offset_is, want $offset_want\n";
+       my ($offset_func) = ($offset_will_be =~ /^(\w+)/);
        if (unpack("L", pack("L", $offset_want)) == $offset_is) {
-           my($offset_func) = ($offset_will_be =~ /^(\w+)/);
            print "# 32-bit wraparound suspected in $offset_func() since\n";
-           print "# $offset_want cast into 32 bits is $offset_is.\n";
+           print "# $offset_want cast into 32 bits equals $offset_is.\n";
        } elsif ($offset_want - unpack("L", pack("L", $offset_want)) - 1
-                == $offset_is){
-           my($offset_func) = ($offset_will_be =~ /^(\w+)/);
+                == $offset_is) {
            print "# 32-bit wraparound suspected in $offset_func() since\n";
            printf "# %s - unpack('L', pack('L', %s)) - 1 equals %s.\n",
                $offset_want,
@@ -195,21 +200,21 @@ sub offset ($$) {
 
 print "1..17\n";
 
-my $fail = 0;
+$fail = 0;
 
 fail unless $s[7] == 5_000_000_003;    # exercizes pp_stat
 print "ok 1\n";
 
-fail unless -s "big" == 5_000_000_003; # exercizes pp_ftsize
+fail unless -s $big0 == 5_000_000_003; # exercizes pp_ftsize
 print "ok 2\n";
 
-fail unless -e "big";
+fail unless -e $big0;
 print "ok 3\n";
 
-fail unless -f "big";
+fail unless -f $big0;
 print "ok 4\n";
 
-open(BIG, "big") or do { warn "open failed: $!\n"; bye };
+open(BIG, $big0) or do { warn "open failed: $!\n"; bye };
 binmode BIG;
 
 fail unless seek(BIG, 4_500_000_000, $SEEK_SET);
@@ -266,7 +271,10 @@ explain() if $fail;
 bye(); # does the necessary cleanup
 
 END {
-   unlink "big"; # be paranoid about leaving 5 gig files lying around
+    # unlink may fail if applied directly to a large file
+    # be paranoid about leaving 5 gig files lying around
+    open(BIG, ">$big0"); # truncate
+    close(BIG);
 }
 
 # eof