X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Flfs.t;h=feee8cc9b3fb133849233e6f96bee7a9655d067b;hb=20822f61cc01ab34be1e17db483aceb9d5ec8fb7;hp=0d6d02774304b0abd55374a3e95e2abd8221da26;hpb=1d7c184104c076988718a01b77c8706aae05b092;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/lfs.t b/t/op/lfs.t index 0d6d027..feee8cc 100644 --- a/t/op/lfs.t +++ b/t/op/lfs.t @@ -4,18 +4,24 @@ BEGIN { chdir 't' if -d 't'; - unshift @INC, '../lib'; + @INC = '../lib'; # Don't bother if there are no quad offsets. require Config; import Config; if ($Config{lseeksize} < 8) { - print "1..0\n# no 64-bit file offsets\n"; + print "1..0 # Skip: no 64-bit file offsets\n"; exit(0); } } -sub bye { +sub zap { close(BIG); - unlink "big"; + unlink("big"); + unlink("big1"); + unlink("big2"); +} + +sub bye { + zap(); exit(0); } @@ -40,14 +46,14 @@ print "# checking whether we have sparse files...\n"; # Known have-nots. if ($^O eq 'win32' || $^O eq 'vms') { - print "1..0\n# no sparse files (because this is $^O) \n"; + print "1..0 # Skip: no sparse files (because this is $^O) \n"; bye(); } # 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\n# large files known to work but unable to test them here ($^O)\n"; + print "1..0 # Skip: large files known to work but unable to test them here ($^O)\n"; bye(); } @@ -62,39 +68,64 @@ my ($SEEK_SET, $SEEK_CUR, $SEEK_END) = (0, 1, 2); # consume less blocks than one megabyte (assuming nobody has # one megabyte blocks...) -open(BIG, ">big") or do { warn "open failed: $!\n"; bye }; -binmode BIG; -seek(BIG, 1_000_000, $SEEK_SET); -print BIG "big"; -close(BIG); - -my @s; - -@s = stat("big"); - -print "# @s\n"; - -my $BLOCKSIZE = $s[11] || 512; - -unless (@s == 13 && - $s[7] == 1_000_003 && - defined $s[12] && - $BLOCKSIZE * $s[12] < 1_000_003) { - print "1..0\n# no sparse files?\n"; - bye(); +open(BIG, ">big1") or + do { warn "open big1 failed: $!\n"; bye }; +binmode(BIG) or + do { warn "binmode big1 failed: $!\n"; bye }; +seek(BIG, 1_000_000, $SEEK_SET) or + do { warn "seek big1 failed: $!\n"; bye }; +print BIG "big" or + do { warn "print big1 failed: $!\n"; bye }; +close(BIG) or + do { warn "close big1 failed: $!\n"; bye }; + +my @s1 = stat("big1"); + +print "# s1 = @s1\n"; + +open(BIG, ">big2") or + do { warn "open big2 failed: $!\n"; bye }; +binmode(BIG) or + do { warn "binmode big2 failed: $!\n"; bye }; +seek(BIG, 2_000_000, $SEEK_SET) or + do { warn "seek big2 failed; $!\n"; bye }; +print BIG "big" or + do { warn "print big2 failed; $!\n"; bye }; +close(BIG) or + do { warn "close big2 failed; $!\n"; bye }; + +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]) { + print "1..0 # Skip: no sparse files?\n"; + bye; } print "# we seem to have sparse files...\n"; # By now we better be sure that we do have sparse files: # if we are not, the following will hog 5 gigabytes of disk. Ooops. +# This may fail by producing some signal; run in a subprocess first for safety $ENV{LC_ALL} = "C"; +my $r = system '../perl', '-e', <<'EOF'; +open(BIG, ">big"); +seek(BIG, 5_000_000_000, 0); +print BIG "big"; +exit 0; +EOF + open(BIG, ">big") or do { warn "open failed: $!\n"; bye }; binmode BIG; -unless (seek(BIG, 5_000_000_000, $SEEK_SET)) { - print "1..0\n# seeking past 2GB failed: $!\n"; +if ($r or not seek(BIG, 5_000_000_000, $SEEK_SET)) { + my $err = $r ? 'signal '.($r & 0x7f) : $!; + print "1..0 # Skip: seeking past 2GB failed: $err\n"; explain(); bye(); } @@ -107,9 +138,9 @@ my $close = close BIG; print "# close failed: $!\n" unless $close; unless ($print && $close) { if ($! =~/too large/i) { - print "1..0\n# writing past 2GB failed: process limits?\n"; + print "1..0 # Skip: writing past 2GB failed: process limits?\n"; } elsif ($! =~ /quota/i) { - print "1..0\n# filesystem quota limits?\n"; + print "1..0 # Skip: filesystem quota limits?\n"; } explain(); bye(); @@ -120,7 +151,7 @@ unless ($print && $close) { print "# @s\n"; unless ($s[7] == 5_000_000_003) { - print "1..0\n# not configured to use large files?\n"; + print "1..0 # Skip: not configured to use large files?\n"; explain(); bye(); }