diff --git a/tests/zfs-tests/include/math.shlib b/tests/zfs-tests/include/math.shlib index 692a2a45b..7ac59f279 100644 --- a/tests/zfs-tests/include/math.shlib +++ b/tests/zfs-tests/include/math.shlib @@ -30,14 +30,15 @@ function within_percent typeset percent=$3 # Set $a or $b to $2 such that a >= b - [[ '1' = $(echo "if ($2 > $a) 1" | bc) ]] && a=$2 || b=$2 + [[ '1' = $(echo "if ($2 > $a) 1 else 0" | bc) ]] && a=$2 || b=$2 # Prevent division by 0 [[ $a =~ [1-9] ]] || return 1 typeset p=$(echo "scale=2; $b * 100 / $a" | bc) log_note "Comparing $a and $b given $percent% (calculated: $p%)" - [[ '1' = $(echo "scale=2; if ($p >= $percent) 1" | bc) ]] && return 0 + [[ '1' = $(echo "scale=2; if ($p >= $percent) 1 else 0" | bc) ]] && \ + return 0 return 1 }