From f48a2968aacf57d4f23bfeab613c37530801165c Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Oct 2014 14:59:47 -0400 Subject: Tests: Organize CTestTestMemcheck inner test code Update some whitespace and add comment dividers. --- Tests/CTestTestMemcheck/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 7422eb5..cd84e14 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -103,11 +103,11 @@ 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\") @@ -119,11 +119,11 @@ set_tests_properties(CTestTestMemcheckDummyThreadSanitizer PROPERTIES 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\") @@ -134,11 +134,12 @@ 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\") @@ -150,6 +151,7 @@ set_tests_properties(CTestTestMemcheckDummyAddressSanitizer PROPERTIES PASS_REGULAR_EXPRESSION ".*Memory checking results:.*heap-buffer-overflow - 1.*") +#----------------------------------------------------------------------------- gen_mc_test(DummyPurify "\${PSEUDO_PURIFY}") gen_mc_test(DummyValgrind "\${PSEUDO_VALGRIND}") -- cgit v0.12 From b67ef537d468c7e31c6ee375fe86eabc3bf2a128 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Oct 2014 15:14:20 -0400 Subject: ctest_memcheck: Order sanitizer type code consistently Use alphabetic order everywhere we enumerate the sanitizer types. --- Source/CTest/cmCTestMemCheckHandler.cxx | 46 +++++++++++++++++---------------- Source/CTest/cmCTestMemCheckHandler.h | 4 +-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 16ac37c..8a8a373 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -370,12 +370,12 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) case cmCTestMemCheckHandler::BOUNDS_CHECKER: os << "BoundsChecker"; break; - case cmCTestMemCheckHandler::THREAD_SANITIZER: - os << "ThreadSanitizer"; - break; case cmCTestMemCheckHandler::ADDRESS_SANITIZER: os << "AddressSanitizer"; break; + case cmCTestMemCheckHandler::THREAD_SANITIZER: + os << "ThreadSanitizer"; + break; default: os << "Unknown"; } @@ -537,19 +537,19 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; } if ( this->CTest->GetCTestConfiguration("MemoryCheckType") - == "ThreadSanitizer") + == "AddressSanitizer") { this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand").c_str(); - this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER; + this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER; this->LogWithPID = true; // even if we give the log file the pid is added } if ( this->CTest->GetCTestConfiguration("MemoryCheckType") - == "AddressSanitizer") + == "ThreadSanitizer") { this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand").c_str(); - this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER; + this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER; this->LogWithPID = true; // even if we give the log file the pid is added } // Check the MemoryCheckType @@ -674,8 +674,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterOptions.push_back("/M"); break; } - // these two are almost the same but the env var used - // is different + // these are almost the same but the env var used is different case cmCTestMemCheckHandler::ADDRESS_SANITIZER: case cmCTestMemCheckHandler::THREAD_SANITIZER: { @@ -689,15 +688,15 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() std::string envVar; std::string extraOptions = this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions"); - if(this->MemoryTesterStyle == cmCTestMemCheckHandler::THREAD_SANITIZER) + if(this->MemoryTesterStyle == cmCTestMemCheckHandler::ADDRESS_SANITIZER) { - envVar = "TSAN_OPTIONS"; + envVar = "ASAN_OPTIONS"; + extraOptions += " detect_leaks=1"; } else if(this->MemoryTesterStyle == - cmCTestMemCheckHandler::ADDRESS_SANITIZER) + cmCTestMemCheckHandler::THREAD_SANITIZER) { - envVar = "ASAN_OPTIONS"; - extraOptions += " detect_leaks=1"; + envVar = "TSAN_OPTIONS"; } std::string outputFile = envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\" "; @@ -734,9 +733,9 @@ ProcessMemCheckOutput(const std::string& str, return this->ProcessMemCheckPurifyOutput(str, log, results); } else if ( this->MemoryTesterStyle == - cmCTestMemCheckHandler::THREAD_SANITIZER || + cmCTestMemCheckHandler::ADDRESS_SANITIZER || this->MemoryTesterStyle == - cmCTestMemCheckHandler::ADDRESS_SANITIZER) + cmCTestMemCheckHandler::THREAD_SANITIZER) { return this->ProcessMemCheckSanitizerOutput(str, log, results); } @@ -776,13 +775,16 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( std::vector& result) { std::string regex; - if(this->MemoryTesterStyle == cmCTestMemCheckHandler::THREAD_SANITIZER) - { - regex = "WARNING: ThreadSanitizer: (.*) \\(pid=.*\\)"; - } - else + switch ( this->MemoryTesterStyle ) { - regex = "ERROR: AddressSanitizer: (.*) on.*"; + case cmCTestMemCheckHandler::ADDRESS_SANITIZER: + regex = "ERROR: AddressSanitizer: (.*) on.*"; + break; + case cmCTestMemCheckHandler::THREAD_SANITIZER: + regex = "WARNING: ThreadSanitizer: (.*) \\(pid=.*\\)"; + break; + default: + break; } cmsys::RegularExpression sanitizerWarning(regex); cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*"); diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index f442376..3ceaa25 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -50,8 +50,8 @@ private: PURIFY, BOUNDS_CHECKER, // checkers after here do not use the standard error list - THREAD_SANITIZER, - ADDRESS_SANITIZER + ADDRESS_SANITIZER, + THREAD_SANITIZER }; public: enum { // Memory faults -- cgit v0.12 From 816c100ae2d1ef9ad42186a260724a279b6b5934 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 3 Oct 2014 13:46:18 -0400 Subject: ctest_memcheck: Add support for UndefinedBehaviorSanitizer ubsan UBSan instruments a build and logs messages on any undefined behavior instances. --- Help/variable/CTEST_MEMORYCHECK_TYPE.rst | 2 +- Source/CTest/cmCTestMemCheckHandler.cxx | 23 ++++++++++++++++++++++- Source/CTest/cmCTestMemCheckHandler.h | 3 ++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst index e8d5461..af759e9 100644 --- a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst +++ b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst @@ -4,4 +4,4 @@ CTEST_MEMORYCHECK_TYPE Specify the CTest ``MemoryCheckType`` setting in a :manual:`ctest(1)` dashboard client script. Valid values are Valgrind, Purify, BoundsChecker, and ThreadSanitizer, -and AddressSanitizer. +AddressSanitizer, and UndefinedBehaviorSanitizer. diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 8a8a373..cc691aa 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -376,6 +376,9 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) case cmCTestMemCheckHandler::THREAD_SANITIZER: os << "ThreadSanitizer"; break; + case cmCTestMemCheckHandler::UB_SANITIZER: + os << "UndefinedBehaviorSanitizer"; + break; default: os << "Unknown"; } @@ -552,6 +555,14 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER; this->LogWithPID = true; // even if we give the log file the pid is added } + if ( this->CTest->GetCTestConfiguration("MemoryCheckType") + == "UndefinedBehaviorSanitizer") + { + this->MemoryTester + = this->CTest->GetCTestConfiguration("CMakeCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::UB_SANITIZER; + this->LogWithPID = true; // even if we give the log file the pid is added + } // Check the MemoryCheckType if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UNKNOWN) { @@ -677,6 +688,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() // these are almost the same but the env var used is different case cmCTestMemCheckHandler::ADDRESS_SANITIZER: case cmCTestMemCheckHandler::THREAD_SANITIZER: + case cmCTestMemCheckHandler::UB_SANITIZER: { // To pass arguments to ThreadSanitizer the environment variable // TSAN_OPTIONS is used. This is done with the cmake -E env command. @@ -698,6 +710,10 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() { envVar = "TSAN_OPTIONS"; } + else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) + { + envVar = "UBSAN_OPTIONS"; + } std::string outputFile = envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\" "; this->MemoryTesterEnvironmentVariable = outputFile + extraOptions; @@ -735,7 +751,9 @@ ProcessMemCheckOutput(const std::string& str, else if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::ADDRESS_SANITIZER || this->MemoryTesterStyle == - cmCTestMemCheckHandler::THREAD_SANITIZER) + cmCTestMemCheckHandler::THREAD_SANITIZER || + this->MemoryTesterStyle == + cmCTestMemCheckHandler::UB_SANITIZER) { return this->ProcessMemCheckSanitizerOutput(str, log, results); } @@ -783,6 +801,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( case cmCTestMemCheckHandler::THREAD_SANITIZER: regex = "WARNING: ThreadSanitizer: (.*) \\(pid=.*\\)"; break; + case cmCTestMemCheckHandler::UB_SANITIZER: + regex = "runtime error: (.*)"; + break; default: break; } diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 3ceaa25..f5cc91c 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -51,7 +51,8 @@ private: BOUNDS_CHECKER, // checkers after here do not use the standard error list ADDRESS_SANITIZER, - THREAD_SANITIZER + THREAD_SANITIZER, + UB_SANITIZER }; public: enum { // Memory faults -- cgit v0.12 From 9ba8bf123c0a5c8410580b059ec33af656a569b8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 6 Oct 2014 14:13:37 -0400 Subject: tests: add a test for ctest_memcheck UndefinedBehaviorSanitizer --- Tests/CTestTestMemcheck/CMakeLists.txt | 17 +++++++++++++++++ .../testUndefinedBehaviorSanitizer.cmake | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Tests/CTestTestMemcheck/testUndefinedBehaviorSanitizer.cmake diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index cd84e14..7fb4a0f 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -152,6 +152,23 @@ set_tests_properties(CTestTestMemcheckDummyAddressSanitizer PROPERTIES ".*Memory checking results:.*heap-buffer-overflow - 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}") diff --git a/Tests/CTestTestMemcheck/testUndefinedBehaviorSanitizer.cmake b/Tests/CTestTestMemcheck/testUndefinedBehaviorSanitizer.cmake new file mode 100644 index 0000000..8ef3c0a --- /dev/null +++ b/Tests/CTestTestMemcheck/testUndefinedBehaviorSanitizer.cmake @@ -0,0 +1,21 @@ +# this file simulates a program that has been built with undefined behavior +# sanitizer options + +message("UBSAN_OPTIONS = [$ENV{UBSAN_OPTIONS}]") +string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{UBSAN_OPTIONS}") +message("LOG_FILE=[${LOG_FILE}]") + +# if we are not asked to simulate address sanitizer don't do it +if(NOT "$ENV{UBSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + return() +endif() +# clear the log file +file(REMOVE "${LOG_FILE}.2343") + +# create an error like undefined behavior santizer creates; +# these names come from ubsan_diag.cc and ubsan_handlers.cc +# in llvm + +file(APPEND "${LOG_FILE}.2343" +": runtime error: left shift of negative value -256 +") -- cgit v0.12 From 0c6330da38bb04467eaa4d38c659b02222029ae3 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 7 Oct 2014 11:34:53 -0400 Subject: ctest_memcheck: Add support for MemorySanitizer msan --- Help/variable/CTEST_MEMORYCHECK_TYPE.rst | 2 +- Source/CTest/cmCTestMemCheckHandler.cxx | 22 ++++++++++++++++++++++ Source/CTest/cmCTestMemCheckHandler.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst index af759e9..f1087c0 100644 --- a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst +++ b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst @@ -4,4 +4,4 @@ CTEST_MEMORYCHECK_TYPE Specify the CTest ``MemoryCheckType`` setting in a :manual:`ctest(1)` dashboard client script. Valid values are Valgrind, Purify, BoundsChecker, and ThreadSanitizer, -AddressSanitizer, and UndefinedBehaviorSanitizer. +AddressSanitizer, MemorySanitizer, and UndefinedBehaviorSanitizer. diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index cc691aa..4835010 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -376,6 +376,9 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) case cmCTestMemCheckHandler::THREAD_SANITIZER: os << "ThreadSanitizer"; break; + case cmCTestMemCheckHandler::MEMORY_SANITIZER: + os << "MemorySanitizer"; + break; case cmCTestMemCheckHandler::UB_SANITIZER: os << "UndefinedBehaviorSanitizer"; break; @@ -556,6 +559,14 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->LogWithPID = true; // even if we give the log file the pid is added } if ( this->CTest->GetCTestConfiguration("MemoryCheckType") + == "MemorySanitizer") + { + this->MemoryTester + = this->CTest->GetCTestConfiguration("CMakeCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::MEMORY_SANITIZER; + this->LogWithPID = true; // even if we give the log file the pid is added + } + if ( this->CTest->GetCTestConfiguration("MemoryCheckType") == "UndefinedBehaviorSanitizer") { this->MemoryTester @@ -688,6 +699,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() // these are almost the same but the env var used is different case cmCTestMemCheckHandler::ADDRESS_SANITIZER: case cmCTestMemCheckHandler::THREAD_SANITIZER: + case cmCTestMemCheckHandler::MEMORY_SANITIZER: case cmCTestMemCheckHandler::UB_SANITIZER: { // To pass arguments to ThreadSanitizer the environment variable @@ -710,6 +722,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() { envVar = "TSAN_OPTIONS"; } + else if(this->MemoryTesterStyle == + cmCTestMemCheckHandler::MEMORY_SANITIZER) + { + envVar = "MSAN_OPTIONS"; + } else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) { envVar = "UBSAN_OPTIONS"; @@ -753,6 +770,8 @@ ProcessMemCheckOutput(const std::string& str, this->MemoryTesterStyle == cmCTestMemCheckHandler::THREAD_SANITIZER || this->MemoryTesterStyle == + cmCTestMemCheckHandler::MEMORY_SANITIZER || + this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) { return this->ProcessMemCheckSanitizerOutput(str, log, results); @@ -801,6 +820,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( case cmCTestMemCheckHandler::THREAD_SANITIZER: regex = "WARNING: ThreadSanitizer: (.*) \\(pid=.*\\)"; break; + case cmCTestMemCheckHandler::MEMORY_SANITIZER: + regex = "WARNING: MemorySanitizer: (.*)"; + break; case cmCTestMemCheckHandler::UB_SANITIZER: regex = "runtime error: (.*)"; break; diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index f5cc91c..69fdd9f 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -52,6 +52,7 @@ private: // checkers after here do not use the standard error list ADDRESS_SANITIZER, THREAD_SANITIZER, + MEMORY_SANITIZER, UB_SANITIZER }; public: -- cgit v0.12 From 7345a1f71d8a7b39680413b5180b0089dc80cc57 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 7 Oct 2014 13:51:55 -0400 Subject: tests: Add a test for ctest_memcheck MemorySanitizer --- Tests/CTestTestMemcheck/CMakeLists.txt | 17 ++++++++++++++ Tests/CTestTestMemcheck/testMemorySanitizer.cmake | 27 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 Tests/CTestTestMemcheck/testMemorySanitizer.cmake diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 7fb4a0f..2023e74 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -152,6 +152,23 @@ set_tests_properties(CTestTestMemcheckDummyAddressSanitizer PROPERTIES ".*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\") diff --git a/Tests/CTestTestMemcheck/testMemorySanitizer.cmake b/Tests/CTestTestMemcheck/testMemorySanitizer.cmake new file mode 100644 index 0000000..c87af9a --- /dev/null +++ b/Tests/CTestTestMemcheck/testMemorySanitizer.cmake @@ -0,0 +1,27 @@ +# this file simulates a program that has been built with thread sanitizer +# options + +message("MSAN_OPTIONS = [$ENV{MSAN_OPTIONS}]") +string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{MSAN_OPTIONS}") +message("LOG_FILE=[${LOG_FILE}]") + +# if we are not asked to simulate address sanitizer don't do it +if(NOT "$ENV{MSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + return() +endif() +# 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 + +file(APPEND "${LOG_FILE}.2343" +"================================================================= +==28423== WARNING: MemorySanitizer: use-of-uninitialized-value + #0 0x7f4364210dd9 in main (/home/kitware/msan/msan-bin/umr+0x7bdd9) + #1 0x7f4362d9376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + #2 0x7f4364210b0c in _start (/home/kitware/msan/msan-bin/umr+0x7bb0c) + +SUMMARY: MemorySanitizer: use-of-uninitialized-value ??:0 main +Exiting +") -- cgit v0.12 From e0e75a7201d4189693b409f14a3280b6b94a5f51 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Oct 2014 15:04:48 -0400 Subject: Help: Add notes for topic 'ctest-memcheck-sanitizers' Consolidate earlier sanitizer notes. --- Help/release/dev/ctest-memcheck-sanitizers.rst | 8 ++++++++ Help/release/dev/thread-sanitizer.rst | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 Help/release/dev/ctest-memcheck-sanitizers.rst delete mode 100644 Help/release/dev/thread-sanitizer.rst diff --git a/Help/release/dev/ctest-memcheck-sanitizers.rst b/Help/release/dev/ctest-memcheck-sanitizers.rst new file mode 100644 index 0000000..fa8fb81 --- /dev/null +++ b/Help/release/dev/ctest-memcheck-sanitizers.rst @@ -0,0 +1,8 @@ +ctest-memcheck-sanitizers +------------------------- + +* The :command:`ctest_memcheck` command learned to support sanitizer + modes, including ``AddressSanitizer``, ``MemorySanitizer``, + ``ThreadSanitizer``, and ``UndefinedBehaviorSanitizer``. + Options may be set using the new + :variable:`CTEST_MEMORYCHECK_SANITIZER_OPTIONS` variable. diff --git a/Help/release/dev/thread-sanitizer.rst b/Help/release/dev/thread-sanitizer.rst deleted file mode 100644 index f38e8e1..0000000 --- a/Help/release/dev/thread-sanitizer.rst +++ /dev/null @@ -1,5 +0,0 @@ -thread-sanitizer ----------------- - -* The :command:`ctest_memcheck` command learned to support - ``ThreadSanitizer``. -- cgit v0.12