]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: cp: ensure copy offload is not disabled for sparse files
authorPádraig Brady <P@draigBrady.com>
Sat, 23 Aug 2025 17:53:17 +0000 (18:53 +0100)
committerPádraig Brady <P@draigBrady.com>
Sat, 23 Aug 2025 17:55:46 +0000 (18:55 +0100)
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.

tests/cp/sparse-perf.sh

index 8f737f798d26c3fcfa51b7d92644230ef1ebcdaa..5a283c1fe65816a36342d9f583c1ed787947bf10 100755 (executable)
 
 . "${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"