From: Michał Kępień Date: Thu, 7 Nov 2019 11:25:39 +0000 (+0100) Subject: Use "set -e" in the "tcp" system test X-Git-Tag: v9.15.6~22^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9841635b7f7adba64597247318f352c678082cfc;p=thirdparty%2Fbind9.git Use "set -e" in the "tcp" system test Ensure any unexpected failure in the "tcp" system test causes it to be immediately interrupted with an error to make the aforementioned test more reliable. Since the exit code for "expr 0 + 0" is 1, the status variable needs to be updated using arithmetic expansion. --- diff --git a/bin/tests/system/tcp/tests.sh b/bin/tests/system/tcp/tests.sh index 2d309c2bc4b..1f836ce97b4 100644 --- a/bin/tests/system/tcp/tests.sh +++ b/bin/tests/system/tcp/tests.sh @@ -9,6 +9,8 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. +set -e + SYSTEMTESTTOP=.. . $SYSTEMTESTTOP/conf.sh @@ -29,7 +31,7 @@ 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}'` if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) n=$((n + 1)) echo_i "checking TCP request statistics (resolver) ($n)" @@ -45,7 +47,7 @@ ntcp21=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{pr if [ "$ntcp10" -ge "$ntcp11" ]; then ret=1; fi if [ "$ntcp20" -ne "$ntcp21" ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) n=$((n + 1)) echo_i "checking TCP request statistics (forwarder) ($n)" @@ -61,7 +63,7 @@ ntcp22=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{pr if [ "$ntcp11" -ne "$ntcp12" ]; then ret=1; fi if [ "$ntcp21" -ge "$ntcp22" ];then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # -------- TCP high-water tests ---------- refresh_tcp_stats() { @@ -107,7 +109,7 @@ ret=0 refresh_tcp_stats assert_int_equal "${TCP_CUR}" 1 "current TCP clients count" || ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # Ensure the TCP high-water statistic gets updated after some TCP connections # are established. @@ -124,7 +126,7 @@ check_stats_added() { } retry 2 check_stats_added || ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # Ensure the TCP high-water statistic remains unchanged after some TCP # connections are closed. @@ -142,7 +144,7 @@ check_stats_removed() { } retry 2 check_stats_removed || ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # Ensure the TCP high-water statistic never exceeds the configured TCP clients # limit. @@ -157,7 +159,7 @@ check_stats_limit() { } retry 2 check_stats_limit || 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