[squash] Put Perl code extracting a tree from a cache dump in a separate function
This commit is contained in:
@@ -81,6 +81,21 @@ in_cache () {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Extract records at and below name "$1" from the cache dump in file "$2".
|
||||
filter_tree () {
|
||||
tree="$1"
|
||||
file="$2"
|
||||
perl -n -e '
|
||||
next if /^;/;
|
||||
if (/'"$tree"'/ || (/^\t/ && $print)) {
|
||||
$print = 1;
|
||||
} else {
|
||||
$print = 0;
|
||||
}
|
||||
print if $print;
|
||||
' "$file"
|
||||
}
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "check correctness of routine cache cleaning ($n)"
|
||||
$DIG $DIGOPTS +tcp +keepopen -b 10.53.0.7 -f dig.batch > dig.out.ns2 || status=1
|
||||
@@ -98,7 +113,7 @@ echo_i "reset and check that records are correctly cached initially ($n)"
|
||||
ret=0
|
||||
load_cache
|
||||
dump_cache
|
||||
nrecords=`grep -v '^;' ns2/named_dump.db.$n | perl -nle 'if (/flushtest\.example/ || (/^\t/ && $out)) {$out=1;} else {$out=0;} print if ($out);' | egrep '(TXT|ANY)'| wc -l`
|
||||
nrecords=`filter_tree flushtest.example ns2/named_dump.db.$n | egrep '(TXT|ANY)' | wc -l`
|
||||
[ $nrecords -eq 18 ] || { ret=1; echo_i "found $nrecords records expected 18"; }
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
@@ -108,7 +123,7 @@ echo_i "check flushing of the full cache ($n)"
|
||||
ret=0
|
||||
clear_cache
|
||||
dump_cache
|
||||
nrecords=`grep -v '^;' ns2/named_dump.db.$n | perl -nle 'if (/flushtest\.example/ || (/^\t/ && $out)) {$out=1;} else {$out=0;} print if ($out);' | wc -l`
|
||||
nrecords=`filter_tree flushtest.example ns2/named_dump.db.$n | wc -l`
|
||||
[ $nrecords -eq 0 ] || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
@@ -192,7 +207,7 @@ n=`expr $n + 1`
|
||||
echo_i "check the number of cached records remaining ($n)"
|
||||
ret=0
|
||||
dump_cache
|
||||
nrecords=`grep -v '^;' ns2/named_dump.db.$n | perl -nle 'if (/flushtest\.example/ || (/^\t/ && $out)) {$out=1;} else {$out=0;} print if ($out);' | egrep '(TXT|ANY)' | wc -l`
|
||||
nrecords=`filter_tree flushtest.example ns2/named_dump.db.$n | grep -v '^;' | egrep '(TXT|ANY)' | wc -l`
|
||||
[ $nrecords -eq 17 ] || { ret=1; echo_i "found $nrecords records expected 17"; }
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
@@ -210,7 +225,7 @@ n=`expr $n + 1`
|
||||
echo_i "check the number of cached records remaining ($n)"
|
||||
ret=0
|
||||
dump_cache
|
||||
nrecords=`grep -v '^;' ns2/named_dump.db.$n | perl -nle 'if (/flushtest\.example/ || (/^\t/ && $out)) {$out=1;} else {$out=0;} print if ($out);' | egrep '(TXT|ANY)' | wc -l`
|
||||
nrecords=`filter_tree flushtest.example ns2/named_dump.db.$n | egrep '(TXT|ANY)' | wc -l`
|
||||
[ $nrecords -eq 1 ] || { ret=1; echo_i "found $nrecords records expected 1"; }
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
Reference in New Issue
Block a user