From 443277708bfec65a2c36a970148559fe04a67b5e Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Mon, 2 Nov 2015 18:29:45 -0500 Subject: [PATCH] fix CuTest exit code; add valgrind support --- CMakeLists.txt | 6 ++++++ test/make-tests.sh | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f91104..8e1797b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,12 @@ if (DEFINED TEST) add_test( test ${PROJECT_BINARY_DIR}/run_tests) + # valgrind memory testing + find_program (MEMORYCHECK_COMMAND valgrind) + SET (MEMORYCHECK_COMMAND_OPTIONS --leak-check=full --error-exitcode=1) + + add_test( memory_test ${MEMORYCHECK_COMMAND} ${MEMORYCHECK_COMMAND_OPTIONS} ${PROJECT_BINARY_DIR}/run_tests) + endif() diff --git a/test/make-tests.sh b/test/make-tests.sh index 9d41dab..9010226 100644 --- a/test/make-tests.sh +++ b/test/make-tests.sh @@ -5,6 +5,8 @@ # Prints to stdout. # Author: Asim Jalis # Date: 01/08/2003 +# +# Modified by Fletcher T. Penney for proper error codes if test $# -eq 0 ; then FILES=*.c ; else FILES=$* ; fi @@ -30,6 +32,7 @@ void RunAllTests(void) { CuString *output = CuStringNew(); CuSuite* suite = CuSuiteNew(); + int failCount = 0; ' cat $FILES | grep '^void Test' | @@ -45,7 +48,12 @@ echo \ CuSuiteDetails(suite, output); printf("%s\\n", output->buffer); CuStringDelete(output); + + failCount = suite->failCount; CuSuiteDelete(suite); + + if (failCount != 0) + exit(EXIT_FAILURE); } int main(void) -- 2.40.0