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

Nick Alcock nick.alcock at oracle.com
Wed Nov 1 15:31:04 UTC 2023


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
-- 
2.42.0.271.g85384428f1




More information about the DTrace-devel mailing list