1 # NOTE: this file tests how large files (>2GB) work with raw system IO.
2 # open(), tell(), seek(), print(), read() are tested in t/op/lfs.t.
3 # If you modify/add tests here, remember to update also t/op/lfs.t.
6 # Don't bother if there are no quads.
7 eval { my $q = pack "q", 0 };
9 print "1..0\n# no 64-bit types\n";
13 unshift @INC, '../lib';
14 require Fcntl; import Fcntl;
24 if ($^O eq 'win32' || $^O eq 'vms') {
25 print "1..0\n# no sparse files\n";
29 # Then try to deduce whether we have sparse files.
31 # We'll start off by creating a one megabyte file which has
32 # only three "true" bytes. If we have sparseness, we should
33 # consume less blocks than one megabyte (assuming nobody has
34 # one megabyte blocks...)
36 sysopen(BIG, "big", O_WRONLY|O_CREAT|O_TRUNC) or
37 do { warn "sysopen failed: $!\n"; bye };
38 sysseek(BIG, 1_000_000, SEEK_SET);
52 $s[11] * $s[12] < 1000_003) {
53 print "1..0\n# no sparse files?\n";
57 # By now we better be sure that we do have sparse files:
58 # if we are not, the following will hog 5 gigabytes of disk. Ooops.
64 sysopen(BIG, "big", O_WRONLY|O_CREAT|O_TRUNC) or
65 do { warn "sysopen failed: $!\n"; bye };
66 sysseek(BIG, 5_000_000_000, SEEK_SET);
79 fail unless $s[7] == 5_000_000_003;
82 fail unless -s "big" == 5_000_000_003;
85 sysopen(BIG, "big", O_RDONLY) or do { warn "sysopen failed: $!\n"; bye };
87 sysseek(BIG, 4_500_000_000, SEEK_SET);
89 fail unless sysseek(BIG, 0, SEEK_CUR) == 4_500_000_000;
92 sysseek(BIG, 1, SEEK_CUR);
94 fail unless sysseek(BIG, 0, SEEK_CUR) == 4_500_000_001;
97 sysseek(BIG, -1, SEEK_CUR);
99 fail unless sysseek(BIG, 0, SEEK_CUR) == 4_500_000_000;
102 sysseek(BIG, -3, SEEK_END);
104 fail unless sysseek(BIG, 0, SEEK_CUR) == 5_000_000_000;
109 fail unless sysread(BIG, $big, 3) == 3;
112 fail unless $big eq "big";
120 # If the lfs (large file support) tests fail, it means that
121 # the *file system* you are running the tests on doesn't support
122 # large files (files larger than two gigabytes). Perl may still
123 # be able to support such files, once you have such a file system.