aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author1138-4EB <1138-4EB@users.noreply.github.com>2019-09-18 20:17:09 +0200
committertgingold <tgingold@users.noreply.github.com>2019-09-18 20:17:09 +0200
commit4a04f914b836c21a6d036f72846f8698d907cf43 (patch)
tree957b1f5fbd295d6abdcb02b09389e669f86117b8
parent1b8c3d64e07584ffcd60f2d13634e6285e3cc7ef (diff)
downloadghdl-4a04f914b836c21a6d036f72846f8698d907cf43.tar.gz
ghdl-4a04f914b836c21a6d036f72846f8698d907cf43.tar.bz2
ghdl-4a04f914b836c21a6d036f72846f8698d907cf43.zip
update testsuite (#928)
* update testsuite/testsuite.sh * deprecate dist/travis/test.sh, use testsuite/testsuite.sh instead
-rwxr-xr-xdist/travis/test.sh126
-rwxr-xr-xdist/travis/travis-ci.sh14
-rwxr-xr-xtestsuite/testsuite.sh191
3 files changed, 170 insertions, 161 deletions
diff --git a/dist/travis/test.sh b/dist/travis/test.sh
deleted file mode 100755
index 07326a235..000000000
--- a/dist/travis/test.sh
+++ /dev/null
@@ -1,126 +0,0 @@
-#! /bin/bash
-
-scriptdir=$(dirname $0)
-
-. "$scriptdir/utils.sh"
-disable_color
-
-echo "$0" "$@"
-
-# Stop in case of error
-set -e
-
-export ISGPL=false
-
-# Transform long options to short ones
-for arg in "$@"; do
- shift
- case "$arg" in
- "--color"|"-color") set -- "$@" "-c";;
- "--gpl"|"-gpl") set -- "$@" "-g";;
- "--synth"|"-synth") set -- "$@" "-s";;
- *) set -- "$@" "$arg"
- esac
-done
-# Parse args
-while getopts ":b:p:cgs" opt; do
- case $opt in
- c) enable_color;;
- g) ISGPL=true;;
- s) ISSYNTH=true;;
- \?) printf "$ANSI_RED[GHDL - test] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2
- exit 1 ;;
- :) printf "$ANSI_RED[GHDL - test] Option -$OPTARG requires an argument. $ANSI_NOCOLOR\n" >&2
- exit 1 ;;
- esac
-done
-
-rm -f test_ok
-
-export ENABLECOLOR
-if [ "x$GHDL" = "x" ]; then
- export GHDL="$prefix/bin/ghdl"
-fi
-cd testsuite
-failures=""
-
-travis_start "tests.sanity" "$ANSI_YELLOW[GHDL - test] sanity $ANSI_NOCOLOR"
-cd sanity
-for d in [0-9]*; do
- cd $d
- if ./testsuite.sh > test.log 2>&1 ; then
- echo "sanity $d: ok"
- # Don't disp log
- else
- printf "${ANSI_RED}sanity $d: failed${ANSI_NOCOLOR}\n"
- cat test.log
- failures="$failures $d"
- fi
- cd ..
- # Stop at the first failure
- [ "$failures" = "" ] || break
-done
-cd ..
-travis_finish "tests.sanity"
-[ "$failures" = "" ] || exit 1
-
-if [ "x$ISGPL" != "xtrue" ]; then
- travis_start "tests.gna" "$ANSI_YELLOW[GHDL - test] gna $ANSI_NOCOLOR"
- cd gna
- dirs=`./testsuite.sh --list-tests`
- for d in $dirs; do
- cd $d
- if ./testsuite.sh > test.log 2>&1 ; then
- echo "gna $d: ok"
- # Don't disp log
- else
- printf "${ANSI_RED}gna $d: failed${ANSI_NOCOLOR}\n"
- cat test.log
- failures="$failures $d"
- fi
- cd ..
- # Stop at the first failure
- [ "$failures" = "" ] || break
- done
- cd ..
- travis_finish "tests.gna"
- [ "$failures" = "" ] || exit 1
-fi
-
-travis_start "tests.vests" "$ANSI_YELLOW[GHDL - test] vests $ANSI_NOCOLOR"
-cd vests
-if ./testsuite.sh > vests.log 2>&1 ; then
- printf "${ANSI_GREEN}Vests is OK$ANSI_NOCOLOR\n"
- wc -l vests.log
-else
- cat vests.log
- printf "${ANSI_RED}Vests failure$ANSI_NOCOLOR\n"
- failures=vests
-fi
-cd ..
-travis_finish "tests.vests"
-[ "$failures" = "" ] || exit 1
-
-if [ "x$ISSYNTH" = "xtrue" ]; then
- travis_start "tests.synth" "$ANSI_YELLOW[GHDL - test] synth $ANSI_NOCOLOR"
- cd synth
- if ./testsuite.sh > synth.log 2>&1 ; then
- printf "${ANSI_GREEN}Synth is OK$ANSI_NOCOLOR\n"
- wc -l synth.log
- else
- cat synth.log
- printf "${ANSI_RED}Synth failure$ANSI_NOCOLOR\n"
- failures="synth"
- fi
- cd ..
- travis_finish "tests.synth"
- [ "$failures" = "" ] || exit 1
-fi
-
-$GHDL --version
-cd ..
-
-#---
-
-echo "[SUCCESSFUL]"
-touch test_ok
diff --git a/dist/travis/travis-ci.sh b/dist/travis/travis-ci.sh
index 60c557572..f5dd73e40 100755
--- a/dist/travis/travis-ci.sh
+++ b/dist/travis/travis-ci.sh
@@ -88,15 +88,23 @@ fi
# Test
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
- bash -c "prefix=$(realpath ./install-mcode) ${scriptdir}/test.sh $BUILD_CMD_OPTS"
+ bash -c "prefix=$(realpath ./install-mcode) ${scriptdir}/../../testsuite/testsuite.sh sanity gna vests"
else
# Build ghdl/ghdl:$GHDL_IMAGE_TAG image
build_img_ghdl
# Run test in docker container
- $RUN "ghdl/ghdl:$GHDL_IMAGE_TAG" bash -c "GHDL=ghdl ${scriptdir}/test.sh $BUILD_CMD_OPTS"
+ tests="sanity"
+ if [ "x$EXTRA" != "xgpl" ]; then
+ tests="$tests gna"
+ fi
+ tests="$tests vests"
+ if [ "x$ISEXTRA" = "xsynth" ]; then
+ tests="$tests synth"
+ fi
+ $RUN "ghdl/ghdl:$GHDL_IMAGE_TAG" bash -c "GHDL=ghdl ${scriptdir}/../../testsuite/testsuite.sh $tests"
fi
-if [ ! -f test_ok ]; then
+if [ ! -f "${scriptdir}/../../testsuite/test_ok" ]; then
printf "$ANSI_RED[TRAVIS] TEST failed $ANSI_NOCOLOR\n"
exit 1
fi
diff --git a/testsuite/testsuite.sh b/testsuite/testsuite.sh
index dd3f9e003..797e733eb 100755
--- a/testsuite/testsuite.sh
+++ b/testsuite/testsuite.sh
@@ -1,62 +1,189 @@
-#! /bin/sh
+#! /bin/bash
# Stop in case of error
set -e
-. ./testenv.sh
+enable_color() {
+ ENABLECOLOR=''
+ ANSI_RED="\033[31m"
+ ANSI_GREEN="\033[32m"
+ ANSI_YELLOW="\033[33m"
+ ANSI_BLUE="\033[34m"
+ ANSI_MAGENTA="\033[35m"
+ ANSI_GRAY="\033[90m"
+ ANSI_CYAN="\033[36;1m"
+ ANSI_DARKCYAN="\033[36m"
+ ANSI_NOCOLOR="\033[0m"
+}
-tests=
+disable_color() { unset ENABLECOLOR ANSI_RED ANSI_GREEN ANSI_YELLOW ANSI_BLUE ANSI_MAGENTA ANSI_CYAN ANSI_DARKCYAN ANSI_NOCOLOR; }
+enable_color
-for opt; do
- case "$opt" in
- [a-z]*) tests="$tests $opt" ;;
- *) echo "$0: unknown option $opt"; exit 2 ;;
- esac
-done
+print_start() {
+ COL="$ANSI_YELLOW"
+ if [ "x$2" != "x" ]; then
+ COL="$2"
+ fi
+ printf "${COL}${1}$ANSI_NOCOLOR\n"
+}
+
+gstart () {
+ print_start "$@"
+}
+gend () {
+ :
+}
+
+[ -n "$CI" ] && {
+ echo "INFO: set 'gstart' and 'gend' for CI"
+ gstart () {
+ printf '::[group]'
+ print_start "$@"
+ SECONDS=0
+ }
+
+ gend () {
+ duration=$SECONDS
+ echo '::[endgroup]'
+ printf "${ANSI_GRAY}took $(($duration / 60)) min $(($duration % 60)) sec.${ANSI_NOCOLOR}\n"
+ }
+} || echo "INFO: not in CI"
-if [ x$tests = x ]; then tests="sanity gna vests"; fi
+#---
+
+do_sanity () {
+ gstart "[GHDL - test] sanity"
+ cd sanity
+
+ for d in [0-9]*; do
+ cd $d
+ if ./testsuite.sh > test.log 2>&1 ; then
+ printf "sanity $d: ${ANSI_GREEN}ok${ANSI_NOCOLOR}\n"
+ # Don't disp log
+ else
+ printf "sanity $d: ${ANSI_RED}failed${ANSI_NOCOLOR}\n"
+ cat test.log
+ failures="$failures $d"
+ fi
+ cd ..
+ # Stop at the first failure
+ [ "$failures" = "" ] || break
+ done
+
+ cd ..
+ gend
+ [ "$failures" = "" ] || exit 1
+}
# The GNA testsuite: regression testsuite using reports/issues from gna.org
-do_gna()
-{
+do_gna () {
+ gstart "[GHDL - test] gna"
cd gna
- ./testsuite.sh
+
+ dirs=`./testsuite.sh --list-tests`
+ for d in $dirs; do
+ cd $d
+ if ./testsuite.sh > test.log 2>&1 ; then
+ printf "gna $d: ${ANSI_GREEN}ok${ANSI_NOCOLOR}\n"
+ # Don't disp log
+ else
+ printf "gna $d: ${ANSI_RED}failed${ANSI_NOCOLOR}\n"
+ cat test.log
+ failures="$failures $d"
+ fi
+ cd ..
+ # Stop at the first failure
+ [ "$failures" = "" ] || break
+ done
+
cd ..
+ gend
+ [ "$failures" = "" ] || exit 1
}
# The VESTS testsuite: compliance testsuite, from: https://github.com/nickg/vests.git 388250486a
-do_vests()
-{
+do_vests () {
+ gstart "[GHDL - test] vests"
cd vests
- ./testsuite.sh
+
+ if ./testsuite.sh > vests.log 2>&1 ; then
+ printf "${ANSI_GREEN}Vests is OK$ANSI_NOCOLOR\n"
+ wc -l vests.log
+ else
+ cat vests.log
+ printf "${ANSI_RED}Vests failure$ANSI_NOCOLOR\n"
+ failures=vests
+ fi
+
cd ..
+ gend
+ [ "$failures" = "" ] || exit 1
}
-do_sanity()
-{
- cd sanity
- ./testsuite.sh
- cd ..
+do_synth () {
+ gstart "[GHDL - test] synth"
+ cd synth
+
+ if ./testsuite.sh > synth.log 2>&1 ; then
+ printf "${ANSI_GREEN}Synth is OK$ANSI_NOCOLOR\n"
+ wc -l synth.log
+ else
+ cat synth.log
+ printf "${ANSI_RED}Synth failure$ANSI_NOCOLOR\n"
+ failures="synth"
+ fi
+
+ cd ..
+ gend
+ [ "$failures" = "" ] || exit 1
}
+#---
+
+if [ "x$GHDL" = "x" ]; then
+ if [ "x$prefix" != "x" ]; then
+ export GHDL="$prefix/bin/ghdl"
+ elif [ "x$(command -v which)" != "x" ]; then
+ export GHDL="$(which ghdl)"
+ else
+ printf "${ANSI_RED}error: GHDL environment variable is not defined${ANSI_NOCOLOR}\n"
+ exit 1
+ fi
+fi
+
+cd $(dirname $0)
+rm -f test_ok
+failures=""
+tests=
+
+for opt; do
+ case "$opt" in
+ [a-z]*) tests="$tests $opt" ;;
+ *) echo "$0: unknown option $opt"; exit 2 ;;
+ esac
+done
+
+if [ "x$tests" = "x" ]; then tests="sanity gna vests synth"; fi
+
+echo "tests: $tests"
+
# Run a testsuite
do_test() {
case $1 in
- gna) do_gna;;
- vests) do_vests;;
- sanity) do_sanity;;
- *)
- echo "$0: test name '$1' is unknown"
- exit 1;;
+ sanity) do_sanity;;
+ gna) do_gna;;
+ vests) do_vests;;
+ synth) do_synth;;
+ *)
+ printf "${ANSI_RED}$0: test name '$1' is unknown${ANSI_NOCOLOR}\n"
+ exit 1;;
esac
}
-
for t in $tests; do do_test $t; done
-echo "$0: Success"
+printf "${ANSI_GREEN}[GHDL - test] SUCCESSFUL${ANSI_NOCOLOR}\n"
+touch test_ok
-echo "GHDL is: $GHDL"
+printf "GHDL is: %s\n\n" "$GHDL"
$GHDL --version
-
-exit 0