testsummary.sh 1.68 KB
Newer Older
1 2
#!/bin/sh
#
3
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4 5 6 7
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 9 10
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
11

12
# Creates the system tests output file from the various test.output files.  It
13 14 15
# then searches that file and prints the number of tests passed, failed, not
# run.  It also checks whether the IP addresses 10.53.0.[1-8] were set up and,
# if not, prints a warning.
16 17
#
# Usage:
18 19 20 21
#    testsummary.sh [-n]
#
# -n	Do NOT delete the individual test.output files after concatenating
#	them into systests.output.
22 23 24 25 26 27 28 29
#
# Status return:
# 0 - no tests failed
# 1 - one or more tests failed

SYSTEMTESTTOP=.
. $SYSTEMTESTTOP/conf.sh

30 31
keepfile=0

32 33 34 35 36 37
while getopts "n" flag; do
    case $flag in
	n) keepfile=1 ;;
    esac
done

38 39 40 41 42 43 44 45
if [ `ls */test.output 2> /dev/null | wc -l` -eq 0 ]; then
    echowarn "I:No 'test.output' files were found."
    echowarn "I:Printing summary from pre-existing 'systests.output'."
else
    cat */test.output > systests.output
    if [ $keepfile -eq 0 ]; then
        rm -f */test.output
    fi
46
fi
47

48
status=0
49 50
echoinfo "I:System test result summary:"
echoinfo "`grep 'R:[a-z0-9_-][a-z0-9_-]*:[A-Z][A-Z]*' systests.output | cut -d':' -f3 | sort | uniq -c | sed -e 's/^/I:/'`"
51 52 53

FAILED_TESTS=`grep 'R:[a-z0-9_-][a-z0-9_-]*:FAIL' systests.output | cut -d':' -f2 | sort | sed -e 's/^/I:      /'`
if [ -n "${FAILED_TESTS}" ]; then
54 55
	echoinfo "I:The following system tests failed:"
	echoinfo "${FAILED_TESTS}"
56 57
	status=1
fi
58 59

exit $status