]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
use guard values for testing unixtime serial
authorMark Andrews <marka@isc.org>
Wed, 25 Jul 2018 01:19:08 +0000 (11:19 +1000)
committerMark Andrews <marka@isc.org>
Thu, 2 Aug 2018 00:25:56 +0000 (10:25 +1000)
bin/tests/system/nsupdate/tests.sh

index 5902c80324529491a301f3a8a3e4f23318d483ac..03f9fc84079a4d3ca49feb06333db4ca04018673 100755 (executable)
@@ -268,6 +268,7 @@ ret=0
 echo_i "check that unixtime serial number is correctly generated ($n)"
 $DIG $DIGOPTS +short unixtime.nil. soa @10.53.0.1 > dig.out.old.test$n || ret=1
 oldserial=`awk '{print $3}' dig.out.old.test$n` || ret=1
+start=`$PERL -e 'print time()."\n";'`
 $NSUPDATE <<END > /dev/null 2>&1 || ret=1
     server 10.53.0.1 ${PORT}
     ttl 600
@@ -278,10 +279,12 @@ now=`$PERL -e 'print time()."\n";'`
 sleep 1
 $DIG $DIGOPTS +short unixtime.nil. soa @10.53.0.1 > dig.out.new.test$n || ret=1
 serial=`awk '{print $3}' dig.out.new.test$n` || ret=1
-[ "$oldserial" -ne "$serial" ] || ret=1
-# allow up to 2 seconds difference between the serial
-# number and the unix epoch date but no more
-$PERL -e 'exit 1 if abs($ARGV[1] - $ARGV[0]) > 2;' $now $serial || ret=1
+[ "$oldserial" = "$serial" ] && { echo_i "oldserial == serial"; ret=1; }
+if [ "$serial" -lt "$start" ]; then
+    echo_i "out-of-range serial=$serial < start=$start"; ret=1;
+elif [ "$serial" -gt "$now" ]; then
+    echo_i "out-of-range serial=$serial > now=$now"; ret=1;
+fi
 [ $ret = 0 ] || { echo_i "failed"; status=1; }
 
 ret=0