summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2023-04-12 14:37:00 +0100
committerPádraig Brady <P@draigBrady.com>2023-04-13 20:19:18 +0100
commitdaa1e4f55702e03e9bcf06d2d0906652fb1619b0 (patch)
tree121fb194010cd67525d8826e25df5126c65ac375
parent854c90ecc031232a3bd6d94b149f84d5c2e1ab11 (diff)
downloadcoreutils-daa1e4f55702e03e9bcf06d2d0906652fb1619b0.tar.gz
tests: avoid dependence on file layout for cp sparse check
* tests/cp/sparse-2.sh: Don't depend on the copy taking <= allocation of the source. Instead leverage --debug to check that zero detection is being enabled.
-rwxr-xr-xtests/cp/sparse-2.sh18
1 files changed, 4 insertions, 14 deletions
diff --git a/tests/cp/sparse-2.sh b/tests/cp/sparse-2.sh
index 3024055e6..65607648a 100755
--- a/tests/cp/sparse-2.sh
+++ b/tests/cp/sparse-2.sh
@@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ cp stat dd
+print_ver_ cp dd
touch sparse_chk
seek_data_capable_ sparse_chk \
@@ -44,18 +44,8 @@ printf x > k || framework_failure_
dd bs=1k seek=1 of=k count=255 < /dev/zero || framework_failure_
# cp should detect the all-zero blocks and convert some of them to holes.
-# How many it detects/converts currently depends on io_blksize.
-# Currently, on my F14/ext4 desktop, this K file starts off with size 256KiB,
-# (note that the K in the preceding test starts off with size 4KiB).
-# cp from coreutils-8.9 with --sparse=always reduces the size to 32KiB.
-cp --reflink=never --sparse=always k k2 || fail=1
-if test $(stat -c %b k2) -ge $(stat -c %b k); then
- # If not sparse, then double check by creating with dd
- # as we're not guaranteed that seek will create a hole.
- # apfs on darwin 19.2.0 for example was seen to not to create holes < 16MiB.
- hole_size=$(stat -c %o k2) || framework_failure_
- dd if=k of=k2.dd bs=$hole_size conv=sparse || framework_failure_
- test $(stat -c %b k2) -eq $(stat -c %b k2.dd) || fail=1
-fi
+cp --debug --reflink=never --sparse=always k k2 >cp.out || fail=1
+cmp k k2 || fail=1
+grep 'sparse detection: .*zeros' cp.out || { cat cp.out; fail=1; }
Exit $fail