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:
Tom Krizek
2023-06-08 15:34:30 +02:00
parent 01bc805f89
commit 4d42bdc245
49 changed files with 2041 additions and 2041 deletions

View File

@@ -38,35 +38,35 @@ rndc_stats() {
echo_i "fetching a.example from ns2's initial configuration ($n)"
$DIGCMD +noauth a.example. @10.53.0.2 any > dig.out.ns2.1 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "dumping initial stats for ns2 ($n)"
rndc_stats ns2 10.53.0.2 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "verifying adb records in named.stats ($n)"
grep "ADB stats" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
echo_i "checking for 1 entry in adb hash table in named.stats ($n)"
grep "1 Addresses in hash table" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "verifying cache statistics in named.stats ($n)"
grep "Cache Statistics" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "checking for 2 entries in adb hash table in named.stats ($n)"
@@ -74,8 +74,8 @@ $DIGCMD a.example.info. @10.53.0.2 any > /dev/null 2>&1
rndc_stats ns2 10.53.0.2 || ret=1
grep "2 Addresses in hash table" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "dumping initial stats for ns3 ($n)"
@@ -83,8 +83,8 @@ rndc_stats ns3 10.53.0.3 || ret=1
nsock0nstat=`grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}'`
[ 0 -ne ${nsock0nstat:-0} ] || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
echo_i "sending queries to ns3"
$DIGCMD +tries=2 +time=1 +recurse @10.53.0.3 foo.info. any > /dev/null 2>&1
@@ -97,30 +97,30 @@ getstats() {
}
retry_quiet 5 getstats || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "verifying recursing clients output in named.stats ($n)"
grep "2 recursing clients" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "verifying active fetches output in named.stats ($n)"
grep "1 active fetches" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "verifying active sockets output in named.stats ($n)"
nsock1nstat=`grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}'`
[ `expr ${nsock1nstat:-0} - ${nsock0nstat:-0}` -eq 1 ] || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
# there should be 1 UDP and no TCP queries. As the TCP counter is zero
# no status line is emitted.
@@ -129,22 +129,22 @@ echo_i "verifying queries in progress in named.stats ($n)"
grep "1 UDP queries in progress" $last_stats > /dev/null || ret=1
grep "TCP queries in progress" $last_stats > /dev/null && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "verifying bucket size output ($n)"
grep "bucket size" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "checking priming queries are counted ($n)"
grep "priming queries" $last_stats > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "checking that zones with slash are properly shown in XML output ($n)"
@@ -155,8 +155,8 @@ else
echo_i "skipping test as libxml2 and/or curl was not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "checking that zones return their type ($n)"
@@ -167,8 +167,8 @@ else
echo_i "skipping test as libxml2 and/or curl was not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "checking bind9.xsl vs xml ($n)"
@@ -223,8 +223,8 @@ else
echo_i "skipping test as libxml2 and/or curl with HTTP/1.1 support and/or xsltproc was not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "checking bind9.xml socket statistics ($n)"
@@ -247,8 +247,8 @@ else
echo_i "skipping test as libxml2 and/or stats.xml.out file and/or xsltproc was not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
echo_i "Check that 'zone-statistics full;' is processed by 'rndc reconfig' ($n)"
ret=0
@@ -271,8 +271,8 @@ rndc_reconfig ns2 10.53.0.2
rndc_stats ns2 10.53.0.2 || ret=1
sed -n '/Per Zone Query Statistics/,/^++/p' $last_stats | grep -F '[example]' > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
status=$((status + ret))
n=$((n + 1))
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1