From 2085e0e59a7c1d3d731ad1ffbce4c9434ea9e602 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Sat, 11 Apr 2015 23:26:37 +0200 Subject: Fail memcheck target on leak or memory errors Some unit test were checked using valgrind, but if an error was detected it was only logged: the build was not failed. Fail to build all *MemCheck targets if a leak or an error is reported by valgrind. Signed-off-by: Kevin Rocard --- ctest/CMakeLists.txt | 14 ++++++++++++++ ctest/valgrind.supp | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 ctest/valgrind.supp diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt index 6ee2e10..c8cdbbb 100644 --- a/ctest/CMakeLists.txt +++ b/ctest/CMakeLists.txt @@ -26,6 +26,20 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# Ctest configuration variables must be set BEFORE include(Ctest) + +# Check process children and give detail for each leak +set(MEMORYCHECK_COMMAND_OPTIONS + "${MEMORYCHECK_COMMAND_OPTIONS} --trace-children=yes --leak-check=full") + +# As dash is not used to submit results, there is no way to see valgrind result. +# Force it to log to stderr and fail in case of leak or error. +set(MEMORYCHECK_COMMAND_OPTIONS + "${MEMORYCHECK_COMMAND_OPTIONS} --error-exitcode=255 --log-fd=2") + +# Ignore errors from third-partie libraries +set(MEMORYCHECK_SUPPRESSIONS_FILE "${CMAKE_CURRENT_LIST_DIR}/valgrind.supp") + # Enable tests, coverage, memcheck, ... # See http://www.cmake.org/Wiki/CMake/Testing_With_CTest#Dashboard_Preparation include(CTest) diff --git a/ctest/valgrind.supp b/ctest/valgrind.supp new file mode 100644 index 0000000..1de6188 --- /dev/null +++ b/ctest/valgrind.supp @@ -0,0 +1,11 @@ +# Ignore conditional jump in libz. +# It is fixed in zlib1g v1.2.8 (ubuntu 14.04) +# but not in v1.2.3 (ubuntu 12.04) which travis has. +{ + libz/inflateReset2/jump + Memcheck:Cond + fun:inflateReset2 + fun:inflateInit2_ + obj:/*/libz.so* +} + -- cgit v1.1