bind9/bin/tests/system/runall.sh
Michał Kępień fed397c04b Fix system test error reporting on Windows
Make sure the CYGWIN environment variable is set whenever system tests
are run on Windows to prevent stop.pl from making incorrect assumptions
about the environment it is running in, which triggers e.g. false
reports about named instances crashing on shutdown when system tests are
run on Windows.  This issue has not been caught earlier because the
CYGWIN environment variable was incidentally being set on a higher level
in our Windows test environments.

Error reporting for parallel system tests on Windows has been broken all
along: since all parallel.mk targets generated by parallel.sh pipe their
output through "tee", the return code from run.sh is lost and thus
running "make -f parallel.mk check" will not yield a non-zero return
code if some system tests fail.  The same applies to runsequential.sh.
Yet, runall.sh on Windows only sets its return code to a non-zero value
if either "make -f parallel.mk check" or runsequential.sh returns a
non-zero return code.  Fix by making runall.sh yield a non-zero return
code when testsummary.sh fails, which is the same approach as the one
used in the "test" target in bin/tests/system/Makefile.
2019-09-26 15:11:15 +02:00

105 lines
2.9 KiB
Bash
Executable file

#!/bin/sh
#
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# 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/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
# Run all the system tests.
#
# Usage:
# runall.sh [-c] [-n] [numprocesses]
#
# -c Force colored output.
#
# -n Noclean. Keep all output files produced by all tests. These
# can later be removed by running "cleanall.sh".
#
# numprocess Number of concurrent processes to use when running the tests.
# The default is one, which causes the tests to run sequentially.
# (This is ignored when running on Windows as the tests are always
# run sequentially on that platform.)
SYSTEMTESTTOP=.
. $SYSTEMTESTTOP/conf.sh
usage="Usage: ./runall.sh [-c] [-n] [numprocesses]"
# Preserve values of environment variables which are already set.
SYSTEMTEST_FORCE_COLOR=${SYSTEMTEST_FORCE_COLOR:-0}
SYSTEMTEST_NO_CLEAN=${SYSTEMTEST_NO_CLEAN:-0}
# Handle command line switches if present.
while getopts "cn" flag; do
case "$flag" in
c) SYSTEMTEST_FORCE_COLOR=1 ;;
n) SYSTEMTEST_NO_CLEAN=1 ;;
esac
done
export NOCLEAN
shift `expr $OPTIND - 1`
# Obtain number of processes to use.
if [ $# -eq 0 ]; then
numproc=1
elif [ $# -eq 1 ]; then
test "$1" -eq "$1" > /dev/null 2>&1
if [ $? -ne 0 ]; then
# Value passed is not numeric
echo "$usage" >&2
exit 1
fi
numproc=$1
else
echo "$usage" >&2
exit 1
fi
# Run the tests.
export SYSTEMTEST_FORCE_COLOR
export SYSTEMTEST_NO_CLEAN
status=0
if [ "$NOPARALLEL" = "" ]; then
if [ "$CYGWIN" = "" ]; then
# Running on Unix, use "make" to run tests in parallel.
make -j $numproc check
status=$?
else
# Running on Windows: Cygwin "make" is available, but isn't being
# used for the build. So we create a special makefile for the purpose
# of parallel execution of system tests, and use that.
$SHELL parallel.sh > parallel.mk
make -f parallel.mk -j $numproc check
$SHELL ./runsequential.sh -r
$SHELL ./testsummary.sh || status=1
fi
else
# the NOPARALLEL environment variable indicates that tests must be
# run sequentially.
$PERL testsock.pl || {
cat <<-EOF
I:NOTE: System tests were skipped because they require the
I: test IP addresses 10.53.0.* to be configured as alias
I: addresses on the loopback interface. Please run
I: "bin/tests/system/ifconfig.sh up" as root to configure them.
EOF
exit 1
}
{
for testdir in $SUBDIRS; do
$SHELL run.sh $testdir || status=1
done
} 2>&1 | tee "systests.output"
fi
exit $status