From 89c6e8c25bf01e21390dc67089f5de5822034fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 12 Apr 2023 14:37:00 +0100 Subject: [PATCH] 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. --- tests/cp/sparse-2.sh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tests/cp/sparse-2.sh b/tests/cp/sparse-2.sh index 3024055e6..9ae317492 100755 --- a/tests/cp/sparse-2.sh +++ b/tests/cp/sparse-2.sh @@ -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 || fail=1 Exit $fail -- 2.26.2