Skip to content

Commit 37b6be0

Browse files
miss-islingtonvstinner
authored andcommitted
00319: test_tarfile_ppc64
Fix sparse file tests of test_tarfile on ppc64le with the tmpfs filesystem. Upstream: https://bugs.python.org/issue35772 Co-authored-by: Victor Stinner <[email protected]>
1 parent d5c9687 commit 37b6be0

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Lib/test/pythoninfo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ def collect_resource(info_add):
515515
value = resource.getrlimit(key)
516516
info_add('resource.%s' % name, value)
517517

518+
call_func(info_add, 'resource.pagesize', resource, 'getpagesize')
519+
518520

519521
def collect_test_socket(info_add):
520522
try:

Lib/test/test_tarfile.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,16 +980,21 @@ def test_sparse_file_10(self):
980980
def _fs_supports_holes():
981981
# Return True if the platform knows the st_blocks stat attribute and
982982
# uses st_blocks units of 512 bytes, and if the filesystem is able to
983-
# store holes in files.
983+
# store holes of 4 KiB in files.
984+
#
985+
# The function returns False if page size is larger than 4 KiB.
986+
# For example, ppc64 uses pages of 64 KiB.
984987
if sys.platform.startswith("linux"):
985988
# Linux evidentially has 512 byte st_blocks units.
986989
name = os.path.join(TEMPDIR, "sparse-test")
987990
with open(name, "wb") as fobj:
991+
# Seek to "punch a hole" of 4 KiB
988992
fobj.seek(4096)
993+
fobj.write(b'x' * 4096)
989994
fobj.truncate()
990995
s = os.stat(name)
991996
support.unlink(name)
992-
return s.st_blocks == 0
997+
return (s.st_blocks * 512 < s.st_size)
993998
else:
994999
return False
9951000

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Fix sparse file tests of test_tarfile on ppc64 with the tmpfs filesystem. Fix
2+
the function testing if the filesystem supports sparse files: create a file
3+
which contains data and "holes", instead of creating a file which contains no
4+
data. tmpfs effective block size is a page size (tmpfs lives in the page cache).
5+
RHEL uses 64 KiB pages on aarch64, ppc64, ppc64le, only s390x and x86_64 use 4
6+
KiB pages, whereas the test punch holes of 4 KiB.

0 commit comments

Comments
 (0)