From 86a39d35d1dff6f4ffe85cf81b775d31acc3763f Mon Sep 17 00:00:00 2001
From: Daniel Arndt
Date: Sun, 11 Mar 2018 17:02:40 +0100
Subject: [PATCH] Allow to run the testsuite with valgrind
---
doc/developers/testsuite.html | 27 ++++++++++++++
doc/news/changes/minor/20180311DanielArndt | 4 +++
tests/run_testsuite.cmake | 42 ++++++++++++++++++++--
3 files changed, 71 insertions(+), 2 deletions(-)
create mode 100644 doc/news/changes/minor/20180311DanielArndt
diff --git a/doc/developers/testsuite.html b/doc/developers/testsuite.html
index 7d8c625570..b9938d31f9 100644
--- a/doc/developers/testsuite.html
+++ b/doc/developers/testsuite.html
@@ -292,6 +292,33 @@ xx: =============================== OUTPUT END ============================
+
+ Running with valgrind
+
+
+ The testsuite can also be run using valgrind
+ to check for memory corruption in the library.
+
+
+
+ You can do so by invoking
+
+ ctest -DMEMORYCHECK=ON <...> -S ../tests/run_testsuite.cmake
+
+ when running the testsuite, or directly by
+
+ ctest <...> -S ../tests/run_memorycheck.cmake
+
+
+
+
+ At the end of all of this, results will be shown in a separate section
+ "Dynamic Analysis" at the
+ deal.II cdash site.
+
+
+
Generating coverage information
diff --git a/doc/news/changes/minor/20180311DanielArndt b/doc/news/changes/minor/20180311DanielArndt
new file mode 100644
index 0000000000..ea1cdbaa89
--- /dev/null
+++ b/doc/news/changes/minor/20180311DanielArndt
@@ -0,0 +1,4 @@
+New: The testsuite can be run using valgrind via
+'ctest -S ../tests/run_memorycheck.cmake'.
+
+(Daniel Arndt, 2018/03/11)
diff --git a/tests/run_testsuite.cmake b/tests/run_testsuite.cmake
index 6c1b827fd1..d23239128f 100644
--- a/tests/run_testsuite.cmake
+++ b/tests/run_testsuite.cmake
@@ -81,6 +81,10 @@
# CTEST_COVERAGE() stage will be run. Test results must go into the
# "Experimental" section.
#
+# MEMORYCHECK
+# - If set to ON the CTEST_MEMORYCHECK() stage will be run.
+# Test results must go into the "Experimantal" section.
+#
# MAKEOPTS
# - Additional options that will be passed directly to make (or ninja).
#
@@ -424,6 +428,35 @@ ENDIF()
MESSAGE("-- COVERAGE: ${COVERAGE}")
+#
+# Setup memcheck:
+#
+
+IF(MEMORYCHECK)
+ IF(NOT TRACK MATCHES "Experimental")
+ MESSAGE(FATAL_ERROR "
+TRACK must be set to \"Experimental\" if Memcheck is enabled via
+MEMORYCHECK=TRUE.
+"
+ )
+ ENDIF()
+
+ FIND_PROGRAM(MEMORYCHECK_COMMAND NAMES valgrind)
+ IF(MEMORYCOMMAND MATCHES "-NOTFOUND")
+ MESSAGE(FATAL_ERROR "
+Memcheck enabled but could not find the valgrind executable. Please install
+valgrind.
+"
+ )
+ ENDIF()
+
+ SET(CTEST_MEMORYCHECK_COMMAND "${MEMORYCHECK_COMMAND}")
+ENDIF()
+
+MESSAGE("-- MEMORYCHECK: ${MEMORYCHECK}")
+
+
+
MACRO(CREATE_TARGETDIRECTORIES_TXT)
#
# It gets tricky: Fake a TargetDirectories.txt containing _all_ target
@@ -494,11 +527,16 @@ IF("${_res}" STREQUAL "0")
)
ENDIF()
- MESSAGE("-- Running CTEST_TESTS()")
IF(DEAL_II_MSVC)
SET(CTEST_BUILD_CONFIGURATION "${JOB_BUILD_CONFIGURATION}")
ENDIF()
- CTEST_TEST()
+ IF(MEMORYCHECK)
+ MESSAGE("-- Running CTEST_MEMCHECK()")
+ CTEST_MEMCHECK()
+ ELSE()
+ MESSAGE("-- Running CTEST_TESTS()")
+ CTEST_TEST()
+ ENDIF(MEMORYCHECK)
IF(COVERAGE)
CREATE_TARGETDIRECTORIES_TXT()
--
2.39.5