]> 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 01:29:15 +0000 (11:29 +1000)
(cherry picked from commit abe41ba0118783c8689a5086800ff6d919babdb7)

bin/tests/system/nsupdate/tests.sh

index cf09bd9408b51244c805eae5f888d1a0ecb0b178..ae8b3ce28a309cd622cdbdaaffc8f7047720616d 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