2000-05-15 22:53:15 +00:00
|
|
|
#!/bin/sh
|
2000-05-19 22:45:47 +00:00
|
|
|
#
|
2018-02-23 09:53:12 +01:00
|
|
|
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2012-06-29 11:39:47 +10:00
|
|
|
#
|
2016-06-27 14:56:38 +10:00
|
|
|
# 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/.
|
2018-02-23 09:53:12 +01:00
|
|
|
#
|
|
|
|
# See the COPYRIGHT file distributed with this work for additional
|
|
|
|
# information regarding copyright ownership.
|
2004-03-05 05:14:21 +00:00
|
|
|
|
2000-05-15 22:53:15 +00:00
|
|
|
#
|
|
|
|
# Run a system test.
|
|
|
|
#
|
2000-06-05 19:36:44 +00:00
|
|
|
|
|
|
|
SYSTEMTESTTOP=.
|
|
|
|
. $SYSTEMTESTTOP/conf.sh
|
2000-05-15 22:53:15 +00:00
|
|
|
|
2000-06-09 23:16:56 +00:00
|
|
|
stopservers=true
|
2017-11-23 09:58:57 +00:00
|
|
|
baseport=5300
|
2017-10-18 13:00:15 +02:00
|
|
|
|
2018-02-21 14:59:33 +01:00
|
|
|
if [ ${SYSTEMTEST_NO_CLEAN:-0} -eq 1 ]; then
|
|
|
|
clean=false
|
|
|
|
else
|
|
|
|
clean=true
|
|
|
|
fi
|
|
|
|
|
2018-03-06 10:59:25 -08:00
|
|
|
while getopts "knp:r-:" flag; do
|
2017-10-18 13:00:15 +02:00
|
|
|
case "$flag" in
|
2018-03-06 10:59:25 -08:00
|
|
|
-) case "${OPTARG}" in
|
|
|
|
keep) stopservers=false ;;
|
|
|
|
noclean) clean=false ;;
|
|
|
|
esac
|
|
|
|
;;
|
2017-10-18 13:00:15 +02:00
|
|
|
k) stopservers=false ;;
|
|
|
|
n) clean=false ;;
|
2017-11-23 09:58:57 +00:00
|
|
|
p) baseport=$OPTARG ;;
|
2017-12-15 15:56:33 +00:00
|
|
|
r) runall="-r" ;;
|
2017-10-18 13:00:15 +02:00
|
|
|
esac
|
|
|
|
done
|
2017-12-14 17:17:28 +00:00
|
|
|
shift `expr $OPTIND - 1`
|
2000-06-09 23:16:56 +00:00
|
|
|
|
2017-12-20 15:50:03 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echofail "Usage: $0 [-k] [-n] [-p <PORT>] [-r] test-directory [test-options]" >&2;
|
|
|
|
exit 1
|
|
|
|
fi
|
2000-05-15 22:53:15 +00:00
|
|
|
|
2017-12-20 19:08:57 +00:00
|
|
|
systest=$1
|
2000-05-15 22:53:15 +00:00
|
|
|
shift
|
|
|
|
|
2017-12-20 19:08:57 +00:00
|
|
|
if [ ! -d $systest ]; then
|
|
|
|
echofail "$0: $systest: no such test" >&2
|
2017-12-20 15:50:03 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2000-05-15 22:53:15 +00:00
|
|
|
|
2017-12-14 17:17:28 +00:00
|
|
|
# Define the number of ports allocated for each test, and the lowest and
|
|
|
|
# highest valid values for the "-p" option.
|
2017-12-14 15:02:01 +00:00
|
|
|
#
|
2017-12-14 17:17:28 +00:00
|
|
|
# The lowest valid value is one more than the highest privileged port number
|
|
|
|
# (1024).
|
|
|
|
#
|
|
|
|
# The highest valid value is calculated by noting that the value passed on the
|
|
|
|
# command line is the lowest port number in a block of "numports" consecutive
|
|
|
|
# ports and that the highest valid port number is 65,535.
|
|
|
|
numport=100
|
2017-12-14 15:02:01 +00:00
|
|
|
minvalid=`expr 1024 + 1`
|
|
|
|
maxvalid=`expr 65535 - $numport + 1`
|
|
|
|
|
|
|
|
test "$baseport" -eq "$baseport" > /dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
2017-12-20 19:08:57 +00:00
|
|
|
echofail "$0: $systest: must specify a numeric value for the port" >&2
|
2017-12-14 15:02:01 +00:00
|
|
|
exit 1
|
|
|
|
elif [ $baseport -lt $minvalid -o $baseport -gt $maxvalid ]; then
|
2017-12-20 19:08:57 +00:00
|
|
|
echofail "$0: $systest: the specified port must be in the range $minvalid to $maxvalid" >&2
|
2017-12-14 15:02:01 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-12-14 17:17:28 +00:00
|
|
|
# Name the first 10 ports in the set (it is assumed that each test has access
|
|
|
|
# to ten or more ports): the query port, the control port and eight extra
|
|
|
|
# ports. Since the lowest numbered port (specified in the command line)
|
|
|
|
# will usually be a multiple of 10, the names are chosen so that if this is
|
|
|
|
# true, the last digit of EXTRAPORTn is "n".
|
2018-01-29 12:33:33 +01:00
|
|
|
PORT=$baseport
|
|
|
|
EXTRAPORT1=`expr $baseport + 1`
|
|
|
|
EXTRAPORT2=`expr $baseport + 2`
|
|
|
|
EXTRAPORT3=`expr $baseport + 3`
|
|
|
|
EXTRAPORT4=`expr $baseport + 4`
|
|
|
|
EXTRAPORT5=`expr $baseport + 5`
|
|
|
|
EXTRAPORT6=`expr $baseport + 6`
|
|
|
|
EXTRAPORT7=`expr $baseport + 7`
|
|
|
|
EXTRAPORT8=`expr $baseport + 8`
|
|
|
|
CONTROLPORT=`expr $baseport + 9`
|
2017-12-14 15:02:01 +00:00
|
|
|
|
2018-01-29 12:33:33 +01:00
|
|
|
LOWPORT=$baseport
|
|
|
|
HIGHPORT=`expr $baseport + $numport - 1`
|
2017-12-14 15:02:01 +00:00
|
|
|
|
2018-01-29 12:33:33 +01:00
|
|
|
export PORT
|
|
|
|
export EXTRAPORT1
|
|
|
|
export EXTRAPORT2
|
|
|
|
export EXTRAPORT3
|
|
|
|
export EXTRAPORT4
|
|
|
|
export EXTRAPORT5
|
|
|
|
export EXTRAPORT6
|
|
|
|
export EXTRAPORT7
|
|
|
|
export EXTRAPORT8
|
|
|
|
export CONTROLPORT
|
|
|
|
|
|
|
|
export LOWPORT
|
|
|
|
export HIGHPORT
|
2017-11-23 09:58:57 +00:00
|
|
|
|
2018-01-25 17:47:33 +00:00
|
|
|
echostart "S:$systest:`date`"
|
2017-12-20 19:08:57 +00:00
|
|
|
echoinfo "T:$systest:1:A"
|
|
|
|
echoinfo "A:$systest:System test $systest"
|
|
|
|
echoinfo "I:$systest:PORTRANGE:${LOWPORT} - ${HIGHPORT}"
|
2000-06-12 20:32:47 +00:00
|
|
|
|
2014-06-13 11:45:08 +10:00
|
|
|
if [ x${PERL:+set} = x ]
|
2000-06-13 19:41:59 +00:00
|
|
|
then
|
2017-12-20 19:08:57 +00:00
|
|
|
echowarn "I:$systest:Perl not available. Skipping test."
|
|
|
|
echowarn "R:$systest:UNTESTED"
|
|
|
|
echoend "E:$systest:`date $dateargs`"
|
2000-06-13 19:41:59 +00:00
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
2017-12-15 19:30:55 +00:00
|
|
|
$PERL testsock.pl -p $PORT || {
|
2017-12-20 19:08:57 +00:00
|
|
|
echowarn "I:$systest:Network interface aliases not set up. Skipping test."
|
|
|
|
echowarn "R:$systest:UNTESTED"
|
|
|
|
echoend "E:$systest:`date $dateargs`"
|
2017-12-15 19:30:55 +00:00
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2000-07-15 00:37:23 +00:00
|
|
|
# Check for test-specific prerequisites.
|
2017-12-20 19:08:57 +00:00
|
|
|
test ! -f $systest/prereq.sh || ( cd $systest && $SHELL prereq.sh "$@" )
|
2010-12-20 21:35:45 +00:00
|
|
|
result=$?
|
|
|
|
|
|
|
|
if [ $result -eq 0 ]; then
|
2000-07-14 23:38:14 +00:00
|
|
|
: prereqs ok
|
|
|
|
else
|
2017-12-20 19:08:57 +00:00
|
|
|
echowarn "I:$systest:Prerequisites missing, skipping test."
|
|
|
|
[ $result -eq 255 ] && echowarn "R:$systest:SKIPPED" || echowarn "R:$systest:UNTESTED"
|
|
|
|
echoend "E:$systest:`date $dateargs`"
|
2000-07-14 23:38:14 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2010-06-07 03:42:37 +00:00
|
|
|
# Check for PKCS#11 support
|
|
|
|
if
|
2017-12-20 19:08:57 +00:00
|
|
|
test ! -f $systest/usepkcs11 || $SHELL cleanpkcs11.sh
|
2010-06-07 03:42:37 +00:00
|
|
|
then
|
|
|
|
: pkcs11 ok
|
|
|
|
else
|
2017-12-20 19:08:57 +00:00
|
|
|
echowarn "I:$systest:Need PKCS#11, skipping test."
|
|
|
|
echowarn "R:$systest:PKCS11ONLY"
|
|
|
|
echoend "E:$systest:`date $dateargs`"
|
2010-06-07 03:42:37 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2000-05-15 22:53:15 +00:00
|
|
|
# Set up any dynamically generated test data
|
2017-12-20 19:08:57 +00:00
|
|
|
if test -f $systest/setup.sh
|
2000-05-15 22:53:15 +00:00
|
|
|
then
|
2017-12-20 19:08:57 +00:00
|
|
|
( cd $systest && $SHELL setup.sh "$@" )
|
2000-05-15 22:53:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Start name servers running
|
2017-12-20 19:08:57 +00:00
|
|
|
$PERL start.pl --port $PORT $systest
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echofail "R:$systest:FAIL"
|
|
|
|
echoend "E:$systest:`date $dateargs`"
|
|
|
|
exit 1
|
|
|
|
fi
|
2000-05-15 22:53:15 +00:00
|
|
|
|
2000-05-16 22:38:06 +00:00
|
|
|
# Run the tests
|
2017-12-20 19:08:57 +00:00
|
|
|
( cd $systest ; $SHELL tests.sh "$@" )
|
2000-05-19 20:46:24 +00:00
|
|
|
status=$?
|
2000-05-16 22:38:06 +00:00
|
|
|
|
2000-06-12 23:48:28 +00:00
|
|
|
if $stopservers
|
2000-06-09 23:16:56 +00:00
|
|
|
then
|
2000-06-12 23:48:28 +00:00
|
|
|
:
|
|
|
|
else
|
2000-06-09 23:16:56 +00:00
|
|
|
exit $status
|
|
|
|
fi
|
|
|
|
|
2000-05-16 22:38:06 +00:00
|
|
|
# Shutdown
|
2017-12-20 19:08:57 +00:00
|
|
|
$PERL stop.pl $systest
|
2000-05-18 22:49:29 +00:00
|
|
|
|
2000-07-05 18:49:06 +00:00
|
|
|
status=`expr $status + $?`
|
|
|
|
|
|
|
|
if [ $status != 0 ]; then
|
2017-12-20 19:08:57 +00:00
|
|
|
echofail "R:$systest:FAIL"
|
2017-12-20 15:50:03 +00:00
|
|
|
# Do not clean up - we need the evidence.
|
|
|
|
find . -name core -exec chmod 0644 '{}' \;
|
2000-07-05 18:49:06 +00:00
|
|
|
else
|
2017-12-20 19:08:57 +00:00
|
|
|
echopass "R:$systest:PASS"
|
2017-10-24 12:45:13 +11:00
|
|
|
if $clean
|
|
|
|
then
|
2017-12-20 19:08:57 +00:00
|
|
|
$SHELL clean.sh $runall $systest "$@"
|
|
|
|
if test -d ../../../.git
|
|
|
|
then
|
|
|
|
git status -su --ignored $systest | \
|
|
|
|
sed -n -e 's|^?? \(.*\)|I:file \1 not removed|p' \
|
|
|
|
-e 's|^!! \(.*/named.run\)$|I:file \1 not removed|p' \
|
|
|
|
-e 's|^!! \(.*/named.memstats\)$|I:file \1 not removed|p'
|
2017-12-15 15:56:33 +00:00
|
|
|
fi
|
2017-10-24 12:45:13 +11:00
|
|
|
fi
|
2000-06-21 01:24:19 +00:00
|
|
|
fi
|
2000-05-18 22:49:29 +00:00
|
|
|
|
2017-12-20 19:08:57 +00:00
|
|
|
echoend "E:$systest:`date $dateargs`"
|
2000-06-12 20:32:47 +00:00
|
|
|
|
2000-05-18 22:49:29 +00:00
|
|
|
exit $status
|