From e5e4f82e065abcfbfb466ca65f0adfff0c1080e4 Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 18 Jan 2021 01:44:49 +0100 Subject: testsuite: add suite_driver.sh --- testsuite/gna/testsuite.sh | 50 +--------------- testsuite/sanity/testsuite.sh | 42 +------------ testsuite/suite_driver.sh | 61 +++++++++++++++++++ testsuite/synth/testsuite.sh | 50 +--------------- testsuite/testsuite.sh | 133 ++++++++---------------------------------- testsuite/vpi/testsuite.sh | 50 +--------------- 6 files changed, 89 insertions(+), 297 deletions(-) mode change 100755 => 100644 testsuite/gna/testsuite.sh create mode 100755 testsuite/suite_driver.sh (limited to 'testsuite') diff --git a/testsuite/gna/testsuite.sh b/testsuite/gna/testsuite.sh old mode 100755 new mode 100644 index 12b367f2c..ebf84842b --- a/testsuite/gna/testsuite.sh +++ b/testsuite/gna/testsuite.sh @@ -1,53 +1,5 @@ #! /bin/sh -# Driver for a testsuite. - set -e -# This is the only place where test dirs are specified. Do not duplicate this -# line -dirs="*[0-9]" - -failures="" -full=n - -for opt; do - case "$opt" in - -k | --keep-going) full=y ;; - --dir=*) dirs=`echo $opt | sed -e 's/--dir=//'` ;; - --skip=*) d=`echo $opt | sed -e 's/--skip=//'` - dirs=`echo "" $dirs | sed -e "s/ $d//"` ;; - --start-at=*) d=`echo $opt | sed -e 's/--start-at=//'` - dirs=`echo "" $dirs | sed -e "s/^.* $d//"` - dirs="$d $dirs" ;; - --list-tests) echo $dirs; exit 0;; - *) echo "Unknown option $opt" - exit 2 - ;; - esac -done - -singlerun() { - echo "" - echo "dir $1:" - cd $1 - if ! ./testsuite.sh; then - echo "#################################################################" - echo "######### FAILURE: $1" - echo "#################################################################" - if [ $2 = "y" ]; then - failures="$failures $1" - else - exit 1; - fi - fi - cd .. -} - -for i in $dirs; do singlerun $i $full; done - -if [ x"$failures" = x"" ]; then - echo "tests are successful" && exit 0 -else - echo "test failed ($failures)" && exit 1 -fi +`dirname $0`/../suite_driver.sh gna $@ diff --git a/testsuite/sanity/testsuite.sh b/testsuite/sanity/testsuite.sh index 96150da88..54d265d37 100755 --- a/testsuite/sanity/testsuite.sh +++ b/testsuite/sanity/testsuite.sh @@ -1,45 +1,5 @@ #! /bin/sh -# Driver for sanity checks - set -e -dirs="[0-9]*" - -failures="" -full=n - -for opt; do - case "$opt" in - -k | --keep-going) full=y ;; - --list-tests) echo $dirs; exit 0;; - *) echo "Unknown option $opt" - exit 2 - ;; - esac -done - -singlerun() { - echo "" - echo "sanity $1:" - cd $1 - if ! ./testsuite.sh; then - echo "#################################################################" - echo "######### FAILURE: $1" - echo "#################################################################" - if [ $2 = "y" ]; then - failures="$failures $1" - else - exit 1; - fi - fi - cd .. -} - -for i in $dirs; do singlerun $i $full; done - -if [ x"$failures" = x"" ]; then - echo "sanity tests are successful" && exit 0 -else - echo "sanity test failed ($failures)" && exit 1 -fi +`dirname $0`/../suite_driver.sh sanity $@ diff --git a/testsuite/suite_driver.sh b/testsuite/suite_driver.sh new file mode 100755 index 000000000..748961634 --- /dev/null +++ b/testsuite/suite_driver.sh @@ -0,0 +1,61 @@ +#! /bin/sh + +# Driver for a testsuite +# The first positional argument is required, it's the name of the suite to be executed + +set -e + +ANSI_GREEN="\033[32m" +ANSI_RED="\033[31m" +ANSI_NOCOLOR="\033[0m" + +_suite="$1" +shift + +# This is the only place where test dirs are specified. +#Do not duplicate this line +dirs="*[0-9]" + +failures="" +full=n + +for opt; do + case "$opt" in + -k | --keep-going) full=y ;; + --dir=*) dirs=`echo $opt | sed -e 's/--dir=//'` ;; + --skip=*) d=`echo $opt | sed -e 's/--skip=//'` + dirs=`echo "" $dirs | sed -e "s/ $d//"` ;; + --start-at=*) d=`echo $opt | sed -e 's/--start-at=//'` + dirs=`echo "" $dirs | sed -e "s/^.* $d//"` + dirs="$d $dirs" ;; + --list-tests) echo $dirs; exit 0;; + *) echo "Unknown option $opt" + exit 2 + ;; + esac +done + +singlerun() { + cd $1 + if ./testsuite.sh > test.log 2>&1 ; then + printf "$_suite $1: ${ANSI_GREEN}ok${ANSI_NOCOLOR}\n" + # Don't disp log + else + printf "$_suite $1: ${ANSI_RED}failed${ANSI_NOCOLOR}\n" + cat test.log + if [ $2 = "y" ]; then + failures="$failures $1" + else + exit 1; + fi + fi + cd .. +} + +for i in $dirs; do singlerun $i $full; done + +if [ x"$failures" = x"" ]; then + echo "$_suite tests are successful" && exit 0 +else + echo "$_suite test failed ($failures)" && exit 1 +fi diff --git a/testsuite/synth/testsuite.sh b/testsuite/synth/testsuite.sh index 12b367f2c..76e3a7a32 100755 --- a/testsuite/synth/testsuite.sh +++ b/testsuite/synth/testsuite.sh @@ -1,53 +1,5 @@ #! /bin/sh -# Driver for a testsuite. - set -e -# This is the only place where test dirs are specified. Do not duplicate this -# line -dirs="*[0-9]" - -failures="" -full=n - -for opt; do - case "$opt" in - -k | --keep-going) full=y ;; - --dir=*) dirs=`echo $opt | sed -e 's/--dir=//'` ;; - --skip=*) d=`echo $opt | sed -e 's/--skip=//'` - dirs=`echo "" $dirs | sed -e "s/ $d//"` ;; - --start-at=*) d=`echo $opt | sed -e 's/--start-at=//'` - dirs=`echo "" $dirs | sed -e "s/^.* $d//"` - dirs="$d $dirs" ;; - --list-tests) echo $dirs; exit 0;; - *) echo "Unknown option $opt" - exit 2 - ;; - esac -done - -singlerun() { - echo "" - echo "dir $1:" - cd $1 - if ! ./testsuite.sh; then - echo "#################################################################" - echo "######### FAILURE: $1" - echo "#################################################################" - if [ $2 = "y" ]; then - failures="$failures $1" - else - exit 1; - fi - fi - cd .. -} - -for i in $dirs; do singlerun $i $full; done - -if [ x"$failures" = x"" ]; then - echo "tests are successful" && exit 0 -else - echo "test failed ($failures)" && exit 1 -fi +`dirname $0`/../suite_driver.sh synth $@ diff --git a/testsuite/testsuite.sh b/testsuite/testsuite.sh index 651c82012..d24fa884d 100755 --- a/testsuite/testsuite.sh +++ b/testsuite/testsuite.sh @@ -88,65 +88,8 @@ 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 and from GitHub -do_gna () { - gstart "[GHDL - test] gna" - cd gna - - 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 Python Unit testsuite: regression testsuite for Python bindings to libghdl -do_pyunit () { - gstart "[GHDL - test] pyunit" - PYTHONPATH=$(pwd)/.. python3 -m pytest -rA pyunit - gend -} - # The VESTS testsuite: compliance testsuite, from: https://github.com/nickg/vests.git 388250486a -do_vests () { +_vests () { gstart "[GHDL - test] vests" cd vests @@ -164,50 +107,6 @@ do_vests () { [ "$failures" = "" ] || exit 1 } -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 -} - -#--- - -do_vpi () { - gstart "[GHDL - test] vpi" - cd vpi - - for d in *[0-9]; do - cd $d - if ./testsuite.sh > test.log 2>&1 ; then - printf "vpi $d: ${ANSI_GREEN}ok${ANSI_NOCOLOR}\n" - # Don't disp log - else - printf "vpi $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 -} - #--- if [ "x$GHDL" = "x" ]; then @@ -227,25 +126,41 @@ failures="" tests= for opt; do + shift case "$opt" in [a-z]*) tests="$tests $opt" ;; + --) break ;; *) echo "$0: unknown option $opt"; exit 2 ;; esac done if [ "x$tests" = "x" ]; then tests="sanity pyunit gna vests synth vpi"; fi -echo "tests: $tests" +echo "> tests: $tests" +echo "> args: $@" # Run a testsuite do_test() { case $1 in - sanity) do_sanity;; - pyunit) do_pyunit;; - gna) do_gna;; - vests) do_vests;; - synth) do_synth;; - vpi) do_vpi;; + sanity|gna|synth|vpi) + gstart "[GHDL - test] $1" + cd $1 + ../suite_driver.sh $@ + cd .. + gend + [ "$failures" = "" ] || exit 1 + ;; + + pyunit) + # The Python Unit testsuite: regression testsuite for Python bindings to libghdl + gstart "[GHDL - test] pyunit" + PYTHONPATH=$(pwd)/.. python3 -m pytest -rA pyunit + gend + ;; + + vests) + _vests + ;; *) printf "${ANSI_RED}$0: test name '$1' is unknown${ANSI_NOCOLOR}\n" exit 1;; diff --git a/testsuite/vpi/testsuite.sh b/testsuite/vpi/testsuite.sh index 12b367f2c..ec4b5655e 100755 --- a/testsuite/vpi/testsuite.sh +++ b/testsuite/vpi/testsuite.sh @@ -1,53 +1,5 @@ #! /bin/sh -# Driver for a testsuite. - set -e -# This is the only place where test dirs are specified. Do not duplicate this -# line -dirs="*[0-9]" - -failures="" -full=n - -for opt; do - case "$opt" in - -k | --keep-going) full=y ;; - --dir=*) dirs=`echo $opt | sed -e 's/--dir=//'` ;; - --skip=*) d=`echo $opt | sed -e 's/--skip=//'` - dirs=`echo "" $dirs | sed -e "s/ $d//"` ;; - --start-at=*) d=`echo $opt | sed -e 's/--start-at=//'` - dirs=`echo "" $dirs | sed -e "s/^.* $d//"` - dirs="$d $dirs" ;; - --list-tests) echo $dirs; exit 0;; - *) echo "Unknown option $opt" - exit 2 - ;; - esac -done - -singlerun() { - echo "" - echo "dir $1:" - cd $1 - if ! ./testsuite.sh; then - echo "#################################################################" - echo "######### FAILURE: $1" - echo "#################################################################" - if [ $2 = "y" ]; then - failures="$failures $1" - else - exit 1; - fi - fi - cd .. -} - -for i in $dirs; do singlerun $i $full; done - -if [ x"$failures" = x"" ]; then - echo "tests are successful" && exit 0 -else - echo "test failed ($failures)" && exit 1 -fi +`dirname $0`/../suite_driver.sh vpi $@ -- cgit v1.2.3