diff options
author | Brad King <brad.king@kitware.com> | 2014-10-08 14:48:12 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-10-08 14:48:12 (GMT) |
commit | ec941fc04bf4facc7ffe45142351126262fdddee (patch) | |
tree | 19e4bdf95913c38eb735b4cbdcd17b49fa9d6d03 /Source | |
parent | 26a8b64f7d98c02e0f489e9e1e12e3484ded8bec (diff) | |
parent | e0e75a7201d4189693b409f14a3280b6b94a5f51 (diff) | |
download | CMake-ec941fc04bf4facc7ffe45142351126262fdddee.zip CMake-ec941fc04bf4facc7ffe45142351126262fdddee.tar.gz CMake-ec941fc04bf4facc7ffe45142351126262fdddee.tar.bz2 |
Merge topic 'ctest-memcheck-sanitizers'
e0e75a72 Help: Add notes for topic 'ctest-memcheck-sanitizers'
7345a1f7 tests: Add a test for ctest_memcheck MemorySanitizer
0c6330da ctest_memcheck: Add support for MemorySanitizer msan
9ba8bf12 tests: add a test for ctest_memcheck UndefinedBehaviorSanitizer
816c100a ctest_memcheck: Add support for UndefinedBehaviorSanitizer ubsan
b67ef537 ctest_memcheck: Order sanitizer type code consistently
f48a2968 Tests: Organize CTestTestMemcheck inner test code
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.cxx | 79 | ||||
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.h | 4 |
2 files changed, 65 insertions, 18 deletions
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 16ac37c..4835010 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -370,11 +370,17 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) case cmCTestMemCheckHandler::BOUNDS_CHECKER: os << "BoundsChecker"; break; + case cmCTestMemCheckHandler::ADDRESS_SANITIZER: + os << "AddressSanitizer"; + break; case cmCTestMemCheckHandler::THREAD_SANITIZER: os << "ThreadSanitizer"; break; - case cmCTestMemCheckHandler::ADDRESS_SANITIZER: - os << "AddressSanitizer"; + case cmCTestMemCheckHandler::MEMORY_SANITIZER: + os << "MemorySanitizer"; + break; + case cmCTestMemCheckHandler::UB_SANITIZER: + os << "UndefinedBehaviorSanitizer"; break; default: os << "Unknown"; @@ -537,6 +543,14 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; } if ( this->CTest->GetCTestConfiguration("MemoryCheckType") + == "AddressSanitizer") + { + this->MemoryTester + = this->CTest->GetCTestConfiguration("CMakeCommand").c_str(); + this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER; + this->LogWithPID = true; // even if we give the log file the pid is added + } + if ( this->CTest->GetCTestConfiguration("MemoryCheckType") == "ThreadSanitizer") { this->MemoryTester @@ -545,11 +559,19 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->LogWithPID = true; // even if we give the log file the pid is added } if ( this->CTest->GetCTestConfiguration("MemoryCheckType") - == "AddressSanitizer") + == "MemorySanitizer") { this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand").c_str(); - this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER; + 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 + = 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 @@ -674,10 +696,11 @@ 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: + case cmCTestMemCheckHandler::MEMORY_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. @@ -689,15 +712,24 @@ 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 = "ASAN_OPTIONS"; + extraOptions += " detect_leaks=1"; + } + else if(this->MemoryTesterStyle == + cmCTestMemCheckHandler::THREAD_SANITIZER) { envVar = "TSAN_OPTIONS"; } else if(this->MemoryTesterStyle == - cmCTestMemCheckHandler::ADDRESS_SANITIZER) + cmCTestMemCheckHandler::MEMORY_SANITIZER) { - envVar = "ASAN_OPTIONS"; - extraOptions += " detect_leaks=1"; + envVar = "MSAN_OPTIONS"; + } + else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) + { + envVar = "UBSAN_OPTIONS"; } std::string outputFile = envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\" "; @@ -734,9 +766,13 @@ ProcessMemCheckOutput(const std::string& str, return this->ProcessMemCheckPurifyOutput(str, log, results); } else if ( this->MemoryTesterStyle == + cmCTestMemCheckHandler::ADDRESS_SANITIZER || + this->MemoryTesterStyle == cmCTestMemCheckHandler::THREAD_SANITIZER || this->MemoryTesterStyle == - cmCTestMemCheckHandler::ADDRESS_SANITIZER) + cmCTestMemCheckHandler::MEMORY_SANITIZER || + this->MemoryTesterStyle == + cmCTestMemCheckHandler::UB_SANITIZER) { return this->ProcessMemCheckSanitizerOutput(str, log, results); } @@ -776,13 +812,22 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( std::vector<int>& 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; + case cmCTestMemCheckHandler::MEMORY_SANITIZER: + regex = "WARNING: MemorySanitizer: (.*)"; + break; + case cmCTestMemCheckHandler::UB_SANITIZER: + regex = "runtime error: (.*)"; + 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..69fdd9f 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -50,8 +50,10 @@ private: PURIFY, BOUNDS_CHECKER, // checkers after here do not use the standard error list + ADDRESS_SANITIZER, THREAD_SANITIZER, - ADDRESS_SANITIZER + MEMORY_SANITIZER, + UB_SANITIZER }; public: enum { // Memory faults |