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:
@@ -23,68 +23,68 @@ n=0
|
||||
|
||||
for conf in conf/good*.conf
|
||||
do
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking that $conf is accepted ($n)"
|
||||
ret=0
|
||||
$CHECKCONF "$conf" || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
done
|
||||
|
||||
for conf in conf/bad*.conf
|
||||
do
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking that $conf is rejected ($n)"
|
||||
ret=0
|
||||
$CHECKCONF "$conf" >/dev/null && ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
done
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "trying an axfr that should be denied (NOTAUTH) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp data.example. @10.53.0.2 axfr > dig.out.ns2.test$n || ret=1
|
||||
grep "; Transfer failed." dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "non recursive query for a static-stub zone with server name should be rejected ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp +norec data.example. @10.53.0.2 txt > dig.out.ns2.test$n \
|
||||
|| ret=1
|
||||
grep "REFUSED" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "non recursive query for a static-stub zone with server name should be rejected ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp +norec data.example.org. @10.53.0.2 txt > dig.out.ns2.test$n \
|
||||
|| ret=1
|
||||
grep "REFUSED" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "allow-query ACL ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp +norec data.example. @10.53.0.2 txt -b 10.53.0.7 \
|
||||
> dig.out.ns2.test$n || ret=1
|
||||
grep "REFUSED" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "look for static-stub zone data with recursion (should be found) ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp +noauth data.example. @10.53.0.2 txt > dig.out.ns2.test$n || ret=1
|
||||
digcomp knowngood.dig.out.rec dig.out.ns2.test$n || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking authoritative NS is ignored for delegation ($n)"
|
||||
ret=0
|
||||
# the auth server returns a different (and incorrect) NS for .example.
|
||||
@@ -94,9 +94,9 @@ grep "ns4.example." dig.out.ns2.test1.$n > /dev/null || ret=1
|
||||
$DIG $DIGOPTS +tcp data2.example. @10.53.0.2 txt > dig.out.ns2.test2.$n || ret=1
|
||||
grep "2nd test data" dig.out.ns2.test2.$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking queries for a child zone of the static-stub zone ($n)"
|
||||
ret=0
|
||||
# prime the delegation to a child zone of the static-stub zone
|
||||
@@ -120,9 +120,9 @@ copy_setports ns3/named.conf.in tmp
|
||||
sed 's/EXAMPLE_ZONE_PLACEHOLDER/zone "example" { type primary; file "example.db.signed"; };/' tmp > ns3/named.conf
|
||||
rndc_reload ns3 10.53.0.3
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking authoritative NS addresses are ignored for delegation ($n)"
|
||||
ret=0
|
||||
# the auth server returns a different (and incorrect) A/AAA RR for .example.
|
||||
@@ -137,29 +137,29 @@ rndc_reload ns2 10.53.0.2
|
||||
$DIG $DIGOPTS +tcp data3.example. @10.53.0.2 txt > dig.out.ns2.test3.$n || ret=1
|
||||
grep "3rd test data" dig.out.ns2.test3.$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
# the authoritative server of the query domain (example.com) is the apex
|
||||
# name of the static-stub zone (example). in this case the static-stub
|
||||
# configuration must be ignored and cached information must be used.
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking NS of static-stub is ignored when referenced from other domain ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp data.example.com. @10.53.0.2 txt > dig.out.ns2.test$n || ret=1
|
||||
grep "example com data" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
# check server-names
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking static-stub with a server-name ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp data.example.org. @10.53.0.2 txt > dig.out.ns2.test$n || ret=1
|
||||
grep "example org data" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
# Note: for a short term workaround we use ::1, assuming it's configured and
|
||||
# usable for our tests. We should eventually use the test ULA and available
|
||||
# checks introduced in change 2916.
|
||||
@@ -170,31 +170,31 @@ then
|
||||
$DIG $DIGOPTS +tcp data.example.info. @10.53.0.2 txt > dig.out.ns2.test$n || ret=1
|
||||
grep "example info data" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
else
|
||||
echo_i "SKIPPED: checking IPv6 static-stub address ($n)"
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "look for static-stub zone data with DNSSEC validation ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp +dnssec data4.example. @10.53.0.2 txt > dig.out.ns2.test$n || ret=1
|
||||
grep "ad; QUERY" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
grep "4th test data" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "look for a child of static-stub zone data with DNSSEC validation ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS +tcp +dnssec data3.sub.example. @10.53.0.2 txt > dig.out.ns2.test$n || ret=1
|
||||
grep "ad; QUERY" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
grep "3rd sub test data" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
# reload with a different name server: existing zone shouldn't be reused.
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking server reload with a different static-stub config ($n)"
|
||||
ret=0
|
||||
copy_setports ns2/named.conf.in tmp
|
||||
@@ -203,9 +203,9 @@ rndc_reload ns2 10.53.0.2
|
||||
$DIG $DIGOPTS +tcp data2.example.org. @10.53.0.2 txt > dig.out.ns2.test$n || ret=1
|
||||
grep "2nd example org data" dig.out.ns2.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
status=$((status + ret))
|
||||
|
||||
n=`expr $n + 1`
|
||||
n=$((n + 1))
|
||||
echo_i "checking static-stub of a undelegated tld resolves after DS query ($n)"
|
||||
ret=0
|
||||
$DIG $DIGOPTS undelegated. @10.53.0.2 ds > dig.out.ns2.ds.test$n
|
||||
@@ -213,7 +213,7 @@ $DIG $DIGOPTS undelegated. @10.53.0.2 soa > dig.out.ns2.soa.test$n
|
||||
grep "status: NXDOMAIN" dig.out.ns2.ds.test$n > /dev/null || ret=1
|
||||
grep "status: NOERROR" dig.out.ns2.soa.test$n > /dev/null || ret=1
|
||||
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