From d42f3a4d41034d099bf29ade22221b401528c060 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sat, 17 Mar 2012 17:04:21 +0100 Subject: 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. --- tests/dd/sparse | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests/dd/sparse') 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 -- cgit v1.2.3-54-g00ecf