From cf53b705a5f9b04a98af466dd1b6460c91ec2057 Mon Sep 17 00:00:00 2001
From: Eric Cano <Eric.Cano@cern.ch>
Date: Thu, 25 Jan 2018 11:32:01 +0100
Subject: [PATCH] Refactored and fixed helgrind options.

---
 CMakeLists.txt | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51226aac4d..122179ad41 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -177,28 +177,31 @@ endif (${COMPILE_PACKAGING} STREQUAL "1")
 
 configure_file(tests/valgrind.suppr tests/valgrind.suppr COPYONLY)
 configure_file(tests/helgrind.suppr tests/helgrind.suppr COPYONLY)
+set(VALGRIND valgrind)
+set(VALGRIND_OPTS --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr)
+set(HELGRIND_OPTS -v --demangle=yes --gen-suppressions=all --num-callers=25 --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr --sim-hints=no-nptl-pthread-stackcache)
 add_custom_target(fullunittests
   tests/cta-unitTests
   COMMAND tests/cta-unitTests-multiProcess
-  COMMAND valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests
-  COMMAND valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --num-callers=25 --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr --sim-hints=no-nptl-pthread-stackcache tests/cta-unitTests
+  COMMAND ${VALGRIND} ${VALGRIND_OPTS} tests/cta-unitTests
+  COMMAND ${VALGRIND} --tool=helgrind ${HELGRIND_OPTS} tests/cta-unitTests
   COMMAND tests/cta-unitTests-multiProcess
-  COMMAND valgrind --track-fds=yes --child-silent-after-fork=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests-multiProcess
-  COMMAND valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --num-callers=25 --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr --sim-hints=no-nptl-pthread-stackcache tests/cta-unitTests-multiProcess
+  COMMAND ${VALGRIND} ${VALGRIND_OPTS} --child-silent-after-fork=yes tests/cta-unitTests-multiProcess
+  COMMAND ${VALGRIND} --tool=helgrind ${HELGRIND_OPTS} tests/cta-unitTests-multiProcess
   
   DEPENDS tests/cta-unitTests tests/cta-unitTests-multiProcess tests/valgrind.suppr tests/helgrind.suppr
   COMMENT "Running unit tests with memory leak and race conditions detection" VERBATIM)
 
 add_custom_target(valgrind
-  valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests
-  COMMAND valgrind --track-fds=yes --child-silent-after-fork=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/cta-unitTests-multiProcess
+  ${VALGRIND} ${VALGRIND_OPTS} tests/cta-unitTests
+  COMMAND ${VALGRIND} ${VALGRIND_OPTS} --child-silent-after-fork=yes tests/cta-unitTests-multiProcess
 
   DEPENDS tests/cta-unitTests tests/cta-unitTests-multiProcess tests/valgrind.suppr
   COMMENT "Running unit tests with memory leak detection" VERBATIM)
 
 add_custom_target(helgrind
-  valgrind --tool=helgrind -v --demangle=yes --gen-suppressions=all --num-callers=25 --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr tests/cta-unitTests --sim-hints=no-nptl-pthread-stackcache
-  COMMAND valgrind --tool=helgrind -v --child-silent-after-fork=yes --demangle=yes --gen-suppressions=all --num-callers=25 --conflict-cache-size=30000000 --error-exitcode=1 --suppressions=tests/helgrind.suppr --sim-hints=no-nptl-pthread-stackcache tests/cta-unitTests-multiProcess
+  ${VALGRIND} --tool=helgrind ${HELGRIND_OPTS} tests/cta-unitTests
+  COMMAND ${VALGRIND} --tool=helgrind ${HELGRIND_OPTS} tests/cta-unitTests-multiProcess
   
   DEPENDS tests/cta-unitTests tests/cta-unitTests-multiProcess tests/helgrind.suppr
   COMMENT "Running unit tests with race conditions detection" VERBATIM)
-- 
GitLab