Use arithmetic expansion in system tests
Change the way arithmetic operations are performed in system test shell scripts from using `expr` to `$(())`. This ensures that updating the variable won't end up with a non-zero exit code, which would case the script to exit prematurely when `set -e` is in effect. The following replacements were performed using sed in all text files (git grep -Il '' | xargs sed -i): s/status=`expr $status + $ret`/status=$((status + ret))/g s/n=`expr $n + 1`/n=$((n + 1))/g s/t=`expr $t + 1`/t=$((t + 1))/g s/status=`expr $status + 1`/status=$((status + 1))/g s/try=`expr $try + 1`/try=$((try + 1))/g
This commit is contained in:
@@ -24,13 +24,13 @@ status=0
|
||||
echo_i "checking that we detect a NS which refers to a CNAME"
|
||||
if $CHECKZONE . cname.db > cname.out 2>&1
|
||||
then
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
else
|
||||
if grep "is a CNAME" cname.out > /dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -38,13 +38,13 @@ fi
|
||||
echo_i "checking that we detect a NS which is below a DNAME"
|
||||
if $CHECKZONE . dname.db > dname.out 2>&1
|
||||
then
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
else
|
||||
if grep "is below a DNAME" dname.out > /dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -52,13 +52,13 @@ fi
|
||||
echo_i "checking that we detect a NS which has no address records (A/AAAA)"
|
||||
if $CHECKZONE . noaddress.db > noaddress.out
|
||||
then
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
else
|
||||
if grep "has no address records" noaddress.out > /dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -66,13 +66,13 @@ fi
|
||||
echo_i "checking that we detect a NS which has no records"
|
||||
if $CHECKZONE . nxdomain.db > nxdomain.out
|
||||
then
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
else
|
||||
if grep "has no address records" noaddress.out > /dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -80,13 +80,13 @@ fi
|
||||
echo_i "checking that we detect a NS which looks like a A record (fail)"
|
||||
if $CHECKZONE -n fail . a.db > a.out 2>&1
|
||||
then
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
else
|
||||
if grep "appears to be an address" a.out > /dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -98,10 +98,10 @@ then
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
else
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -110,25 +110,25 @@ if $CHECKZONE -n ignore . a.db > a.out 2>&1
|
||||
then
|
||||
if grep "appears to be an address" a.out > /dev/null
|
||||
then
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
else
|
||||
:
|
||||
fi
|
||||
else
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
fi
|
||||
|
||||
#
|
||||
echo_i "checking that we detect a NS which looks like a AAAA record (fail)"
|
||||
if $CHECKZONE -n fail . aaaa.db > aaaa.out 2>&1
|
||||
then
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
else
|
||||
if grep "appears to be an address" aaaa.out > /dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -140,10 +140,10 @@ then
|
||||
then
|
||||
:
|
||||
else
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
fi
|
||||
else
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -152,12 +152,12 @@ if $CHECKZONE -n ignore . aaaa.db > aaaa.out 2>&1
|
||||
then
|
||||
if grep "appears to be an address" aaaa.out > /dev/null
|
||||
then
|
||||
echo_i "failed (message)"; status=`expr $status + 1`
|
||||
echo_i "failed (message)"; status=$((status + 1))
|
||||
else
|
||||
:
|
||||
fi
|
||||
else
|
||||
echo_i "failed (status)"; status=`expr $status + 1`
|
||||
echo_i "failed (status)"; status=$((status + 1))
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -234,7 +234,7 @@ $RNDCCMD 10.53.0.1 zonestatus reload.example > rndc.out.removeinclude 2>&1
|
||||
checkfor "files: reload.db$" rndc.out.removeinclude
|
||||
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
echo_i "checking 'rdnc zonestatus' with duplicated zone name"
|
||||
ret=0
|
||||
@@ -245,14 +245,14 @@ checkfor "name: duplicate.example" rndc.out.duplicate
|
||||
$RNDCCMD 10.53.0.1 zonestatus nosuchzone.example > rndc.out.duplicate 2>&1
|
||||
checkfor "no matching zone 'nosuchzone.example' in any view" rndc.out.duplicate
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
echo_i "checking 'rdnc zonestatus' with big serial value"
|
||||
ret=0
|
||||
$RNDCCMD 10.53.0.1 zonestatus bigserial.example > rndc.out.bigserial 2>&1
|
||||
checkfor "serial: 3003113544" rndc.out.bigserial
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
echo_i "exit status: $status"
|
||||
[ $status -eq 0 ] || exit 1
|
||||
|
||||
Reference in New Issue
Block a user