echo_i "check prefetch disabled (${n})"
ret=0
$DIG $DIGOPTS @10.53.0.7 fetch.example.net txt > dig.out.1.${n} || ret=1
-ttl1=`awk '/"A" "short" "ttl"/ { print $2 - 2 }' dig.out.1.${n}`
+ttl1=`awk '/"A" "short" "ttl"/ { print $2 }' dig.out.1.${n}`
+delay=$((ttl1 - 5))
# sleep so we are in expire range
-sleep ${ttl1:-0}
-# look for ttl = 1, allow for one miss at getting zero ttl
-zerotonine="0 1 2 3 4 5 6 7 8 9"
-for i in $zerotonine $zerotonine $zerotonine $zerotonine
-do
+sleep ${delay:-0}
+tmp_ttl=$ttl1
+# fetch record and ensure its ttl is in range 0 < ttl < tmp_ttl
+# since prefetch is disabled, updated ttl must be a lower value than
+# the previous one.
+for i in 0 1 3; do
$DIG $DIGOPTS @10.53.0.7 fetch.example.net txt > dig.out.2.${n} || ret=1
ttl2=`awk '/"A" "short" "ttl"/ { print $2 }' dig.out.2.${n}`
- test ${ttl2:-2} -eq 1 && break
- $PERL -e 'select(undef, undef, undef, 0.05);'
+ # check that prefetch has not occured
+ if [ $ttl2 -ge $tmp_ttl ]; then
+ ret=1
+ break
+ fi
+ tmp_ttl=$ttl2
+ $PERL -e 'select(undef, undef, undef, 1);'
done
-test ${ttl2:-2} -eq 1 || ret=1
-# delay so that any prefetched record will have a lower ttl than expected
-sleep 3
-# check that prefetch has not occured
-$DIG $DIGOPTS @10.53.0.7 fetch.example.net txt > dig.out.3.${n} || ret=1
-ttl=`awk '/"A" "short" "ttl"/ { print $2 - 2 }' dig.out.3.${n}`
-test ${ttl:-0} -eq ${ttl1:-1} || ret=1
+
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`