[DTrace-devel] [PATCH v2 2/4] test: fix check_result.sh

Eugene Loh eugene.loh at oracle.com
Wed Nov 1 18:03:19 UTC 2023


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
I don't argue with the patch, but for my personal edification I'd like 
to understand the commit message better.  The pre-existing syntax seemed 
to have worked perfectly for me and I don't ever remember encountering 
the problem described.  Ah well.  The patch is fine regardless.

Also, s/shuold/should/.

On 11/1/23 11:31, Nick Alcock via DTrace-devel wrote:
> This checker (used in a number of tests) has a syntax error that
> causes it to spit things like
>
> test/utils/check_result.sh: line 14: 4 - : syntax error: operand expected (error token is "- ")
> test/utils/check_result.sh: line 15: 4 + : syntax error: operand expected (error token is "+ ")
>
> instead of actually checking for minima/maxima.
>
> The problem is that shell variables inside $((...)) shuold not be
> $-prepended: they undergo variable expansion anyway, and $-prepending them
> just causes them to undergo *another* round, which fails and expands to
> nothing, yielding the errors above.
>
> Fixed, fixing a number of tests (that is, causing them to emit errors
> appropriately, i.e. possibly fail where they weren't before).
>
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
> ---
>   test/utils/check_result.sh | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/test/utils/check_result.sh b/test/utils/check_result.sh
> index 9509512a5750b..25a877a44c89a 100755
> --- a/test/utils/check_result.sh
> +++ b/test/utils/check_result.sh
> @@ -11,11 +11,11 @@ margin=$3
>   
>   printf " check %10s;  against %10s;  margin %10s:  " $actual $expect $margin
>   
> -if [ $actual -lt $(($expect - $margin)) ]; then
> +if [ $actual -lt $((expect - margin)) ]; then
>   	echo ERROR too small
>   	exit 1
>   fi
> -if [ $actual -gt $(($expect + $margin)) ]; then
> +if [ $actual -gt $((expect + margin)) ]; then
>   	echo ERROR too large
>   	exit 1
>   fi



More information about the DTrace-devel mailing list