Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47f4034

Browse files
committed
Change the criteria for skipping the test.
If on Windows, we require the 'largefile' resource. If not on Windows, we use a test that actually writes a byte beyond the 2BG limit -- seeking alone is not sufficient, since on some systems (e.g. Linux with glibc 2.2) the sytem call interface supports large seek offsets but not all filesystem implementations do. Note that on Windows, we do not use the write test: on Win2K, that test can take a minute trying to zero all those blocks on disk, and on Windows our code always supports large seek offsets (but again, not all filesystems do). This may mean that on Win95, or on certain other backward filesystems, test_largefile will *fail*.
1 parent fda3058 commit 47f4034

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

Lib/test/test_largefile.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,6 @@
1111
import os, struct, stat, sys
1212

1313

14-
# only run if the current system support large files
15-
f = open(test_support.TESTFN, 'wb')
16-
try:
17-
# 2**31 == 2147483648
18-
f.seek(2147483649L)
19-
except (IOError, OverflowError):
20-
f.close()
21-
os.unlink(test_support.TESTFN)
22-
raise test_support.TestSkipped, \
23-
"platform does not have largefile support"
24-
else:
25-
f.close()
26-
27-
28-
# create >2GB file (2GB = 2147483648 bytes)
29-
size = 2500000000L
30-
name = test_support.TESTFN
31-
32-
3314
# On Windows this test comsumes large resources; It takes a long time to build
3415
# the >2GB file and takes >2GB of disk space therefore the resource must be
3516
# enabled to run this test. If not, nothing after this line stanza will be
@@ -38,6 +19,28 @@
3819
test_support.requires(
3920
'largefile',
4021
'test requires %s bytes and a long time to run' % str(size))
22+
else:
23+
# Only run if the current filesystem supports large files.
24+
# (Skip this test on Windows, since we now always support large files.)
25+
f = open(test_support.TESTFN, 'wb')
26+
try:
27+
# 2**31 == 2147483648
28+
f.seek(2147483649L)
29+
# Seeking is not enough of a test: you must write and flush, too!
30+
f.write("x")
31+
f.flush()
32+
except (IOError, OverflowError):
33+
f.close()
34+
os.unlink(test_support.TESTFN)
35+
raise test_support.TestSkipped, \
36+
"filesystem does not have largefile support"
37+
else:
38+
f.close()
39+
40+
41+
# create >2GB file (2GB = 2147483648 bytes)
42+
size = 2500000000L
43+
name = test_support.TESTFN
4144

4245

4346
def expect(got_this, expect_this):

0 commit comments

Comments
 (0)