Tests: Move CTestTestMemcheck cases into a RunCMake.CTestMemcheck test

The CTestTestMemcheck test cases all try to check the ctest output with
a regular expression.  They fail intermittently due to ordering of the
portions of the output that come from stdout and stderr being mixed.
Convert all the test cases to use the RunCMake infrastructure to match
stdout and stderr separately.
This commit is contained in:
Brad King 2014-12-16 13:50:30 -05:00
parent 1c8129795a
commit 1651dc9668
71 changed files with 311 additions and 256 deletions

View File

@ -1,13 +1,3 @@
REGEX_ESCAPE_STRING(CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
get_filename_component(CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR
"${CMAKE_CURRENT_BINARY_DIR}" REALPATH
)
REGEX_ESCAPE_STRING(CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR
"${CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR}"
)
foreach (_retval 0 1)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY)
endforeach ()
@ -35,245 +25,6 @@ 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: ")
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.
# - 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
${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}")
set(CHECKER_COMMAND "${CHECKER}")
foreach(_file IN ITEMS CMakeLists.txt CTestConfig.cmake test.cmake)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${_file}.in"
"${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${_file}" @ONLY)
endforeach()
add_test(NAME CTestTestMemcheck${NAME}
COMMAND ${CMAKE_CTEST_COMMAND}
-C $<CONFIGURATION>
-S "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/test.cmake" -V
--output-log "${CMAKE_CURRENT_BINARY_DIR}/${NAME}/testOutput.log"
${ARGN}
)
endfunction(gen_mc_test_internal)
function(gen_mc_test NAME CHECKER)
gen_mc_test_internal(${NAME} "${CHECKER}"
-D PSEUDO_BC=$<TARGET_FILE:pseudo_BC>
-D PSEUDO_PURIFY=$<TARGET_FILE:pseudo_purify>
-D PSEUDO_VALGRIND=$<TARGET_FILE:pseudo_valgrind>
-D ERROR_COMMAND=$<TARGET_FILE:memcheck_fail>
${ARGN}
)
endfunction(gen_mc_test)
function(gen_mcnl_test NAME CHECKER)
gen_mc_test_internal(${NAME} ${CHECKER}
-D PSEUDO_BC=$<TARGET_FILE:pseudonl_BC>
-D PSEUDO_PURIFY=$<TARGET_FILE:pseudonl_purify>
-D PSEUDO_VALGRIND=$<TARGET_FILE:pseudonl_valgrind>
${ARGN}
)
set_tests_properties(CTestTestMemcheck${NAME}
PROPERTIES
PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/${NAME}/Testing/Temporary/MemoryChecker.1.log\n(.*\n)?Error in read script: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/${NAME}/test.cmake\n")
endfunction(gen_mcnl_test)
unset(CTEST_EXTRA_CONFIG)
unset(CTEST_EXTRA_CODE)
unset(CMAKELISTS_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add ThreadSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\"
-P \"${CMAKE_CURRENT_SOURCE_DIR}/testThreadSanitizer.cmake\")
")
gen_mc_test_internal(DummyThreadSanitizer "" -DMEMCHECK_TYPE=ThreadSanitizer)
set_tests_properties(CTestTestMemcheckDummyThreadSanitizer PROPERTIES
PASS_REGULAR_EXPRESSION
".*Memory checking results:.*data race.* - 1.*data race on vptr .ctor/dtor vs virtual call. - 1.*heap-use-after-free - 1.*thread leak - 1.*destroy of a locked mutex - 1.*double lock of a mutex - 1.*unlock of an unlocked mutex .or by a wrong thread. - 1.*read lock of a write locked mutex - 1.*read unlock of a write locked mutex - 1.*signal-unsafe call inside of a signal - 1.*signal handler spoils errno - 1.*lock-order-inversion .potential deadlock. - 1.*")
set(CMAKELISTS_EXTRA_CODE )
set(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add LeakSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\"
-P \"${CMAKE_CURRENT_SOURCE_DIR}/testLeakSanitizer.cmake\")
")
gen_mc_test_internal(DummyLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer)
set(CMAKELISTS_EXTRA_CODE )
set(CTEST_EXTRA_CODE)
set_tests_properties(CTestTestMemcheckDummyLeakSanitizer PROPERTIES
PASS_REGULAR_EXPRESSION
".*Memory checking results:.*Direct leak - 2.*Indirect leak - 1.*")
#-----------------------------------------------------------------------------
# add AddressSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\"
-P \"${CMAKE_CURRENT_SOURCE_DIR}/testAddressSanitizer.cmake\")
")
gen_mc_test_internal(DummyAddressSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer)
set(CMAKELISTS_EXTRA_CODE )
set(CTEST_EXTRA_CODE)
set_tests_properties(CTestTestMemcheckDummyAddressSanitizer PROPERTIES
PASS_REGULAR_EXPRESSION
".*Memory checking results:.*heap-buffer-overflow - 1.*")
#-----------------------------------------------------------------------------
# add MemorySanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\"
-P \"${CMAKE_CURRENT_SOURCE_DIR}/testMemorySanitizer.cmake\")
")
gen_mc_test_internal(DummyMemorySanitizer "" -DMEMCHECK_TYPE=MemorySanitizer)
set(CMAKELISTS_EXTRA_CODE )
set(CTEST_EXTRA_CODE)
set_tests_properties(CTestTestMemcheckDummyMemorySanitizer PROPERTIES
PASS_REGULAR_EXPRESSION
".*Memory checking results:.*use-of-uninitialized-value - 1.*")
#-----------------------------------------------------------------------------
# add UndefinedBehaviorSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\"
-P \"${CMAKE_CURRENT_SOURCE_DIR}/testUndefinedBehaviorSanitizer.cmake\")
")
gen_mc_test_internal(DummyUndefinedBehaviorSanitizer "" -DMEMCHECK_TYPE=UndefinedBehaviorSanitizer)
set(CMAKELISTS_EXTRA_CODE )
set(CTEST_EXTRA_CODE)
set_tests_properties(CTestTestMemcheckDummyUndefinedBehaviorSanitizer PROPERTIES
PASS_REGULAR_EXPRESSION
".*Memory checking results:.*left shift of negative value -256 - 1.*")
#-----------------------------------------------------------------------------
gen_mc_test(DummyPurify "\${PSEUDO_PURIFY}")
gen_mc_test(DummyValgrind "\${PSEUDO_VALGRIND}")
gen_mc_test(DummyBC "\${PSEUDO_BC}")
gen_mcnl_test(DummyPurifyNoLogfile "\${PSEUDO_PURIFY}")
gen_mcnl_test(DummyValgrindNoLogfile "\${PSEUDO_VALGRIND}")
gen_mcnl_test(DummyBCNoLogfile "\${PSEUDO_BC}")
set(CTEST_EXTRA_CODE "string(REPLACE \" \" \"\\\\ \" PRE_POST_COMMAND \"\${CTEST_MEMORYCHECK_COMMAND}\")
set(CTEST_CUSTOM_PRE_MEMCHECK \"\${PRE_POST_COMMAND} pre command\")
set(CTEST_CUSTOM_POST_MEMCHECK \"\${PRE_POST_COMMAND} post command \")
")
gen_mc_test(DummyValgrindPrePost "\${PSEUDO_VALGRIND}")
set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_POST_MEMCHECK \"\${ERROR_COMMAND}\")")
gen_mc_test(DummyValgrindFailPost "\${PSEUDO_VALGRIND}")
set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_PRE_MEMCHECK \"\${ERROR_COMMAND}\")")
gen_mc_test(DummyValgrindFailPre "\${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CODE)
set(CTEST_EXTRA_CONFIG "set(CTEST_CUSTOM_MEMCHECK_IGNORE RunCMakeAgain)\n")
set(CMAKELISTS_EXTRA_CODE "add_test(NAME RunCMakeAgain COMMAND \"\${CMAKE_COMMAND}\" --version)")
gen_mc_test(DummyValgrindIgnoreMemcheck "\${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CONFIG)
gen_mc_test(DummyValgrindTwoTargets "\${PSEUDO_VALGRIND}" "-VV")
set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE \"\${CMAKE_CURRENT_BINARY_DIR}/does-not-exist\")")
unset(CMAKELISTS_EXTRA_CODE)
gen_mc_test(DummyValgrindInvalidSupFile "\${PSEUDO_VALGRIND}")
# CTest will add the logfile option before any custom options. Set the logfile
# again, this time to an empty string. This will cause the logfile to be
# missing, which will be the prove for us that the custom option is indeed used.
set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"--log-file=\")")
gen_mc_test(DummyValgrindCustomOptions "\${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CONFIG)
gen_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe")
gen_mc_test(Unknown "${CMAKE_COMMAND}")
string(REPLACE "\\" "\\\\" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND}")
string(REPLACE "(" "\\(" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}")
string(REPLACE ")" "\\)" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}")
string(REPLACE "+" "\\+" CMAKE_COMMAND_ESCAPED "${CMAKE_COMMAND_ESCAPED}")
set_tests_properties(CTestTestMemcheckUnknown PROPERTIES
PASS_REGULAR_EXPRESSION "Do not understand memory checker: ${CMAKE_COMMAND_ESCAPED}\n(.*\n)?Error in read script: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/Unknown/test.cmake\n")
set_tests_properties(CTestTestMemcheckNotExist PROPERTIES
PASS_REGULAR_EXPRESSION "Memory checker \\(MemoryCheckCommand\\) not set, or cannot find the specified program.")
# It is a valid result if valgrind does not output any files (can e.g. happen
# if you have not compiled in debug mode), so these tests will not fail.
set_tests_properties(CTestTestMemcheckDummyValgrind
CTestTestMemcheckDummyValgrindPrePost
CTestTestMemcheckDummyPurify
PROPERTIES
PASS_REGULAR_EXPRESSION "${ctest_and_tool_outputs}$")
foreach (_pp Pre Post)
string(TOLOWER ${_pp} _pp_lower)
set_tests_properties(CTestTestMemcheckDummyValgrindFail${_pp}
PROPERTIES
PASS_REGULAR_EXPRESSION "\nProblem running command: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}[^\n]*fail[^\n]*\n(.*\n)?Problem executing ${_pp_lower}-memcheck command\\(s\\\).\n(.*\n)?Error in read script: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindFail${_pp}/test.cmake\n")
endforeach ()
set_tests_properties(CTestTestMemcheckDummyValgrindIgnoreMemcheck
PROPERTIES
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${guard_malloc_lines}\n100% tests passed, 0 tests failed out of 1\n(.*\n)?Error parsing XML in stream at line 1: no element found\n")
set_tests_properties(CTestTestMemcheckDummyValgrindInvalidSupFile PROPERTIES
PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n")
set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES
PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/Testing/Temporary/MemoryChecker.1.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/test.cmake\n")
set_tests_properties(CTestTestMemcheckDummyValgrindTwoTargets PROPERTIES
PASS_REGULAR_EXPRESSION
"\nMemory check project ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets\n.*\n *Start 1: RunCMake\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.1.log\" \"-q\".*\n *Start 2: RunCMakeAgain\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.2.log\" \"-q\".*\n")
# Xcode 2.x forgets to create the output directory before linking
# the individual architectures.
if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")

View File

@ -52,6 +52,19 @@ add_RunCMake_test(CMP0053)
add_RunCMake_test(CMP0054)
add_RunCMake_test(CMP0055)
add_RunCMake_test(CTest)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
add_RunCMake_test(CTestMemcheck
-DPSEUDO_BC=$<TARGET_FILE:pseudo_BC>
-DPSEUDO_PURIFY=$<TARGET_FILE:pseudo_purify>
-DPSEUDO_VALGRIND=$<TARGET_FILE:pseudo_valgrind>
-DPSEUDO_BC_NOLOG=$<TARGET_FILE:pseudonl_BC>
-DPSEUDO_PURIFY_NOLOG=$<TARGET_FILE:pseudonl_purify>
-DPSEUDO_VALGRIND_NOLOG=$<TARGET_FILE:pseudonl_valgrind>
-DMEMCHECK_FAIL=$<TARGET_FILE:memcheck_fail>
)
endif()
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
add_RunCMake_test(CompilerChange)
endif()

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyAddressSanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\*
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyAddressSanitizer/test.cmake

View File

@ -0,0 +1,2 @@
Memory checking results:
heap-buffer-overflow - 1

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1 @@
Error parsing XML in stream at line 1: no element found

View File

@ -0,0 +1,3 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,3 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyBCNoLogFile-build/Testing/Temporary/MemoryChecker.1.log
.*Error parsing XML in stream at line 1: no element found
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyBCNoLogFile/test.cmake

View File

@ -0,0 +1,3 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyLeakSanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\*
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyLeakSanitizer/test.cmake

View File

@ -0,0 +1,3 @@
Memory checking results:
Direct leak - 2
Indirect leak - 1

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyMemorySanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\*
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyMemorySanitizer/test.cmake

View File

@ -0,0 +1,2 @@
Memory checking results:
use-of-uninitialized-value - 1

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
^((^|
)(BullseyeCoverage|==|ctest\([0-9]+\) malloc:)[^
]*)*$

View File

@ -0,0 +1,6 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1
.*
-- Processing memory checking output:( )
Memory checking results:

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyPurifyNoLogFile-build/Testing/Temporary/MemoryChecker.1.log
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyPurifyNoLogFile/test.cmake

View File

@ -0,0 +1,3 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyThreadSanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\*
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyThreadSanitizer/test.cmake

View File

@ -0,0 +1,13 @@
Memory checking results:
data race - 1
data race on vptr \(ctor/dtor vs virtual call\) - 1
heap-use-after-free - 1
thread leak - 1
destroy of a locked mutex - 1
double lock of a mutex - 1
unlock of an unlocked mutex \(or by a wrong thread\) - 1
read lock of a write locked mutex - 1
read unlock of a write locked mutex - 1
signal-unsafe call inside of a signal - 1
signal handler spoils errno - 1
lock-order-inversion \(potential deadlock\) - 1

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyUndefinedBehaviorSanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\*
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyUndefinedBehaviorSanitizer/test.cmake

View File

@ -0,0 +1,2 @@
Memory checking results:
left shift of negative value -256 - 1

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
^((^|
)(BullseyeCoverage|==|ctest\([0-9]+\) malloc:)[^
]*)*$

View File

@ -0,0 +1,6 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1
.*
-- Processing memory checking output:( )
Memory checking results:

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindCustomOptions-build/Testing/Temporary/MemoryChecker.1.log
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindCustomOptions/test.cmake

View File

@ -0,0 +1,6 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1
.*
-- Processing memory checking output:( )
Memory checking results:

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,3 @@
Problem running command: .*memcheck_fail.*
Problem executing post-memcheck command\(s\).
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindFailPost/test.cmake

View File

@ -0,0 +1,6 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1
.*
-- Processing memory checking output:( )
Memory checking results:

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,3 @@
Problem running command: .*memcheck_fail.*
Problem executing pre-memcheck command\(s\).
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindFailPre/test.cmake

View File

@ -0,0 +1 @@
Memory check project .*/Tests/RunCMake/CTestMemcheck/DummyValgrindFailPre-build

View File

@ -0,0 +1,3 @@
^((^|
)(BullseyeCoverage|==|ctest\([0-9]+\) malloc:)[^
]*)*$

View File

@ -0,0 +1,7 @@
2/2 Test #2: RunCMakeAgain .*
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1
.*
-- Processing memory checking output:( )
Memory checking results:

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory checker suppression file: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindInvalidSupFile-build/does-not-exist
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindInvalidSupFile/test.cmake

View File

@ -0,0 +1 @@
Memory check project .*/Tests/RunCMake/CTestMemcheck/DummyValgrindInvalidSupFile-build$

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Cannot find memory tester output file: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindNoLogFile-build/Testing/Temporary/MemoryChecker.1.log
Error in read script: .*/Tests/RunCMake/CTestMemcheck/DummyValgrindNoLogFile/test.cmake

View File

@ -0,0 +1,3 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
^((^|
)(BullseyeCoverage|==|ctest\([0-9]+\) malloc:)[^
]*)*$

View File

@ -0,0 +1,6 @@
1/1 MemCheck #1: RunCMake \.+ Passed +[0-9]+.[0-9]+ sec
100% tests passed, 0 tests failed out of 1
.*
-- Processing memory checking output:( )
Memory checking results:

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,3 @@
^((^|
)(BullseyeCoverage|==|ctest\([0-9]+\) malloc:)[^
]*)*$

View File

@ -0,0 +1,8 @@
Memory check project .*/DummyValgrindTwoTargets-build
.*
*Start 1: RunCMake
(.*
)?Memory check command: .* \"--log-file=.*/DummyValgrindTwoTargets-build/Testing/Temporary/MemoryChecker.1.log\" \"-q\".*
*Start 2: RunCMakeAgain
(.*
)?Memory check command: .* \"--log-file=.*/DummyValgrindTwoTargets-build/Testing/Temporary/MemoryChecker.2.log\" \"-q\".*

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1 @@
Memory checker \(MemoryCheckCommand\) not set, or cannot find the specified program\.

View File

@ -0,0 +1 @@
Memory check project .*/Tests/RunCMake/CTestMemcheck/NotExist-build$

View File

@ -0,0 +1,144 @@
include(RunCMake)
set(SITE test-site)
set(BUILDNAME test-build)
set(COVERAGE_COMMAND "")
function(run_mc_test SUBTEST_NAME CHECKER_COMMAND)
configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in
${RunCMake_BINARY_DIR}/${SUBTEST_NAME}/test.cmake @ONLY)
configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
${RunCMake_BINARY_DIR}/${SUBTEST_NAME}/CTestConfig.cmake @ONLY)
configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
${RunCMake_BINARY_DIR}/${SUBTEST_NAME}/CMakeLists.txt @ONLY)
run_cmake_command(${SUBTEST_NAME} ${CMAKE_CTEST_COMMAND}
-C Debug
-S ${RunCMake_BINARY_DIR}/${SUBTEST_NAME}/test.cmake
-V
--output-log ${RunCMake_BINARY_DIR}/${SUBTEST_NAME}-build/testOutput.log
${ARGN}
)
endfunction()
unset(CTEST_EXTRA_CONFIG)
unset(CTEST_EXTRA_CODE)
unset(CMAKELISTS_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add ThreadSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\"
-P \"${RunCMake_SOURCE_DIR}/testThreadSanitizer.cmake\")
")
run_mc_test(DummyThreadSanitizer "" -DMEMCHECK_TYPE=ThreadSanitizer)
unset(CMAKELISTS_EXTRA_CODE)
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add LeakSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\"
-P \"${RunCMake_SOURCE_DIR}/testLeakSanitizer.cmake\")
")
run_mc_test(DummyLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer)
unset(CMAKELISTS_EXTRA_CODE)
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add AddressSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\"
-P \"${RunCMake_SOURCE_DIR}/testAddressSanitizer.cmake\")
")
run_mc_test(DummyAddressSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer)
unset(CMAKELISTS_EXTRA_CODE)
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add MemorySanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\"
-P \"${RunCMake_SOURCE_DIR}/testMemorySanitizer.cmake\")
")
run_mc_test(DummyMemorySanitizer "" -DMEMCHECK_TYPE=MemorySanitizer)
unset(CMAKELISTS_EXTRA_CODE)
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add UndefinedBehaviorSanitizer test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\"
-P \"${RunCMake_SOURCE_DIR}/testUndefinedBehaviorSanitizer.cmake\")
")
run_mc_test(DummyUndefinedBehaviorSanitizer "" -DMEMCHECK_TYPE=UndefinedBehaviorSanitizer)
unset(CMAKELISTS_EXTRA_CODE)
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
set(CTEST_EXTRA_CODE "string(REPLACE \" \" \"\\\\ \" PRE_POST_COMMAND \"\${CTEST_MEMORYCHECK_COMMAND}\")
set(CTEST_CUSTOM_PRE_MEMCHECK \"\${PRE_POST_COMMAND} pre command\")
set(CTEST_CUSTOM_POST_MEMCHECK \"\${PRE_POST_COMMAND} post command \")
")
run_mc_test(DummyValgrindPrePost "${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_POST_MEMCHECK \"${MEMCHECK_FAIL}\")")
run_mc_test(DummyValgrindFailPost "${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_PRE_MEMCHECK \"${MEMCHECK_FAIL}\")")
run_mc_test(DummyValgrindFailPre "${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
set(CTEST_EXTRA_CONFIG "set(CTEST_CUSTOM_MEMCHECK_IGNORE RunCMakeAgain)\n")
set(CMAKELISTS_EXTRA_CODE "add_test(NAME RunCMakeAgain COMMAND \"\${CMAKE_COMMAND}\" --version)")
run_mc_test(DummyValgrindIgnoreMemcheck "${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CONFIG)
unset(CMAKELISTS_EXTRA_CODE)
#-----------------------------------------------------------------------------
set(CMAKELISTS_EXTRA_CODE "add_test(NAME RunCMakeAgain COMMAND \"\${CMAKE_COMMAND}\" --version)")
run_mc_test(DummyValgrindTwoTargets "${PSEUDO_VALGRIND}" "-VV")
unset(CMAKELISTS_EXTRA_CODE)
#-----------------------------------------------------------------------------
set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE \"\${CMAKE_CURRENT_BINARY_DIR}/does-not-exist\")")
run_mc_test(DummyValgrindInvalidSupFile "${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CONFIG)
#-----------------------------------------------------------------------------
# CTest will add the logfile option before any custom options. Set the logfile
# again, this time to an empty string. This will cause the logfile to be
# missing, which will be the prove for us that the custom option is indeed used.
set(CTEST_EXTRA_CONFIG "set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"--log-file=\")")
run_mc_test(DummyValgrindCustomOptions "${PSEUDO_VALGRIND}")
unset(CTEST_EXTRA_CONFIG)
#-----------------------------------------------------------------------------
run_mc_test(DummyPurify "${PSEUDO_PURIFY}")
run_mc_test(DummyValgrind "${PSEUDO_VALGRIND}")
run_mc_test(DummyBC "${PSEUDO_BC}")
run_mc_test(DummyPurifyNoLogFile "${PSEUDO_PURIFY_NOLOG}")
run_mc_test(DummyValgrindNoLogFile "${PSEUDO_VALGRIND_NOLOG}")
run_mc_test(DummyBCNoLogFile "${PSEUDO_BC_NOLOG}")
run_mc_test(NotExist "\${CTEST_BINARY_DIRECTORY}/no-memcheck-exe")
run_mc_test(Unknown "\${CMAKE_COMMAND}")

View File

@ -0,0 +1 @@
(-1|255)

View File

@ -0,0 +1,2 @@
Do not understand memory checker: .*/cmake.*
Error in read script: .*/Tests/RunCMake/CTestMemcheck/Unknown/test.cmake

View File

@ -0,0 +1 @@
Memory check project .*/Tests/RunCMake/CTestMemcheck/Unknown-build$

View File

@ -1,16 +1,14 @@
cmake_minimum_required(VERSION 2.8.9)
# Settings:
set(CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@")
set(CTEST_SITE "@SITE@")
set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Memcheck@SUBTEST_NAME@")
set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@")
set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@SUBTEST_NAME@")
set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@SUBTEST_NAME@-build")
set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")