tests.sh revision d907426f0f5b6100cbe4d03e417f59ce67ff171b
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley#!/bin/sh
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews#
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley#
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley# This Source Code Form is subject to the terms of the Mozilla Public
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley# License, v. 2.0. If a copy of the MPL was not distributed with this
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# file, You can obtain one at http://mozilla.org/MPL/2.0/.
15a44745412679c30a6d022733925af70a38b715David Lawrence
15a44745412679c30a6d022733925af70a38b715David LawrenceSYSTEMTESTTOP=..
15a44745412679c30a6d022733925af70a38b715David Lawrence. $SYSTEMTESTTOP/conf.sh
15a44745412679c30a6d022733925af70a38b715David Lawrence
15a44745412679c30a6d022733925af70a38b715David Lawrencestatus=0
15a44745412679c30a6d022733925af70a38b715David Lawrencen=1
15a44745412679c30a6d022733925af70a38b715David Lawrence
15a44745412679c30a6d022733925af70a38b715David Lawrencematchall () {
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley file=$1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley echo "$2" | while read matchline; do
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews grep "$matchline" $file > /dev/null 2>&1 || {
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence echo "FAIL"
110d1702731f42dd620879c1d765ebe91f3920ceMichael Graff return
110d1702731f42dd620879c1d765ebe91f3920ceMichael Graff }
c3b708aaf1bb0a118e0e11befa1b732acfb1d079Bob Halley done
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley}
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
def8e47c688e2480a4539d69c3d1a0a28a7c0550Mark Andrewsecho "I:checking for DNSSEC key coverage issues"
364a82f7c25b62967678027043425201a5e5171aBob Halleyret=0
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyfor dir in [0-9][0-9]-*; do
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence ret=0
8dfa9caeec8e68db0c937e347a3d6629e7627d54Bob Halley echo "I:$dir ($n)"
54f959d12b5a1f9315fbf6a776c6d349316e9686Bob Halley kargs= cargs= kmatch= cmatch= kret= cret=0 warn= error= ok=
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley . $dir/expect
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley # use policy.conf if available
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley policy=""
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley [ -e "$dir/policy.conf" ] && policy="-c $dir/policy.conf"
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley # run keymgr to update keys
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley $KEYMGR $policy -K $dir -g $KEYGEN -r $RANDFILE -s $SETTIME $kargs > keymgr.$n 2>&1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley # check that return code matches expectations
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley found=$?
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley if [ $found -ne $kret ]; then
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley echo "keymgr retcode was $found expected $kret"
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ret=1
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley fi
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley found=`matchall keymgr.$n "$kmatch"`
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley if [ "$found" = "FAIL" ]; then
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley echo "no match on '$kmatch'"
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ret=1
ca67883a666bdf314d3da958d5195e7215b1f797Bob Halley fi
732e0731dec1922747bb3b3147cf2c3d16b22eaaBob Halley
b12f0228b32775ee688ed21ddbf3a116c1adfb43Michael Graff # now check coverage
61fb42c4ef45d88e115bd769c30c4f36b461870bMark Andrews $COVERAGE -K $dir $cargs > coverage.$n 2>&1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley # check that return code matches expectations
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley found=$?
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley if [ $found -ne $cret ]; then
80b782f356f0692c11b4e52e8dd46ec41704e5a2Mark Andrews echo "coverage retcode was $found expected $cret"
e496615043400500492fa7b891c515c8e7cb7d08Bob Halley ret=1
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews fi
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley # check for correct number of errors
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley found=`grep ERROR coverage.$n | wc -l`
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley if [ $found -ne $error ]; then
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley echo "error count was $found expected $error"
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ret=1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley fi
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley # check for correct number of warnings
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley found=`grep WARNING coverage.$n | wc -l`
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley if [ $found -ne $warn ]; then
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence echo "warning count was $found expected $warn"
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley ret=1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley fi
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley # check for correct number of OKs
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley found=`grep "No errors found" coverage.$n | wc -l`
ca67883a666bdf314d3da958d5195e7215b1f797Bob Halley if [ $found -ne $ok ]; then
732e0731dec1922747bb3b3147cf2c3d16b22eaaBob Halley echo "good count was $found expected $ok"
b12f0228b32775ee688ed21ddbf3a116c1adfb43Michael Graff ret=1
61fb42c4ef45d88e115bd769c30c4f36b461870bMark Andrews fi
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley found=`matchall coverage.$n "$cmatch"`
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley if [ "$found" = "FAIL" ]; then
80b782f356f0692c11b4e52e8dd46ec41704e5a2Mark Andrews echo "no match on '$cmatch'"
e496615043400500492fa7b891c515c8e7cb7d08Bob Halley ret=1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley fi
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley n=`expr $n + 1`
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley if [ $ret != 0 ]; then echo "I:failed"; fi
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley status=`expr $status + $ret`
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleydone
2cd0c38115b1efb043ed3104c0d08e51ceade0d7Bob Halley
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyecho "I:checking policy.conf parser ($n)"
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyret=0
078d49b63324f01d98301ee21671abee0c41fcdeBob Halley${PYTHON} testpolicy.py policy.sample > policy.out
0180ccf72c79b98eb8ee5abbb7331aec6951dd9fBob Halleycmp -s policy.good policy.out || ret=1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyif [ $ret != 0 ]; then echo "I:failed"; fi
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleystatus=`expr $status + $ret`
5619558151f1aa4249b3ead979e76876e29278b6Bob Halleyn=`expr $n + 1`
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley
904a5734375869ffb504ed8cde6b68cafadb6d64Bob Halleyecho "I:exit status: $status"
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley[ $status -eq 0 ] || exit 1
5619558151f1aa4249b3ead979e76876e29278b6Bob Halley