testsuite: relax sparse file SEEK_DATA check

On filesystems with large allocation units like tmpfs with hugepages,
SEEK_DATA can report an offset before the actual first non-zero byte.

The test already verifies file contents and checks st_blocks to confirm
the file is stored sparsely, so only require that the first data region
is not past the expected content.

Signed-off-by: Zhou Qiankang <wszqkzqk@qq.com>
This commit is contained in:
Zhou Qiankang 2026-07-02 23:45:32 +08:00
parent c944ace472
commit 3969aeac0b
No known key found for this signature in database
GPG key ID: F0647F18A79089C9

View file

@ -198,7 +198,9 @@ def test_sparse_file(archivers, request):
try:
if fd.seek(0, os.SEEK_HOLE) != 0:
sparse = False
if fd.seek(0, os.SEEK_DATA) != hole_size:
# FS allocation granularity may report DATA before the actual first
# non-zero byte, so only check it is not after the expected content.
if fd.seek(0, os.SEEK_DATA) > hole_size:
sparse = False
except OSError:
# OS/FS does not really support SEEK_HOLE/SEEK_DATA