summaryrefslogtreecommitdiffstats
path: root/bin/tests/system/keymgr/tests.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 23:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 23:51:28 +0000
commit754c7de1e91eeb28c6d3766900ead0c3e44fdb85 (patch)
tree51433c0e38731dc9ecd342555a56f876980b1834 /bin/tests/system/keymgr/tests.sh
parentAdding debian version 1:9.16.44-1~deb11u1. (diff)
downloadbind9-754c7de1e91eeb28c6d3766900ead0c3e44fdb85.tar.xz
bind9-754c7de1e91eeb28c6d3766900ead0c3e44fdb85.zip
Merging upstream version 1:9.16.48.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bin/tests/system/keymgr/tests.sh')
-rw-r--r--bin/tests/system/keymgr/tests.sh207
1 files changed, 103 insertions, 104 deletions
diff --git a/bin/tests/system/keymgr/tests.sh b/bin/tests/system/keymgr/tests.sh
index 667277f..5beb83c 100644
--- a/bin/tests/system/keymgr/tests.sh
+++ b/bin/tests/system/keymgr/tests.sh
@@ -17,130 +17,129 @@ SYSTEMTESTTOP=..
status=0
n=1
-matchall () {
- match_result=ok
- file=$1
- while IFS="," read expect matchline; do
- [ -z "$matchline" ] && continue
- matches=`grep "$matchline" $file | wc -l`
- [ "$matches" -ne "$expect" ] && {
- echo "'$matchline': expected $expect found $matches"
- return 1
- }
- done << EOF
+matchall() {
+ match_result=ok
+ file=$1
+ while IFS="," read expect matchline; do
+ [ -z "$matchline" ] && continue
+ matches=$(grep "$matchline" $file | wc -l)
+ [ "$matches" -ne "$expect" ] && {
+ echo "'$matchline': expected $expect found $matches"
+ return 1
+ }
+ done <<EOF
$2
EOF
- return 0
+ return 0
}
echo_i "checking for DNSSEC key coverage issues"
ret=0
for dir in [0-9][0-9]-*; do
- ret=0
- echo_i "$dir ($n)"
- kargs= cargs= kmatch= cmatch= kret= cret=0 warn= error= ok=
- . $dir/expect
-
- # use policy.conf if available
- policy=""
- if [ -e "$dir/policy.conf" ]; then
- policy="-c $dir/policy.conf"
- if grep -e "-c policy.conf" $dir/expect > /dev/null
- then
- echo_i "fix $dir/expect: multiple policy files"
- ret=1
- fi
- else
- policy="-c policy.conf"
- fi
-
- # run keymgr to update keys
- if [ "$CYGWIN" ]; then
- $KEYMGR $policy -K $dir -g `cygpath -w $KEYGEN` \
- -s `cygpath -w $SETTIME` $kargs > keymgr.$n 2>&1
- else
- $KEYMGR $policy -K $dir -g $KEYGEN \
- -s $SETTIME $kargs > keymgr.$n 2>&1
- fi
- # check that return code matches expectations
- found=$?
- if [ $found -ne $kret ]; then
- echo "keymgr retcode was $found expected $kret"
- ret=1
- fi
-
- # check for matches in keymgr output
- matchall keymgr.$n "$kmatch" || ret=1
-
- # now check coverage
- $COVERAGE -K $dir $cargs > coverage.$n 2>&1
- # check that return code matches expectations
- found=$?
- if [ $found -ne $cret ]; then
- echo "coverage retcode was $found expected $cret"
- ret=1
- fi
-
- # check for correct number of errors
- found=`grep ERROR coverage.$n | wc -l`
- if [ $found -ne $error ]; then
- echo "error count was $found expected $error"
- ret=1
- fi
-
- # check for correct number of warnings
- found=`grep WARNING coverage.$n | wc -l`
- if [ $found -ne $warn ]; then
- echo "warning count was $found expected $warn"
- ret=1
- fi
-
- # check for correct number of OKs
- found=`grep "No errors found" coverage.$n | wc -l`
- if [ $found -ne $ok ]; then
- echo "good count was $found expected $ok"
- ret=1
- fi
-
- # check for matches in coverage output
- matchall coverage.$n "$cmatch" || ret=1
-
- if [ -f $dir/extra.sh ]; then
- cd $dir
- . ./extra.sh
- cd ..
- fi
-
- n=`expr $n + 1`
- if [ $ret != 0 ]; then echo_i "failed"; fi
- status=`expr $status + $ret`
+ ret=0
+ echo_i "$dir ($n)"
+ kargs= cargs= kmatch= cmatch= kret= cret=0 warn= error= ok=
+ . $dir/expect
+
+ # use policy.conf if available
+ policy=""
+ if [ -e "$dir/policy.conf" ]; then
+ policy="-c $dir/policy.conf"
+ if grep -e "-c policy.conf" $dir/expect >/dev/null; then
+ echo_i "fix $dir/expect: multiple policy files"
+ ret=1
+ fi
+ else
+ policy="-c policy.conf"
+ fi
+
+ # run keymgr to update keys
+ if [ "$CYGWIN" ]; then
+ $KEYMGR $policy -K $dir -g $(cygpath -w $KEYGEN) \
+ -s $(cygpath -w $SETTIME) $kargs >keymgr.$n 2>&1
+ else
+ $KEYMGR $policy -K $dir -g $KEYGEN \
+ -s $SETTIME $kargs >keymgr.$n 2>&1
+ fi
+ # check that return code matches expectations
+ found=$?
+ if [ $found -ne $kret ]; then
+ echo "keymgr retcode was $found expected $kret"
+ ret=1
+ fi
+
+ # check for matches in keymgr output
+ matchall keymgr.$n "$kmatch" || ret=1
+
+ # now check coverage
+ $COVERAGE -K $dir $cargs >coverage.$n 2>&1
+ # check that return code matches expectations
+ found=$?
+ if [ $found -ne $cret ]; then
+ echo "coverage retcode was $found expected $cret"
+ ret=1
+ fi
+
+ # check for correct number of errors
+ found=$(grep ERROR coverage.$n | wc -l)
+ if [ $found -ne $error ]; then
+ echo "error count was $found expected $error"
+ ret=1
+ fi
+
+ # check for correct number of warnings
+ found=$(grep WARNING coverage.$n | wc -l)
+ if [ $found -ne $warn ]; then
+ echo "warning count was $found expected $warn"
+ ret=1
+ fi
+
+ # check for correct number of OKs
+ found=$(grep "No errors found" coverage.$n | wc -l)
+ if [ $found -ne $ok ]; then
+ echo "good count was $found expected $ok"
+ ret=1
+ fi
+
+ # check for matches in coverage output
+ matchall coverage.$n "$cmatch" || ret=1
+
+ if [ -f $dir/extra.sh ]; then
+ cd $dir
+ . ./extra.sh
+ cd ..
+ fi
+
+ n=$(expr $n + 1)
+ if [ $ret != 0 ]; then echo_i "failed"; fi
+ status=$(expr $status + $ret)
done
echo_i "checking domains ending in . ($n)"
ret=0
-$KEYMGR -g $KEYGEN -s $SETTIME . > keymgr.1.$n 2>&1
-nkeys=`grep dnssec-keygen keymgr.1.$n | wc -l`
+$KEYMGR -g $KEYGEN -s $SETTIME . >keymgr.1.$n 2>&1
+nkeys=$(grep dnssec-keygen keymgr.1.$n | wc -l)
[ "$nkeys" -eq 2 ] || ret=1
-$KEYMGR -g $KEYGEN -s $SETTIME . > keymgr.2.$n 2>&1
-nkeys=`grep dnssec-keygen keymgr.2.$n | wc -l`
+$KEYMGR -g $KEYGEN -s $SETTIME . >keymgr.2.$n 2>&1
+nkeys=$(grep dnssec-keygen keymgr.2.$n | wc -l)
[ "$nkeys" -eq 0 ] || ret=1
-$KEYMGR -g $KEYGEN -s $SETTIME example.com. > keymgr.3.$n 2>&1
-nkeys=`grep dnssec-keygen keymgr.3.$n | wc -l`
+$KEYMGR -g $KEYGEN -s $SETTIME example.com. >keymgr.3.$n 2>&1
+nkeys=$(grep dnssec-keygen keymgr.3.$n | wc -l)
[ "$nkeys" -eq 2 ] || ret=1
-$KEYMGR -g $KEYGEN -s $SETTIME example.com. > keymgr.4.$n 2>&1
-nkeys=`grep dnssec-keygen keymgr.4.$n | wc -l`
+$KEYMGR -g $KEYGEN -s $SETTIME example.com. >keymgr.4.$n 2>&1
+nkeys=$(grep dnssec-keygen keymgr.4.$n | wc -l)
[ "$nkeys" -eq 0 ] || ret=1
-status=`expr $status + $ret`
-n=`expr $n + 1`
+status=$(expr $status + $ret)
+n=$(expr $n + 1)
echo_i "checking policy.conf parser ($n)"
ret=0
-PYTHONPATH="../../../python:$PYTHONPATH" ${PYTHON} testpolicy.py policy.sample > policy.out
-$DOS2UNIX policy.out > /dev/null 2>&1
+PYTHONPATH="../../../python:$PYTHONPATH" ${PYTHON} testpolicy.py policy.sample >policy.out
+$DOS2UNIX policy.out >/dev/null 2>&1
cmp -s policy.good policy.out || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
-status=`expr $status + $ret`
-n=`expr $n + 1`
+status=$(expr $status + $ret)
+n=$(expr $n + 1)
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1