]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use arithmetic expansion in system tests (followup)
authorTom Krizek <tkrizek@isc.org>
Thu, 22 Jun 2023 12:09:22 +0000 (14:09 +0200)
committerTom Krizek <tkrizek@isc.org>
Fri, 14 Jul 2023 13:49:15 +0000 (15:49 +0200)
These are manual edits in addition of the automated changes from the
previous commit.

16 files changed:
bin/tests/system/builtin/tests.sh
bin/tests/system/dupsigs/ns1/reset_keys.sh
bin/tests/system/names/tests.sh
bin/tests/system/nsupdate/krb/setup.sh
bin/tests/system/reclimit/tests.sh
bin/tests/system/redirect/tests.sh
bin/tests/system/rpz/clean.sh
bin/tests/system/rpz/tests.sh
bin/tests/system/rpzrecurse/setup.sh
bin/tests/system/rpzrecurse/tests.sh
bin/tests/system/rrl/tests.sh
bin/tests/system/serve-stale/tests.sh
bin/tests/system/statistics/tests.sh
bin/tests/system/upforwd/tests.sh
bin/tests/system/wildcard/tests.sh
bin/tests/system/xferquota/tests.sh

index 76851774718aa7bbd74fada58d584db58ed6d4cb..49e1c4575074bc9ebe4ce40ed82597afd4c7f557 100644 (file)
@@ -132,7 +132,7 @@ do
                echo_i "failed (empty zone $zone missing)"
                ret=1
        }
-       count=`expr $count + 1`
+       count=$((count + 1))
 done
 lines=`grep "automatic empty zone: " ns1/named.run | wc -l`
 test $count -eq $lines -a $count -eq 99 || {
index cc9bef78f543feaaa222f149371279fc0597e50a..9f23d10c709cfec50e3df7ea3accf7800cda869d 100644 (file)
@@ -52,14 +52,14 @@ $SETTIME -P $BASET -A $BASET $KEYDIR/$KSK
 $SETTIME -P $BASET -A $BASET $KEYDIR/$ZSK0
 
 # schedule the first roll
-R1=`expr $BASE + 50`
+R1=$((BASE + 50))
 R1T=`timetodnssec $R1`
 
 $SETTIME -I $R1T $KEYDIR/$ZSK0
 $SETTIME -P $BASET -A $R1T $KEYDIR/$ZSK1
 
 # schedule the second roll (which includes the delete of the first key)
-R2=`expr $R1 + 50`
+R2=$((R1 + 50))
 R2T=`timetodnssec $R2`
 DT=$R2
 DTT=`timetodnssec $DT`
@@ -69,7 +69,7 @@ $SETTIME -I $R2T $KEYDIR/$ZSK1
 $SETTIME -P $R1T -A $R2T $KEYDIR/$ZSK2
 
 # schedule the third roll
-R3=`expr $R2 + 25`
+R3=$((R2 + 25))
 R3T=`timetodnssec $R3`
 
 $SETTIME -D $R3T $KEYDIR/$ZSK1
@@ -91,7 +91,7 @@ exit
 # this isn't long enough for the signing to complete and would result in
 # duplicate signatures, see
 # https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/231#note_9597
-R4=`expr $R3 + 10`
+R4=$((R3 + 10))
 R4T=`timetodnssec $R4`
 
 $SETTIME -D $R4T $KEYDIR/$ZSK2
index 1d1b26ac99114e8863059ef36a4bf8bc095efa0c..1d6f63084734b38aaef9841f7bad89846a122d0e 100644 (file)
@@ -39,7 +39,7 @@ status=$((status + ret))
 
 echo_i "Checking if message with compression disabled is significantly larger"
 echo_i "Disabled $COMPDIS vs enabled $COMPEN"
-val=`expr \( $COMPDIS \* 3 / 2 \) / $COMPEN`
+val=$(( (COMPDIS * 3 / 2) / COMPEN))
 if [ $val -le 1 ]; then
        echo_i "failed"
        status=$((status + 1))
index 5ac116c41d2e5f21a378f6b2380ad4e4ed73f1f7..a1b3ee6771f1fdee1f70b273348ba3d07e9e85f7 100644 (file)
@@ -22,8 +22,8 @@ KRB5_KDC_PROFILE=${PWD}/krb5kdc
 export KRB5_KDC_PROFILE
 
 now=`date +%s`
-lifetime=`expr 2147483647 - $now`
-lifetime=`expr $lifetime / 3600 / 24 - 30`
+lifetime=$((2147483647 - now))
+lifetime=$((lifetime / 3600 / 24 - 30))
 
 cat << EOF > "${KRB5_CONFIG}"
 [libdefaults]
index a707063a56dd904cff77cb879315e6afba6fe67a..8fdb637503fd037b0db3aa6ee13db730fc5d5a80 100644 (file)
@@ -42,7 +42,7 @@ ns3_sends_aaaa_queries() {
 check_query_count() {
        count1=`sed 's/[^0-9]//g;' $1`
        count2=`sed 's/[^0-9]//g;' $2`
-       count=`expr $count1 + $count2`
+       count=$((count1 + count2))
        #echo_i "count1=$count1 count2=$count2 count=$count"
        expected_count_with_aaaa=$3
        expected_count_without_aaaa=$4
index 9bfb110842ca7e37cbb089975b53cedc3a118f00..82d413fd0fda19c7fe8d361bc4745b536069f1f6 100644 (file)
@@ -61,7 +61,7 @@ $DIG $DIGOPTS nonexist. @10.53.0.2 -b 10.53.0.2 a > dig.out.ns2.test$n || ret=1
 rm ns2/named.stats 2>/dev/null
 $RNDCCMD 10.53.0.2 stats || ret=1
 POST=`sed -n -e "s/[    ]*\([0-9]*\).queries resulted in NXDOMAIN that were redirected$/\1/p" ns2/named.stats`
-if [ `expr $POST - $PRE` != 1 ]; then ret=1; fi
+if [ $((POST - PRE)) != 1 ]; then ret=1; fi
 n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
@@ -401,8 +401,8 @@ rm ns4/named.stats 2>/dev/null
 $RNDCCMD 10.53.0.4 stats || ret=1
 POST_RED=`sed -n -e "s/[    ]*\([0-9]*\).queries resulted in NXDOMAIN that were redirected$/\1/p" ns4/named.stats`
 POST_SUC=`sed -n -e "s/[    ]*\([0-9]*\).queries resulted in NXDOMAIN that were redirected and resulted in a successful remote lookup$/\1/p" ns4/named.stats`
-if [ `expr $POST_RED - $PRE_RED` != 1 ]; then ret=1; fi
-if [ `expr $POST_SUC - $PRE_SUC` != 1 ]; then ret=1; fi
+if [ $((POST_RED - PRE_RED)) != 1 ]; then ret=1; fi
+if [ $((POST_SUC - PRE_SUC)) != 1 ]; then ret=1; fi
 n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
index 218df9336da3eec5b249a92e2918e8c9e50efcf6..d16b6e966482dcd9421f3314ca2921b710a1e7cf 100644 (file)
@@ -22,7 +22,7 @@ while getopts "Px" c; do
        *) echo "$USAGE" 1>&2; exit 1;;
     esac
 done
-shift `expr $OPTIND - 1 || true`
+shift $((OPTIND - 1))
 if test "$#" -ne 0; then
     echo "$USAGE" 1>&2
     exit 1
index fa8a120b6342f58f55470934338dbafedaab25bd..8ff880b40fa7423229ac7d3375f409eedeec6dd0 100644 (file)
@@ -50,7 +50,7 @@ while getopts "xS:" c; do
        *) echo "$USAGE" 1>&2; exit 1;;
     esac
 done
-shift `expr $OPTIND - 1 || true`
+shift $((OPTIND - 1))
 if test "$#" -ne 0; then
     echo "$USAGE" 1>&2
     exit 1
@@ -265,7 +265,7 @@ ckstats () {
     NEW_CNT=0`sed -n -e 's/[    ]*\([0-9]*\).response policy.*/\1/p'  \
                    $NSDIR/named.stats | tail -1`
     eval "OLD_CNT=0\$${NSDIR}_CNT"
-    GOT=`expr $NEW_CNT - $OLD_CNT`
+    GOT=$((NEW_CNT - OLD_CNT))
     if test "$GOT" -ne "$EXPECTED"; then
        setret "wrong $LABEL $NSDIR statistics of $GOT instead of $EXPECTED"
     fi
@@ -282,7 +282,7 @@ ckstatsrange () {
     NEW_CNT=0`sed -n -e 's/[    ]*\([0-9]*\).response policy.*/\1/p'  \
                    $NSDIR/named.stats | tail -1`
     eval "OLD_CNT=0\$${NSDIR}_CNT"
-    GOT=`expr $NEW_CNT - $OLD_CNT`
+    GOT=$((NEW_CNT - OLD_CNT))
     if test "$GOT" -lt "$MIN" -o "$GOT" -gt "$MAX"; then
        setret "wrong $LABEL $NSDIR statistics of $GOT instead of ${MIN}..${MAX}"
     fi
@@ -785,7 +785,7 @@ EOF
     perf 'without RPZ' norpz 'NOERROR:3000 '
     NORPZ=`trim norpz`
 
-    PERCENT=`expr \( "$RPZ" \* 100 + \( $NORPZ / 2 \) \) / $NORPZ`
+    PERCENT=$(( (RPZ * 100 + (NORPZ / 2)) / NORPZ))
     echo_i "$RPZ qps with RPZ is $PERCENT% of $NORPZ qps without RPZ"
 
     MIN_PERCENT=30
index 6ffe1d6cc42fce4350a13a8864053313be91fb8c..ef9caa3100000917a748deb655fc76da6742eb4e 100644 (file)
@@ -27,7 +27,7 @@ while getopts "DNx" c; do
        *) echo "$USAGE" 1>&2; exit 1;;
     esac
 done
-shift `expr $OPTIND - 1 || true`
+shift $((OPTIND - 1))
 if test "$#" -ne 0; then
     echo "$USAGE" 1>&2
     exit 1
@@ -64,7 +64,7 @@ do
     while test $j -le $i
     do
        echo "name$j A 10.53.0.$i" >> ns2/db.max$i.local
-       j=`expr $j + 1`
+       j=$((j + 1))
     done
-    i=`expr $i + 1`
+    i=$((i + 1))
 done
index 5e06135df6aae062e984ef0ef4f66a052baa7b28..62a5f1ee8fdafed866152f9a2b8e55e61f7a9110 100644 (file)
@@ -34,7 +34,7 @@ while getopts "xS:" c; do
        *) echo "$USAGE" 1>&2; exit 1;;
     esac
 done
-shift `expr $OPTIND - 1 || true`
+shift $((OPTIND - 1))
 if test "$#" -ne 0; then
     echo "$USAGE" 1>&2
     exit 1
index 4263f298f596933cd6aa7bde9433064bbb1f32aa..af01cecef71202bd64a776a27877eef500317778 100644 (file)
@@ -34,7 +34,7 @@ while getopts "x" c; do
        *) echo "$USAGE" 1>&2; exit 1;;
     esac
 done
-shift `expr $OPTIND - 1 || true`
+shift $((OPTIND - 1))
 if test "$#" -ne 0; then
     echo "$USAGE" 1>&2
     exit 1
@@ -98,7 +98,7 @@ burst () {
                -e 's/;; .* status: SERVFAIL.*/SERVFAIL/p'              \
                -e 's/response failed with timed out.*/drop/p'          \
                -e 's/;; communications error to.*/drop/p' >> $FILENAME &
-    QNUM=`expr $QNUM + $BURST_LIMIT`
+    QNUM=$((QNUM + BURST_LIMIT))
 }
 
 # compare integers $1 and $2; ensure the difference is no more than $3
@@ -158,7 +158,7 @@ ckstats () {
     C=`cat ns2/named.stats |
         sed -n -e "s/[  ]*\([0-9]*\).responses $TYPE for rate limits.*/\1/p" |
         tail -1`
-    C=`expr 0$C + 0`
+    C=$((C))
 
     range "$C" $EXPECTED 1 ||
     setret "wrong $LABEL $TYPE statistics of $C instead of $EXPECTED"
index 5a70bee1ef2a9719381151854f05464768468255..b076ba1bdc103df16787cf9fe75faf716fecd1e3 100755 (executable)
@@ -2404,7 +2404,7 @@ burst() {
        num=${1}
        rm -f burst.input.$$
        while [ $num -gt 0 ]; do
-               num=`expr $num - 1`
+               num=$((num - 1))
                echo "fetch${num}.example A" >> burst.input.$$
        done
        $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 burst.input.$$
index cbc84a479e1c5b84006594e8c319b77353cbb2ad..28277a1224bb67f8a83cfb8b2f690c7f659386f3 100644 (file)
@@ -23,6 +23,8 @@ status=0
 ret=0
 n=1
 stats=0
+nsock0nstat=0
+nsock1nstat=0
 rndc_stats() {
        _ns=$1
        _ip=$2
@@ -81,7 +83,7 @@ ret=0
 echo_i "dumping initial stats for ns3 ($n)"
 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
+[ 0 -ne ${nsock0nstat} ] || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 n=$((n + 1))
@@ -117,7 +119,7 @@ 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
+[ $((nsock1nstat - nsock0nstat)) -eq 1 ] || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 n=$((n + 1))
index 143036c89fdcfc5774f973b54f272b31c3846e05..81343758b6ebece7856f0e47a2b8b9cdc0adbd9e 100644 (file)
@@ -416,7 +416,7 @@ EOF
 ) > /dev/null 2>&1 &
        $DIG -p ${PORT} +noadd +notcp +noauth noprimary. @10.53.0.3 soa > dig.out.ns3.test$n.$count || ret=1
        grep "status: NOERROR" dig.out.ns3.test$n.$count > /dev/null || ret=1
-       count=`expr $count + 1`
+       count=$((count + 1))
 done
 if [ $ret != 0 ] ; then echo_i "failed"; status=$((status + ret)); fi
 n=$((n + 1))
index 9a8590d7fd163054d5ce626625ed9888186b147a..42421acbe54380fb44df8998faf29670d4855d7e 100644 (file)
@@ -273,7 +273,7 @@ do
        else
                grep '^\\' dig.out.ns1.$x.test$n && { echo_i "code point $x failed" ; ret=1; }
        fi
-       i=`expr $i + 1`
+       i=$((i + 1))
 done
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
index 85b6aeb9c5efa1b5e15a3adc1c794b11b1639543..f74402e9c18b6f3c948693c61b13c3db83769e9a 100755 (executable)
@@ -31,8 +31,8 @@ while [ $count != 300 ]; do
                 kill -HUP `cat ns1/named.pid`
        fi
        sleep 1
-       ticks=`expr $ticks + 1`
-       seconds=`expr $ticks \* 1`
+       ticks=$((ticks + 1))
+       seconds=$((ticks * 1))
        if [ $ticks = 360 ]; then
                echo_i "Took too long to load zones"
                exit 1