f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt#!/bin/sh
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt#
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt# Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan HuntSYSTEMTESTTOP=..
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt. $SYSTEMTESTTOP/conf.sh
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntstatus=0
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntn=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntmatchall () {
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt file=$1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "$2" | while read matchline; do
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt grep "$matchline" $file > /dev/null 2>&1 || {
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "FAIL"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt return
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt }
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt done
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt}
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntecho "I:checking for DNSSEC key coverage issues"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntret=0
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntfor dir in [0-9][0-9]-*; do
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=0
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "I:$dir ($n)"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt kargs= cargs= kmatch= cmatch= kret= cret=0 warn= error= ok=
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt . $dir/expect
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
d907426f0f5b6100cbe4d03e417f59ce67ff171bEvan Hunt # use policy.conf if available
d907426f0f5b6100cbe4d03e417f59ce67ff171bEvan Hunt policy=""
d907426f0f5b6100cbe4d03e417f59ce67ff171bEvan Hunt [ -e "$dir/policy.conf" ] && policy="-c $dir/policy.conf"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt # run keymgr to update keys
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki if [ "$CYGWIN" ]; then
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki $KEYMGR $policy -K $dir -g `cygpath -w $KEYGEN` -r $RANDFILE \
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki -s `cygpath -w $SETTIME` $kargs > keymgr.$n 2>&1
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki else
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki $KEYMGR $policy -K $dir -g $KEYGEN -r $RANDFILE \
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki -s $SETTIME $kargs > keymgr.$n 2>&1
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt # check that return code matches expectations
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt found=$?
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ $found -ne $kret ]; then
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "keymgr retcode was $found expected $kret"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt found=`matchall keymgr.$n "$kmatch"`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ "$found" = "FAIL" ]; then
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "no match on '$kmatch'"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt # now check coverage
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt $COVERAGE -K $dir $cargs > coverage.$n 2>&1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt # check that return code matches expectations
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt found=$?
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ $found -ne $cret ]; then
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "coverage retcode was $found expected $cret"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt # check for correct number of errors
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt found=`grep ERROR coverage.$n | wc -l`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ $found -ne $error ]; then
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "error count was $found expected $error"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt # check for correct number of warnings
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt found=`grep WARNING coverage.$n | wc -l`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ $found -ne $warn ]; then
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "warning count was $found expected $warn"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt # check for correct number of OKs
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt found=`grep "No errors found" coverage.$n | wc -l`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ $found -ne $ok ]; then
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "good count was $found expected $ok"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt found=`matchall coverage.$n "$cmatch"`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ "$found" = "FAIL" ]; then
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt echo "no match on '$cmatch'"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt n=`expr $n + 1`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt if [ $ret != 0 ]; then echo "I:failed"; fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt status=`expr $status + $ret`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntdone
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntecho "I:checking policy.conf parser ($n)"
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntret=0
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt${PYTHON} testpolicy.py policy.sample > policy.out
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki$DOS2UNIX policy.out > /dev/null
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntcmp -s policy.good policy.out || ret=1
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntif [ $ret != 0 ]; then echo "I:failed"; fi
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntstatus=`expr $status + $ret`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntn=`expr $n + 1`
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Hunt
f6096b958c8b58c4709860d7c4dcdde5deeacb7aEvan Huntecho "I:exit status: $status"
3635d8f9104e70e141a8f191a0e6c1502ceed2f3Mark Andrews[ $status -eq 0 ] || exit 1