mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
tests: fix tests/cp/sparse-2.sh false failure on some systems
* tests/cp/sparse-2.sh: Double check cp --sparse=always, with dd conv=sparse, in the case where the former didn't create a sparse file. Now that this test is being newly run on macos, we're seeing a failure due to seek() not creating holes on apfs unless the size is >= 16MiB.
This commit is contained in:
1 parent
4eb2e9c11a
commit
6b499720fe
1 file changed
+10
-3
+10
-3
@@ -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
|
||||
print_ver_ cp stat dd
|
||||
|
||||
touch sparse_chk
|
||||
seek_data_capable_ sparse_chk \
|
||||
@@ -45,10 +45,17 @@ 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 starts off with size 256KiB,
|
||||
# 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 --sparse=always k k2 || fail=1
|
||||
test $(stat -c %b k2) -lt $(stat -c %b k) || 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
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user