1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-20 18:56:39 +02:00

tests: cp: ensure copy offload is not disabled for sparse files

Related to commits v9.1-109-g879d2180d and v9.7-248-g306de6c26

* tests/cp/sparse-perf.sh: This edge case was missed a couple of times,
so add a test to ensure we attempt copy offload.
This commit is contained in:
Pádraig Brady
2025-08-23 18:53:17 +01:00
parent 7d0d9658f9
commit 6c668dc133

View File

@@ -18,8 +18,27 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cp
cleanup_() { rm -rf "$other_partition_tmpdir"; }
. "$abs_srcdir/tests/other-fs-tmpdir"
# Create a sparse file on another partition to avoid reflinking
# thus exercising more copy logic
other_partition_sparse=$other_partition_tmpdir/k
printf x > $other_partition_sparse || framework_failure_
truncate -s1M $other_partition_sparse || framework_failure_
# cp should not disable anything by default, even for sparse files. For e.g.
# copy offload is an important performance improvement for sparse files on NFS.
cp --debug $other_partition_sparse k2 >cp.out || fail=1
cmp $other_partition_sparse k2 || fail=1
grep ': avoided' cp.out && { cat cp.out; fail=1; }
# Create a large-but-sparse file on the current partition.
# We disable relinking below, thus verifying SEEK_HOLE support
# Create a large-but-sparse file.
timeout 10 truncate -s1T f ||
skip_ "unable to create a 1 TiB sparse file"