From b01e8df7df6a647466246467832a55369a17b33f Mon Sep 17 00:00:00 2001 From: Cedric Bastoul Date: Mon, 13 Jan 2014 13:28:46 +0100 Subject: [PATCH] Add a test_valgrind target for memory check --- test/Makefile.am | 9 +++++++++ test/check_c.sh | 2 +- test/check_fortran.sh | 2 +- test/check_openscop.sh | 2 +- test/check_run.sh | 6 +++--- test/check_special.sh | 2 +- test/check_strided.sh | 2 +- test/checker.sh | 26 +++++++++++++++++--------- 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 3b0f60c..375438a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -298,6 +298,8 @@ valgrind: valgrind $(top_builddir)/cloog$(EXEEXT) $(srcdir)/$$x.cloog ; \ done +valcheck: test_valgrind + CHECKER := "$(srcdir)/checker.sh" TESTS_ENVIRONMENT = \ @@ -317,6 +319,13 @@ TESTS_ENVIRONMENT = \ test_run: generate_test$(EXEEXT) $(TESTS_ENVIRONMENT) $(srcdir)/check_run.sh +test_valgrind: + $(TESTS_ENVIRONMENT) $(srcdir)/check_c.sh valgrind ; \ + $(TESTS_ENVIRONMENT) $(srcdir)/check_fortran.sh valgrind ; \ + $(TESTS_ENVIRONMENT) $(srcdir)/check_strided.sh valgrind ; \ + $(TESTS_ENVIRONMENT) $(srcdir)/check_openscop.sh valgrind ; \ + $(TESTS_ENVIRONMENT) $(srcdir)/check_special.sh valgrind + test_regenerate: $(TESTS_ENVIRONMENT) $(srcdir)/check_c.sh regenerate ; \ $(TESTS_ENVIRONMENT) $(srcdir)/check_fortran.sh regenerate ; \ diff --git a/test/check_c.sh b/test/check_c.sh index 0938837..3df0542 100755 --- a/test/check_c.sh +++ b/test/check_c.sh @@ -35,4 +35,4 @@ # * * # *****************************************************************************/ -$CHECKER "C" "$CLOOGTEST_C" "" "cloog" "c" "0" "${1:-keep}" +$CHECKER "C" "$CLOOGTEST_C" "" "cloog" "c" "${1:-generate}" diff --git a/test/check_fortran.sh b/test/check_fortran.sh index 27cbc14..680b141 100755 --- a/test/check_fortran.sh +++ b/test/check_fortran.sh @@ -35,4 +35,4 @@ # * * # *****************************************************************************/ -$CHECKER "FORTRAN" "$CLOOGTEST_FORTRAN" "" "cloog" "f" "0" "${1:-keep}" +$CHECKER "FORTRAN" "$CLOOGTEST_FORTRAN" "" "cloog" "f" "${1:-generate}" diff --git a/test/check_openscop.sh b/test/check_openscop.sh index 3e943e8..562d521 100755 --- a/test/check_openscop.sh +++ b/test/check_openscop.sh @@ -35,4 +35,4 @@ # * * # *****************************************************************************/ -$CHECKER "OPENSCOP" "$CLOOGTEST_OPENSCOP" "-openscop" "scop" "c" "0" "${1:-keep}" +$CHECKER "OPENSCOP" "$CLOOGTEST_OPENSCOP" "-openscop" "scop" "c" "${1:-generate}" diff --git a/test/check_run.sh b/test/check_run.sh index 279adc3..35faf54 100755 --- a/test/check_run.sh +++ b/test/check_run.sh @@ -44,12 +44,12 @@ special_refactored=`echo "$SPECIAL_OPTIONS" | \ sed "s/#/ /g" | \ sed "s/'//g"` -$CHECKER "RUN C" "$FINITE_CLOOGTEST_C" "" "cloog" "c" "1" "${1:-keep}" +$CHECKER "RUN C" "$FINITE_CLOOGTEST_C" "" "cloog" "c" "run" failedtest=$?; -$CHECKER "RUN SPECIAL" "$special_refactored" "" "cloog" "c" "1" "${1:-keep}" +$CHECKER "RUN SPECIAL" "$special_refactored" "" "cloog" "c" "run" failedtest=`expr $failedtest + $?`; -$CHECKER "RUN SPECIAL -sh 1" "$special_refactored" "-sh 1" "cloog" "c" "1" "${1:-keep}" +$CHECKER "RUN SPECIAL -sh 1" "$special_refactored" "-sh 1" "cloog" "c" "run" failedtest=`expr $failedtest + $?`; return $failedtest; diff --git a/test/check_special.sh b/test/check_special.sh index b392524..7a98781 100755 --- a/test/check_special.sh +++ b/test/check_special.sh @@ -44,4 +44,4 @@ special_refactored=`echo "$SPECIAL_OPTIONS" | \ sed "s/#/ /g" | \ sed "s/'//g"` -$CHECKER "SPECIAL" "$special_refactored" "" "cloog" "c" "0" "${1:-keep}" +$CHECKER "SPECIAL" "$special_refactored" "" "cloog" "c" "${1:-generate}" diff --git a/test/check_strided.sh b/test/check_strided.sh index 8e48d2e..39874c8 100755 --- a/test/check_strided.sh +++ b/test/check_strided.sh @@ -35,4 +35,4 @@ # * * # *****************************************************************************/ -$CHECKER "STRIDED" "$CLOOGTEST_STRIDED" "-strides 1" "cloog" "c" "0" "${1:-keep}" +$CHECKER "STRIDED" "$CLOOGTEST_STRIDED" "-strides 1" "cloog" "c" "${1:-generate}" diff --git a/test/checker.sh b/test/checker.sh index 3fde644..8960d8e 100755 --- a/test/checker.sh +++ b/test/checker.sh @@ -57,12 +57,15 @@ TEST_INPUT_EXTENSION="$4" ## Extension of the input file TEST_OUTPUT_EXTENSION="$5" ## Extension of the generated file -TEST_RUN="$6" ## "1" if the checking policy is to generate, - ## compile and run, generate only otherwise - -TEST_REGENERATE="$7" ## "regenerate" to replace the original file with - ## the generated one in the case of a check fail - ## !!! USE WITH CARE !!! +TEST_TYPE="$6" ## - "generate" to simply test code generation + ## (default) + ## - "regenerate" to replace the original file with + ## the generated one in the case of a check fail + ## !!! USE WITH CARE !!! + ## - "valgrind" to test the valgrind output on + ## code generation + ## - "run" if the checking policy is to generate, + ## compile and run, generate only otherwise failedtest=0; cloog=$top_builddir/cloog$EXEEXT @@ -83,7 +86,7 @@ for x in $TEST_FILES; do echo "(options $options), \c"; fi; - if [ "$TEST_RUN" = "1" ]; then + if [ "$TEST_TYPE" = "run" ]; then generate_test=$srcdir/generate_test$EXEEXT test_run=$srcdir/test_run$EXEEXT good="$srcdir/$name.good.$TEST_OUTPUT_EXTENSION"; @@ -106,12 +109,17 @@ for x in $TEST_FILES; do $test_run; result=$?; rm -f $test_run; + elif [ "$TEST_TYPE" = "valgrind" ]; then + echo "generating..."; + valgrind --leak-check=full --show-reachable=yes --error-exitcode=1 \ + $top_builddir/.libs/cloog$EXEEXT $options -q $input > /dev/null; + result=$?; else echo "generating... \c"; $cloog $options -q $input > cloog_temp; diff -u -w --ignore-matching-lines='CLooG' $output cloog_temp; result=$?; - if [ "$result" -ne "0" ] && [ "$TEST_REGENERATE" = "regenerate" ]; then + if [ "$result" -ne "0" ] && [ "$TEST_TYPE" = "regenerate" ]; then echo -e "\033[31mREGENERATING... \033[0m"; cp cloog_temp $output; fi; @@ -119,7 +127,7 @@ for x in $TEST_FILES; do fi; if [ "$result" -ne "0" ]; then - echo -e "\033[31mFAIL: $output is not the same\033[0m"; + echo -e "\033[31mFAIL: $output has a problem\033[0m"; failedtest=`expr $failedtest + 1`; else echo "PASS"; -- 2.11.4.GIT