summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-01-21 09:24:12 (GMT)
committerGitHub <noreply@github.com>2019-01-21 09:24:12 (GMT)
commitb2385458ceddaf3d0d91456923716259d3915023 (patch)
tree9f654dd0a86e81b96f10d10eb1503271c4a9a771 /Lib/test/test_tarfile.py
parent222d303ade8aadf0adcae5190fac603bdcafe3f0 (diff)
downloadcpython-b2385458ceddaf3d0d91456923716259d3915023.zip
cpython-b2385458ceddaf3d0d91456923716259d3915023.tar.gz
cpython-b2385458ceddaf3d0d91456923716259d3915023.tar.bz2
bpo-35772: Fix test_tarfile on ppc64 (GH-11606)
Fix sparse file tests of test_tarfile on ppc64le with the tmpfs filesystem. Fix the function testing if the filesystem supports sparse files: create a file which contains data and "holes", instead of creating a file which contains no data. tmpfs effective block size is a page size (tmpfs lives in the page cache). RHEL uses 64 KiB pages on aarch64, ppc64 and ppc64le, only s390x and x86_64 use 4 KiB pages, whereas the test punch holes of 4 KiB. test.pythoninfo: Add resource.getpagesize().
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 7d2eec8..5e4d75e 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -973,16 +973,21 @@ class GNUReadTest(LongnameTest, ReadTest, unittest.TestCase):
def _fs_supports_holes():
# Return True if the platform knows the st_blocks stat attribute and
# uses st_blocks units of 512 bytes, and if the filesystem is able to
- # store holes in files.
+ # store holes of 4 KiB in files.
+ #
+ # The function returns False if page size is larger than 4 KiB.
+ # For example, ppc64 uses pages of 64 KiB.
if sys.platform.startswith("linux"):
# Linux evidentially has 512 byte st_blocks units.
name = os.path.join(TEMPDIR, "sparse-test")
with open(name, "wb") as fobj:
+ # Seek to "punch a hole" of 4 KiB
fobj.seek(4096)
+ fobj.write(b'x' * 4096)
fobj.truncate()
s = os.stat(name)
support.unlink(name)
- return s.st_blocks == 0
+ return (s.st_blocks * 512 < s.st_size)
else:
return False