diff options
author | Brad King <brad.king@kitware.com> | 2014-07-09 14:02:48 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-07-09 14:02:48 (GMT) |
commit | 55d3e88fb7eb5cfdb58c5617133dfaf70d3b0547 (patch) | |
tree | 6b3060963ff185b10bb440368a4d1b3bb91e50c2 /Tests | |
parent | aaea11e3531918612887263c7e926fca40964b1a (diff) | |
parent | 7c80ce6f057a7d97b049fe152a6f9d914093da5f (diff) | |
download | CMake-55d3e88fb7eb5cfdb58c5617133dfaf70d3b0547.zip CMake-55d3e88fb7eb5cfdb58c5617133dfaf70d3b0547.tar.gz CMake-55d3e88fb7eb5cfdb58c5617133dfaf70d3b0547.tar.bz2 |
Merge topic 'thread-sanitizer'
7c80ce6f Help: Add notes for topic 'thread-sanitizer'
49948f72 ctest_memcheck: Add support for ThreadSanitizer
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CTestTestMemcheck/CMakeLists.txt | 18 | ||||
-rw-r--r-- | Tests/CTestTestMemcheck/test.cmake.in | 1 | ||||
-rw-r--r-- | Tests/CTestTestMemcheck/testThreadSanitizer.cmake | 47 |
3 files changed, 66 insertions, 0 deletions
diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 8984463..f470835 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -103,6 +103,19 @@ 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(CMAKELISTS_EXTRA_CODE ) +set(CTEST_EXTRA_CODE) + gen_mc_test(DummyPurify "\${PSEUDO_PURIFY}") gen_mc_test(DummyValgrind "\${PSEUDO_VALGRIND}") gen_mc_test(DummyBC "\${PSEUDO_BC}") @@ -189,6 +202,11 @@ 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") +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.*") + + # 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]") diff --git a/Tests/CTestTestMemcheck/test.cmake.in b/Tests/CTestTestMemcheck/test.cmake.in index 471e5a5..87195c5 100644 --- a/Tests/CTestTestMemcheck/test.cmake.in +++ b/Tests/CTestTestMemcheck/test.cmake.in @@ -15,6 +15,7 @@ set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") set(CTEST_MEMORYCHECK_COMMAND "@CHECKER_COMMAND@") +set(CTEST_MEMORYCHECK_TYPE "${MEMCHECK_TYPE}") @CTEST_EXTRA_CODE@ diff --git a/Tests/CTestTestMemcheck/testThreadSanitizer.cmake b/Tests/CTestTestMemcheck/testThreadSanitizer.cmake new file mode 100644 index 0000000..d591931 --- /dev/null +++ b/Tests/CTestTestMemcheck/testThreadSanitizer.cmake @@ -0,0 +1,47 @@ +# this file simulates a program that has been built with thread sanitizer +# options + +message("TSAN_OPTIONS = [$ENV{TSAN_OPTIONS}]") +string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}") +message("LOG_FILE=[${LOG_FILE}]") + +set(error_types + "data race" + "data race on vptr (ctor/dtor vs virtual call)" + "heap-use-after-free" + "thread leak" + "destroy of a locked mutex" + "double lock of a mutex" + "unlock of an unlocked mutex (or by a wrong thread)" + "read lock of a write locked mutex" + "read unlock of a write locked mutex" + "signal-unsafe call inside of a signal" + "signal handler spoils errno" + "lock-order-inversion (potential deadlock)" + ) + +# clear the log file +file(REMOVE "${LOG_FILE}.2343") + +# create an error of each type of thread santizer +# these names come from tsan_report.cc in llvm +foreach(error_type ${error_types} ) + + file(APPEND "${LOG_FILE}.2343" +"================== +WARNING: ThreadSanitizer: ${error_type} (pid=27978) + Write of size 4 at 0x7fe017ce906c by thread T1: + #0 Thread1 ??:0 (exe+0x000000000bb0) + #1 <null> <null>:0 (libtsan.so.0+0x00000001b279) + + Previous write of size 4 at 0x7fe017ce906c by main thread: + #0 main ??:0 (exe+0x000000000c3c) + + Thread T1 (tid=27979, running) created by main thread at: + #0 <null> <null>:0 (libtsan.so.0+0x00000001ed7b) + #1 main ??:0 (exe+0x000000000c2c) + +SUMMARY: ThreadSanitizer: ${error_type} ??:0 Thread1 +================== +") +endforeach() |