2017-03-27 12:39:29 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Run integration tests
|
|
|
|
#
|
|
|
|
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
|
|
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
2017-04-27 13:08:17 +02:00
|
|
|
# @license GNU General Public License (version 3)
|
|
|
|
#
|
|
|
|
# VILLASnode
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# any later version.
|
2017-05-05 19:24:16 +00:00
|
|
|
#
|
2017-04-27 13:08:17 +02:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2017-05-05 19:24:16 +00:00
|
|
|
#
|
2017-04-27 13:08:17 +02:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-03-27 12:39:29 +02:00
|
|
|
##################################################################################
|
|
|
|
|
|
|
|
SCRIPT=$(realpath ${BASH_SOURCE[0]})
|
|
|
|
SCRIPTPATH=$(dirname $SCRIPT)
|
|
|
|
|
|
|
|
export SRCDIR=$(realpath ${SCRIPTPATH}/..)
|
|
|
|
export BUILDDIR=${SRCDIR}/build/release
|
|
|
|
export LOGDIR=${BUILDDIR}/tests/integration
|
|
|
|
export PATH=${BUILDDIR}:${PATH}
|
|
|
|
|
|
|
|
# Default values
|
|
|
|
VERBOSE=0
|
|
|
|
FILTER='*'
|
|
|
|
|
|
|
|
export NUM_SAMPLES=100
|
|
|
|
|
|
|
|
# Parse command line arguments
|
|
|
|
while getopts ":f:v" OPT; do
|
|
|
|
case ${OPT} in
|
|
|
|
f)
|
|
|
|
FILTER=${OPTARG}
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
VERBOSE=1
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid option: -${OPTARG}" >&2
|
|
|
|
;;
|
|
|
|
:)
|
|
|
|
echo "Option -$OPTARG requires an argument." >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
TESTS=${SRCDIR}/tests/integration/${FILTER}.sh
|
|
|
|
|
|
|
|
# Preperations
|
|
|
|
mkdir -p ${LOGDIR}
|
|
|
|
|
|
|
|
NUM_PASS=0
|
|
|
|
NUM_FAIL=0
|
|
|
|
|
|
|
|
# Preamble
|
|
|
|
echo -e "Starting integration tests for VILLASnode/fpga:\n"
|
|
|
|
|
|
|
|
for TEST in ${TESTS}; do
|
|
|
|
TESTNAME=$(basename -s .sh ${TEST})
|
|
|
|
|
|
|
|
# Run test
|
|
|
|
if (( ${VERBOSE} == 0 )); then
|
|
|
|
${TEST} &> ${LOGDIR}/${TESTNAME}.log
|
|
|
|
else
|
|
|
|
${TEST}
|
|
|
|
fi
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-03-27 12:39:29 +02:00
|
|
|
RC=$?
|
|
|
|
|
2017-06-09 16:08:45 +02:00
|
|
|
case $RC in
|
|
|
|
0)
|
|
|
|
echo -e "\e[32m[Pass] \e[39m ${TESTNAME}"
|
|
|
|
NUM_PASS=$((${NUM_PASS} + 1))
|
|
|
|
;;
|
|
|
|
99)
|
|
|
|
echo -e "\e[93m[Skip] \e[39m ${TESTNAME}"
|
|
|
|
NUM_SKIP=$((${NUM_SKIP} + 1))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo -e "\e[31m[Fail] \e[39m ${TESTNAME} with code $RC"
|
|
|
|
NUM_FAIL=$((${NUM_FAIL} + 1))
|
|
|
|
;;
|
|
|
|
esac
|
2017-03-27 12:39:29 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# Show summary
|
|
|
|
if (( ${NUM_FAIL} > 0 )); then
|
|
|
|
echo -e "\nSummary: ${NUM_FAIL} of $((${NUM_FAIL} + ${NUM_PASS})) tests failed."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo -e "\nSummary: all tests passed!"
|
|
|
|
exit 0
|
|
|
|
fi
|