1 # NOTE: this file tests how large files (>2GB) work with perlio (stdio/sfio).
2 # sysopen(), sysseek(), syswrite(), sysread() are tested in t/lib/syslfs.t.
3 # If you modify/add tests here, remember to update also t/lib/syslfs.t.
6 eval { my $q = pack "q", 0 };
8 print "1..0\n# no 64-bit types\n";
12 unshift @INC, '../lib';
21 # First try to figure out whether we have sparse files.
23 if ($^O eq 'win32' || $^O eq 'vms') {
24 print "1..0\n# no sparse files\n";
28 my ($SEEK_SET, $SEEK_CUR, $SEEK_END) = (0, 1, 2);
30 # We'll start off by creating a one megabyte file which has
31 # only three "true" bytes.
33 open(BIG, ">big") or do { warn "open failed: $!\n"; bye };
35 seek(BIG, 1_000_000, $SEEK_SET);
49 $s[11] * $s[12] < 1000_003) {
50 print "1..0\n# no sparse files?\n";
54 # By now we better be sure that we do have sparse files:
55 # if we are not, the following will hog 5 gigabytes of disk. Ooops.
59 open(BIG, ">big") or do { warn "open failed: $!\n"; bye };
61 seek(BIG, 5_000_000_000, $SEEK_SET);
69 print "not " unless $s[7] == 5_000_000_003;
72 print "not " unless -s "big" == 5_000_000_003;
75 open(BIG, "big") or do { warn "open failed: $!\n"; bye };
78 seek(BIG, 4_500_000_000, $SEEK_SET);
80 print "not " unless tell(BIG) == 4_500_000_000;
83 seek(BIG, 1, $SEEK_CUR);
85 print "not " unless tell(BIG) == 4_500_000_001;
88 seek(BIG, -1, $SEEK_CUR);
90 print "not " unless tell(BIG) == 4_500_000_000;
93 seek(BIG, -3, $SEEK_END);
95 print "not " unless tell(BIG) == 5_000_000_000;
100 print "not " unless read(BIG, $big, 3) == 3;
103 print "not " unless $big eq "big";