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 eval { my $q = pack "q", 0 };
8 print "1..0\n# no 64-bit types\n";
12 unshift @INC, '../lib';
13 require Fcntl; import Fcntl;
22 # First try to figure out whether we have sparse files.
24 if ($^O eq 'win32' || $^O eq 'vms') {
25 print "1..0\n# no sparse files\n";
29 # We'll start off by creating a one megabyte file which has
30 # only three "true" bytes.
32 sysopen(BIG, "big", O_WRONLY|O_CREAT|O_TRUNC) or
33 do { warn "sysopen failed: $!\n"; bye };
34 sysseek(BIG, 1_000_000, SEEK_SET);
48 $s[11] * $s[12] < 1000_003) {
49 print "1..0\n# no sparse files?\n";
53 # By now we better be sure that we do have sparse files:
54 # if we are not, the following will hog 5 gigabytes of disk. Ooops.
58 sysopen(BIG, "big", O_WRONLY|O_CREAT|O_TRUNC) or
59 do { warn "sysopen failed: $!\n"; bye };
60 sysseek(BIG, 5_000_000_000, SEEK_SET);
68 print "not " unless $s[7] == 5_000_000_003;
71 print "not " unless -s "big" == 5_000_000_003;
74 sysopen(BIG, "big", O_RDONLY) or do { warn "sysopen failed: $!\n"; bye };
76 sysseek(BIG, 4_500_000_000, SEEK_SET);
78 print "not " unless sysseek(BIG, 0, SEEK_CUR) == 4_500_000_000;
81 sysseek(BIG, 1, SEEK_CUR);
83 print "not " unless sysseek(BIG, 0, SEEK_CUR) == 4_500_000_001;
86 sysseek(BIG, -1, SEEK_CUR);
88 print "not " unless sysseek(BIG, 0, SEEK_CUR) == 4_500_000_000;
91 sysseek(BIG, -3, SEEK_END);
93 print "not " unless sysseek(BIG, 0, SEEK_CUR) == 5_000_000_000;
98 print "not " unless sysread(BIG, $big, 3) == 3;
101 print "not " unless $big eq "big";