set -e
SYSTEMTESTTOP=..
-. $SYSTEMTESTTOP/conf.sh
+# shellcheck source=../conf.sh
+. "$SYSTEMTESTTOP/conf.sh"
-DIGOPTS="-p ${PORT}"
-RNDCCMD="$RNDC -p ${CONTROLPORT} -c ../common/rndc.conf"
-SEND="$PERL $SYSTEMTESTTOP/send.pl 10.53.0.6 ${CONTROLPORT}"
+dig_with_opts() {
+ "${DIG}" -p "${PORT}" "$@"
+}
+
+rndccmd() {
+ "${RNDC}" -p "${CONTROLPORT}" -c ../common/rndc.conf -s "$@"
+}
status=0
n=0
n=$((n + 1))
echo_i "initializing TCP statistics ($n)"
ret=0
-$RNDCCMD -s 10.53.0.1 stats || ret=1
-$RNDCCMD -s 10.53.0.2 stats || ret=1
+rndccmd 10.53.0.1 stats || ret=1
+rndccmd 10.53.0.2 stats || ret=1
mv ns1/named.stats ns1/named.stats.test$n
mv ns2/named.stats ns2/named.stats.test$n
-ntcp10=`grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}'`
-ntcp20=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}'`
+ntcp10="$(grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}')"
+ntcp20="$(grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}')"
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "checking TCP request statistics (resolver) ($n)"
ret=0
-$DIG $DIGOPTS @10.53.0.3 txt.example. > dig.out.test$n
+dig_with_opts @10.53.0.3 txt.example. > dig.out.test$n
sleep 1
-$RNDCCMD -s 10.53.0.1 stats || ret=1
-$RNDCCMD -s 10.53.0.2 stats || ret=1
+rndccmd 10.53.0.1 stats || ret=1
+rndccmd 10.53.0.2 stats || ret=1
mv ns1/named.stats ns1/named.stats.test$n
mv ns2/named.stats ns2/named.stats.test$n
-ntcp11=`grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}'`
-ntcp21=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}'`
+ntcp11="$(grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}')"
+ntcp21="$(grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}')"
if [ "$ntcp10" -ge "$ntcp11" ]; then ret=1; fi
if [ "$ntcp20" -ne "$ntcp21" ]; then ret=1; fi
if [ $ret != 0 ]; then echo_i "failed"; fi
n=$((n + 1))
echo_i "checking TCP request statistics (forwarder) ($n)"
ret=0
-$DIG $DIGOPTS @10.53.0.4 txt.example. > dig.out.test$n
+dig_with_opts @10.53.0.4 txt.example. > dig.out.test$n
sleep 1
-$RNDCCMD -s 10.53.0.1 stats || ret=1
-$RNDCCMD -s 10.53.0.2 stats || ret=1
+rndccmd 10.53.0.1 stats || ret=1
+rndccmd 10.53.0.2 stats || ret=1
mv ns1/named.stats ns1/named.stats.test$n
mv ns2/named.stats ns2/named.stats.test$n
-ntcp12=`grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}'`
-ntcp22=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}'`
+ntcp12="$(grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}')"
+ntcp22="$(grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}')"
if [ "$ntcp11" -ne "$ntcp12" ]; then ret=1; fi
if [ "$ntcp21" -ge "$ntcp22" ];then ret=1; fi
if [ $ret != 0 ]; then echo_i "failed"; fi
# -------- TCP high-water tests ----------
refresh_tcp_stats() {
- $RNDCCMD -s 10.53.0.5 status > rndc.out.$n || ret=1
+ rndccmd 10.53.0.5 status > rndc.out.$n || ret=1
TCP_CUR="$(sed -n "s/^tcp clients: \([0-9][0-9]*\).*/\1/p" rndc.out.$n)"
TCP_LIMIT="$(sed -n "s/^tcp clients: .*\/\([0-9][0-9]*\)/\1/p" rndc.out.$n)"
TCP_HIGH="$(sed -n "s/^TCP high-water: \([0-9][0-9]*\)/\1/p" rndc.out.$n)"
wait_for_log() {
msg=$1
file=$2
- for i in 1 2 3 4 5 6 7 8 9 10; do
+ for _ in 1 2 3 4 5 6 7 8 9 10; do
nextpart "$file" | grep "$msg" > /dev/null && return
sleep 1
done
# Send a command to the tool script listening on 10.53.0.6.
send_command() {
nextpart ans6/ans.run > /dev/null
- echo "$*" | $SEND
+ echo "$*" | "${PERL}" "${SYSTEMTESTTOP}/send.pl" 10.53.0.6 "${CONTROLPORT}"
wait_for_log "result=OK" ans6/ans.run
}