From f169f48f93b12a9b2bce9e8c23fc66e7e3ee8c9e Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 16 Aug 2013 11:19:08 -0400 Subject: [PATCH 1/3] CTestTestMemcheck: Refactor output expectation regex generation Refactor generation of PASS_REGULAR_EXPRESSION for tests CTestTestMemcheckDummyPurify CTestTestMemcheckDummyValgrind CTestTestMemcheckDummyValgrindPrePost CTestTestMemcheckDummyValgrindIgnoreMemcheck Avoid duplicating the normal ctest output matching expression. Use literal newlines instead of "\n" to improve readability. Integrate matching of guard-malloc lines at the end of the output with expressions matching tool output like lines for BullseyeCoverage. --- Tests/CTestTestMemcheck/CMakeLists.txt | 36 +++++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 86d73854b..8a6171051 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -35,14 +35,30 @@ target_link_libraries(memcheck_fail CMakeLib) # same filenames. add_subdirectory(NoLogDummyChecker) -if (APPLE) - # filter out additional messages by Guard Malloc integrated in Xcode - set(GUARD_MALLOC_MSG "(ctest\([0-9]+\) malloc: [^\n]*\n)*") - set(NORMAL_CTEST_OUTPUT "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+\\.[0-9]+ sec\n${GUARD_MALLOC_MSG}\n${GUARD_MALLOC_MSG}100% tests passed, 0 tests failed out of 1\n.*\n-- Processing memory checking output: \n${GUARD_MALLOC_MSG}Memory checking results:\n${GUARD_MALLOC_MSG}") -else () - set(NORMAL_CTEST_OUTPUT "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+\\.[0-9]+ sec\n\n100% tests passed, 0 tests failed out of 1\n.*\n-- Processing memory checking output: \nMemory checking results:\n") -endif () -set(BULLSEYE_MSG "(BullseyeCoverage[^\n]*\n)?") +if(APPLE) + # filter out additional messages by Guard Malloc integrated in Xcode + set(guard_malloc_msg "ctest\([0-9]+\) malloc: ") + set(guard_malloc_lines "(${guard_malloc_msg}[^\n]*\n)*") + set(guard_malloc_output "${guard_malloc_msg}|") +else() + set(guard_malloc_msg "") + set(guard_malloc_lines "") + set(guard_malloc_output "") +endif() + +# When this entire test runs under coverage or memcheck tools +# they may add output to the end, so match known cases: +# - Bullseye adds a "BullseyeCoverage..." line. +set(other_tool_output "((${guard_malloc_output}BullseyeCoverage)[^\n]*\n)*") + +string(REPLACE "\r\n" "\n" ctest_and_tool_outputs " +1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+\\.[0-9]+ sec +${guard_malloc_lines} +100% tests passed, 0 tests failed out of 1 +.* +-- Processing memory checking output:( ) +${guard_malloc_lines}Memory checking results: +${other_tool_output}") function(gen_mc_test_internal NAME CHECKER) set(SUBTEST_NAME "${NAME}") @@ -146,7 +162,7 @@ set_tests_properties(CTestTestMemcheckDummyValgrind CTestTestMemcheckDummyValgrindPrePost CTestTestMemcheckDummyPurify PROPERTIES - PASS_REGULAR_EXPRESSION "${NORMAL_CTEST_OUTPUT}${BULLSEYE_MSG}$") + PASS_REGULAR_EXPRESSION "${ctest_and_tool_outputs}$") foreach (_pp Pre Post) string(TOLOWER ${_pp} _pp_lower) @@ -157,7 +173,7 @@ endforeach () set_tests_properties(CTestTestMemcheckDummyValgrindIgnoreMemcheck PROPERTIES - PASS_REGULAR_EXPRESSION "\n2/2 Test #2: RunCMakeAgain .*${NORMAL_CTEST_OUTPUT}${BULLSEYE_MSG}$") + PASS_REGULAR_EXPRESSION "\n2/2 Test #2: RunCMakeAgain .*${ctest_and_tool_outputs}$") set_tests_properties(CTestTestMemcheckDummyBC PROPERTIES PASS_REGULAR_EXPRESSION "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+.[0-9]+ sec\n\n100% tests passed, 0 tests failed out of 1\n(.*\n)?Error parsing XML in stream at line 1: no element found\n") From 8ea62fdf302e1e499075db50412fbe80b1115fd9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 16 Aug 2013 09:39:52 -0400 Subject: [PATCH 2/3] CTestTestMemcheck: Tolerate trailing "==..." lines from valgrind --- Tests/CTestTestMemcheck/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 8a6171051..d595c9848 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -49,7 +49,8 @@ endif() # When this entire test runs under coverage or memcheck tools # they may add output to the end, so match known cases: # - Bullseye adds a "BullseyeCoverage..." line. -set(other_tool_output "((${guard_malloc_output}BullseyeCoverage)[^\n]*\n)*") +# - Valgrind memcheck may add extra "==..." lines. +set(other_tool_output "((${guard_malloc_output}BullseyeCoverage|==)[^\n]*\n)*") string(REPLACE "\r\n" "\n" ctest_and_tool_outputs " 1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+\\.[0-9]+ sec From e8e67aed224d27c61c690940655ab8495083fca1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Sep 2013 14:46:15 -0400 Subject: [PATCH 3/3] CTestTestMemcheck: Fix matching of malloc debug messages In commit 10bc50ea (Tests: ignore Guard Malloc messages in MemChecker tests, 2013-05-13) we forgot to escape backslashes in the CMake language to get them into the regex. Add them now. --- Tests/CTestTestMemcheck/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index d595c9848..b5162c9a4 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -37,7 +37,7 @@ add_subdirectory(NoLogDummyChecker) if(APPLE) # filter out additional messages by Guard Malloc integrated in Xcode - set(guard_malloc_msg "ctest\([0-9]+\) malloc: ") + set(guard_malloc_msg "ctest\\([0-9]+\\) malloc: ") set(guard_malloc_lines "(${guard_malloc_msg}[^\n]*\n)*") set(guard_malloc_output "${guard_malloc_msg}|") else()