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:
@@ -22,7 +22,7 @@ status=0
|
||||
n=0
|
||||
|
||||
dotests() {
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with RT, single zone (+rec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +rec -t RT rt.rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -30,7 +30,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with RT, two zones (+rec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +rec -t RT rt.rt2.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -38,7 +38,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NAPTR, single zone (+rec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +rec -t NAPTR nap.naptr.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -46,7 +46,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NAPTR, two zones (+rec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +rec -t NAPTR nap.hang3b.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -54,7 +54,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with LP (+rec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +rec -t LP nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -84,7 +84,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NID (+rec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +rec -t NID ns1.nid.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -100,7 +100,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NID + LP (+rec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +rec -t NID nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -118,7 +118,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with RT, single zone (+norec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +norec -t RT rt.rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -126,7 +126,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with RT, two zones (+norec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +norec -t RT rt.rt2.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -134,7 +134,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NAPTR, single zone (+norec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +norec -t NAPTR nap.naptr.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -142,7 +142,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NAPTR, two zones (+norec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +norec -t NAPTR nap.hang3b.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -150,7 +150,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with LP (+norec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +norec -t LP nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -180,7 +180,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NID (+norec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +norec -t NID ns1.nid.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -196,7 +196,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NID + LP (+norec) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +norec -t NID nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -214,7 +214,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NS, root zone ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t NS . @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -224,7 +224,7 @@ dotests() {
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "test with NS, non-root zone ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t NS rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -259,7 +259,7 @@ echo_i "testing with 'minimal-responses no;'"
|
||||
minimal=no
|
||||
dotests
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing with 'minimal-any no;' ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t ANY www.rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -272,7 +272,7 @@ echo_i "reconfiguring server: minimal-any yes"
|
||||
copy_setports ns1/named3.conf.in ns1/named.conf
|
||||
rndc_reconfig ns1 10.53.0.1
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing with 'minimal-any yes;' over UDP ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t ANY +notcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -280,7 +280,7 @@ grep "ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1" dig.out.$n > /dev/null || ret=1
|
||||
if [ $ret -eq 1 ] ; then
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
|
||||
echo_i "testing with 'minimal-any yes;' over TCP ($n)"
|
||||
ret=0
|
||||
@@ -290,7 +290,7 @@ if [ $ret -eq 1 ] ; then
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing with 'minimal-any yes;' over UDP ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t ANY +notcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -311,7 +311,7 @@ echo_i "testing with 'minimal-responses no-auth-recursive;'"
|
||||
minimal=no-auth-recursive
|
||||
dotests
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing returning TLSA records with MX query ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t mx mx.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -322,7 +322,7 @@ if [ $ret -eq 1 ] ; then
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing returning TLSA records with SRV query ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t srv _xmpp-client._tcp.srv.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -337,7 +337,7 @@ echo_i "reconfiguring server: minimal-responses no"
|
||||
copy_setports ns1/named2.conf.in ns1/named.conf
|
||||
rndc_reconfig ns1 10.53.0.1
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing NS handling in ANY responses (authoritative) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t ANY rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -347,7 +347,7 @@ if [ $ret -eq 1 ] ; then
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing NS handling in ANY responses (recursive) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t ANY rt.example @10.53.0.3 > dig.out.$n || ret=1
|
||||
@@ -357,7 +357,7 @@ if [ $ret -eq 1 ] ; then
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing out-of-zone additional data from auth zones (authoritative) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t NS rt.example @10.53.0.1 > dig.out.$n || ret=1
|
||||
@@ -366,7 +366,7 @@ if [ $ret -eq 1 ] ; then
|
||||
echo_i "failed"; status=$((status+1))
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "testing out-of-zone additional data from auth zones (recursive) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS -t NS ex @10.53.0.3 > dig.out.$n || ret=1
|
||||
|
||||
Reference in New Issue
Block a user