diff options
author | Pádraig Brady <P@draigBrady.com> | 2012-03-17 17:04:21 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2012-03-20 10:30:39 +0000 |
commit | d42f3a4d41034d099bf29ade22221b401528c060 (patch) | |
tree | 6e2de0f0609410d13c9f518ec37790c4c04670e1 | |
parent | eb7ef0148ad1e38b99191de7d28db84dd94f5c35 (diff) | |
download | coreutils-d42f3a4d41034d099bf29ade22221b401528c060.tar.xz |
tests: avoid spurious dd/sparse failure
* tests/dd/sparse: Allow for greater variation in sparse-block counts.
Reported by Nelson H. F. Beebe and Bruno Haible.
-rwxr-xr-x | tests/dd/sparse | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/dd/sparse b/tests/dd/sparse index 17aa94b8b..feb94471b 100755 --- a/tests/dd/sparse +++ b/tests/dd/sparse @@ -49,12 +49,18 @@ dd if=/dev/urandom of=file.in bs=1M count=1 conv=notrunc oflag=append # Note the block allocations below are usually equal, # but can vary by a file system block due to alignment, -# which was seen on XFS at least. +# which was seen on XFS at least. Also on various BSDs +# the sparse granularity was up to 8 file system blocks +# (16KiB for the tested systems), causing this to be the +# minimum accuracy we can support. alloc_equal() { - : ${sectors_per_block:=$(expr $(stat -f -c "%S" .) / 512)} + # 8 and 512 below are related, so hardcode sector_size for now + # : ${sector_size:=$(stat -c "%B" "$1")} + : ${sectors_per_block:=$(expr $(stat -f -c '%S' "$1") / 512)} + : ${min_sectors_per_sparse_block:=$(expr $sectors_per_block '*' 8)} alloc_diff=$(expr $(stat -c %b "$1") - $(stat -c %b "$2")) alloc_diff=$(echo $alloc_diff | tr -d -- -) # abs() - test $alloc_diff -le $sectors_per_block + test $alloc_diff -le $min_sectors_per_sparse_block } # Ensure NUL blocks smaller than the block size are not made sparse |