From c6af167b6d9b43fe156990b69f06401225725b3b Mon Sep 17 00:00:00 2001 From: Cedric Bastoul Date: Tue, 5 Aug 2014 01:52:10 +0200 Subject: [PATCH] Clean checking system and add valcheck (check with Valgrind) --- Makefile.am | 4 +++ tests/Makefile.am | 91 ++++++++++++++++++++++++++++---------------------- tests/check_fail.sh | 2 +- tests/check_unitary.sh | 2 +- tests/check_working.sh | 2 +- tests/checker.sh | 86 ++++++++++++++++++++++++++++++++++------------- 6 files changed, 121 insertions(+), 66 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4a243fe..6839b4b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -109,9 +109,13 @@ MAINTAINERCLEANFILES = \ $(AUX_DIST) ############################################################################# + dist-hook: (cd $(distdir) && mkdir -p $(ac_aux_dir)) for file in $(AUX_DIST); do \ cp $$file $(distdir)/$$file; \ done ############################################################################# + +valcheck: + $(MAKE) valcheck -C tests diff --git a/tests/Makefile.am b/tests/Makefile.am index 5186f5b..2dd660f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -39,54 +39,65 @@ SUBDIRS = MAINTAINERCLEANFILES = Makefile.in -TESTS_ENVIRONMENT = top_builddir=$(top_builddir) SRCDIR=$(srcdir) - ############################################################################# -check_SCRIPTS = check_unitary.sh check_fail.sh check_working.sh - -EXTRA_DIST = checker.sh - -## Replace by program names when needed -# check_PROGRAMS = ... -TESTS = $(check_SCRIPTS) - UNITARY_TEST_FILES = \ - $(top_srcdir)/tests/unitary/ax-do.c \ - $(top_srcdir)/tests/unitary/can_reorder_loop.c \ - $(top_srcdir)/tests/unitary/gemver.c \ - $(top_srcdir)/tests/unitary/jacobi1d.c \ - $(top_srcdir)/tests/unitary/loulou.c \ - $(top_srcdir)/tests/unitary/lu.c \ - $(top_srcdir)/tests/unitary/matmul.c \ - $(top_srcdir)/tests/unitary/multiscop3.c \ - $(top_srcdir)/tests/unitary/scalpriv.c \ - $(top_srcdir)/tests/unitary/scalexp.c \ - $(top_srcdir)/tests/unitary/simple.c \ - $(top_srcdir)/tests/unitary/swim.c + unitary/ax-do \ + unitary/can_reorder_loop \ + unitary/gemver \ + unitary/jacobi1d \ + unitary/loulou \ + unitary/lu \ + unitary/matmul \ + unitary/multiscop3 \ + unitary/scalpriv \ + unitary/scalexp \ + unitary/simple \ + unitary/swim TRANSFO_FAIL_TEST_FILES = \ - $(top_srcdir)/tests/transformations/must_fail/no_scalren.c + transformations/must_fail/no_scalren TRANSFO_WORKING_TEST_FILES = \ - $(top_srcdir)/tests/transformations/working/can_reorder_loop.c \ - $(top_srcdir)/tests/transformations/working/loulou.c \ - $(top_srcdir)/tests/transformations/working/scalren.c + transformations/working/can_reorder_loop \ + transformations/working/loulou \ + transformations/working/scalren + +TESTS_ENVIRONMENT = \ + top_builddir=$(top_builddir) \ + srcdir=$(srcdir) \ + EXEEXT=$(EXEEXT) \ + CHECKER="$(top_srcdir)/tests/checker.sh" \ + COMPILE="$(COMPILE)" \ + LINK="$(LINK)" \ + UNITARY_TEST_FILES="$(UNITARY_TEST_FILES)" \ + TRANSFO_FAIL_TEST_FILES="$(TRANSFO_FAIL_TEST_FILES)" \ + TRANSFO_WORKING_TEST_FILES="$(TRANSFO_WORKING_TEST_FILES)" -UNITARY_TEST_FILES_REF = $(UNITARY_TEST_FILES:.c=.c.scop) -TRANSFO_FAIL_TEST_FILES_REF = $(TRANSFO_FAIL_TEST_FILES:.c=.c.scop) -TRANSFO_WORKING_TEST_FILES_REF = $(TRANSFO_WORKING_TEST_FILES:.c=.c.scop) +valcheck: + $(TESTS_ENVIRONMENT) $(srcdir)/check_unitary.sh valgrind ; \ + $(TESTS_ENVIRONMENT) $(srcdir)/check_working.sh valgrind ; \ + $(TESTS_ENVIRONMENT) $(srcdir)/check_fail.sh valgrind -EXTRA_DIST += \ - $(UNITARY_TEST_FILES) \ - $(TRANSFO_FAIL_TEST_FILES) \ - $(TRANSFO_WORKING_TEST_FILES) \ - $(check_SCRIPTS) +check_SCRIPTS = \ + check_unitary.sh \ + check_fail.sh \ + check_working.sh -CLEANFILES = "" +## Replace by program names when needed +# check_PROGRAMS = ... -TESTS_ENVIRONMENT += \ - CHECKER="$(top_srcdir)/tests/checker.sh" \ - UNITARY_TEST_FILES="$(UNITARY_TEST_FILES)" \ - TRANSFO_FAIL_TEST_FILES="$(TRANSFO_FAIL_TEST_FILES)" \ - TRANSFO_WORKING_TEST_FILES="$(TRANSFO_WORKING_TEST_FILES)" +TESTS = $(check_SCRIPTS) + +EXTRA_DIST = \ + $(check_SCRIPTS) \ + $(srcdir)/checker.sh \ + $(UNITARY_TEST_FILES:%=%.c) \ + $(UNITARY_TEST_FILES:%=%.c.struct) \ + $(UNITARY_TEST_FILES:%=%.c.orig.scop) \ + $(TRANSFO_FAIL_TEST_FILES:%=%.c) \ + $(TRANSFO_FAIL_TEST_FILES:%=%.c.struct) \ + $(TRANSFO_FAIL_TEST_FILES:%=%.c.orig.scop) \ + $(TRANSFO_WORKING_TEST_FILES:%=%.c) \ + $(TRANSFO_WORKING_TEST_FILES:%=%.c.struct) \ + $(TRANSFO_WORKING_TEST_FILES:%=%.c.orig.scop) diff --git a/tests/check_fail.sh b/tests/check_fail.sh index f97fd60..9ee6e0f 100755 --- a/tests/check_fail.sh +++ b/tests/check_fail.sh @@ -34,4 +34,4 @@ # * * # *****************************************************************************/ -./$CHECKER "Transformations fail tests" "$TRANSFO_FAIL_TEST_FILES" 1 +$CHECKER "Failing Transformations" "$TRANSFO_FAIL_TEST_FILES" 1 "${1:-candl}" diff --git a/tests/check_unitary.sh b/tests/check_unitary.sh index 25dabe5..d353d0b 100755 --- a/tests/check_unitary.sh +++ b/tests/check_unitary.sh @@ -33,4 +33,4 @@ # * * # *****************************************************************************/ -./$CHECKER "Unitary tests" "$UNITARY_TEST_FILES" 0 +$CHECKER "Unitary Tests" "$UNITARY_TEST_FILES" 0 "${1:-candl}" diff --git a/tests/check_working.sh b/tests/check_working.sh index 7b813b9..7a9b560 100755 --- a/tests/check_working.sh +++ b/tests/check_working.sh @@ -29,4 +29,4 @@ # * * # *****************************************************************************/ -./$CHECKER "Transformations working tests" "$TRANSFO_WORKING_TEST_FILES" 1 +$CHECKER "Working Transformations" "$TRANSFO_WORKING_TEST_FILES" 1 "${1:-candl}" diff --git a/tests/checker.sh b/tests/checker.sh index 9c9c7e2..84e1cd1 100755 --- a/tests/checker.sh +++ b/tests/checker.sh @@ -34,40 +34,80 @@ # * * # *****************************************************************************/ -STRING=$1 -FILES=$2 -TRANSFO=$3 +TEST_NAME="$1" ## Name of the group of files to test -set -x verbose #echo on +TEST_FILES="$2" ## List of test file prefixes and individual options -echo "$STRING" +TEST_TRANSFO="$3" ## Booelan set to 1 if the test is about checking a + ## transformation, 0 if it is a dependence analysis -for name in $FILES; do - echo "check $name \c" +TEST_TYPE="$4" ## - "candl" to simply test candl (default) + ## - "valgrind" to test the valgrind output - orig_scop="$name.orig.scop" - struct="$name.struct" - clay_scop="$name.clay.scop" # only for transformations tests +# Uncomment the following line to print the test script +#set -x verbose #echo on - # read candl options - candloptions=`grep "candl options" "$name" | cut -d'|' -f2` +candl=$top_builddir/candl$EXEEXT + +echo " /*-----------------------------------------------*" +echo " * Testing Candl: $TEST_NAME" +echo " *-----------------------------------------------*/" + +for name in $TEST_FILES; do - case $TRANSFO in - 0) - ../candl $candloptions "$orig_scop" -struct | grep -v "enerated by" > /tmp/candl_struct - ;; - 1) - ../candl $candloptions "$clay_scop" -test "$orig_scop" -struct | grep -v "enerated by" >/tmp/candl_struct - ;; - esac + orig_scop="$name.c.orig.scop" + struct="$name.c.struct" + clay_scop="$name.c.clay.scop" # only for transformations tests + + # read candl options + options=`grep "candl options" "$name.c" | cut -d'|' -f2` - n=`diff /tmp/candl_struct "$struct" | wc -l` - if [ $n -ne 0 ]; then + if [ "$TEST_TYPE" = "candl" ]; then + echo "check $name \c" + case $TEST_TRANSFO in + 0) + $candl $options "$orig_scop" -struct | grep -v "enerated by" > candl_temp + ;; + 1) + $candl $options "$clay_scop" -test "$orig_scop" -struct | grep -v "enerated by" > candl_temp + ;; + esac + + result=`diff candl_temp "$struct" | wc -l` + else + echo "valcheck $name \c" + case $TEST_TRANSFO in + 0) + libtool --mode=execute valgrind --error-exitcode=1 \ + $candl $options "$orig_scop" -struct > /dev/null 2> candl_temp; + ;; + 1) + libtool --mode=execute valgrind --error-exitcode=1 \ + $candl $options "$clay_scop" -test "$orig_scop" -struct > /dev/null 2> candl_temp; + ;; + esac + + errors=$?; + leaks=`grep "in use at exit" candl_temp | cut -f 2 -d ':'` + if [ "$errors" = "1" ]; then + echo -e "\033[31mMemory error detected... \033[0m"; + cat candl_temp; + result="1"; + elif [ "$leaks" != " 0 bytes in 0 blocks" ]; then + echo -e "\033[31mMemory leak detected... \033[0m"; + cat candl_temp; + result="1"; + else + result="0"; + fi; + fi + + if [ $result -ne 0 ]; then echo "\033[31m[ FAIL ]\033[0m" else echo "\033[32m[ OK ]\033[0m" fi - rm -f /tmp/candl_struct + rm -f candl_temp done exit $n -- 2.11.4.GIT