diff options
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBatchTestHandler.cxx | 8 | ||||
-rw-r--r-- | Source/CTest/cmCTestBatchTestHandler.h | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestMemCheckCommand.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.cxx | 85 | ||||
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.h | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestMultiProcessHandler.cxx | 8 | ||||
-rw-r--r-- | Source/CTest/cmParseCoberturaCoverage.cxx | 1 |
7 files changed, 86 insertions, 29 deletions
diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx index 934481b..7f966aa 100644 --- a/Source/CTest/cmCTestBatchTestHandler.cxx +++ b/Source/CTest/cmCTestBatchTestHandler.cxx @@ -33,8 +33,8 @@ void cmCTestBatchTestHandler::WriteBatchScript() { this->Script = this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt"; - std::fstream fout; - fout.open(this->Script.c_str(), std::ios::out); + cmsys::ofstream fout; + fout.open(this->Script.c_str()); fout << "#!/bin/sh\n"; for(TestMap::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i) @@ -48,7 +48,7 @@ void cmCTestBatchTestHandler::WriteBatchScript() } //--------------------------------------------------------- -void cmCTestBatchTestHandler::WriteSrunArgs(int test, std::fstream& fout) +void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout) { cmCTestTestHandler::cmCTestTestProperties* properties = this->Properties[test]; @@ -79,7 +79,7 @@ void cmCTestBatchTestHandler::WriteSrunArgs(int test, std::fstream& fout) } //--------------------------------------------------------- -void cmCTestBatchTestHandler::WriteTestCommand(int test, std::fstream& fout) +void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout) { std::vector<std::string> args = this->Properties[test]->Args; std::vector<std::string> processArgs; diff --git a/Source/CTest/cmCTestBatchTestHandler.h b/Source/CTest/cmCTestBatchTestHandler.h index ab0d081..e0c6e48 100644 --- a/Source/CTest/cmCTestBatchTestHandler.h +++ b/Source/CTest/cmCTestBatchTestHandler.h @@ -17,6 +17,7 @@ #include <cmCTestTestHandler.h> #include <cmCTestMultiProcessHandler.h> #include <cmCTestRunTest.h> +#include <cmsys/FStream.hxx> /** \class cmCTestBatchTestHandler * \brief run parallel ctest @@ -30,8 +31,8 @@ public: virtual void RunTests(); protected: void WriteBatchScript(); - void WriteSrunArgs(int test, std::fstream& fout); - void WriteTestCommand(int test, std::fstream& fout); + void WriteSrunArgs(int test, cmsys::ofstream& fout); + void WriteTestCommand(int test, cmsys::ofstream& fout); void SubmitBatchScript(); diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx index 939b4dc..f144066 100644 --- a/Source/CTest/cmCTestMemCheckCommand.cxx +++ b/Source/CTest/cmCTestMemCheckCommand.cxx @@ -23,6 +23,8 @@ cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler() this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE"); this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND"); this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS"); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index a7ab077..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. @@ -686,15 +709,30 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() // TSAN_OPTIONS string with the log_path in it. this->MemoryTesterDynamicOptions.push_back("-E"); this->MemoryTesterDynamicOptions.push_back("env"); - std::string envVar = "TSAN_OPTIONS"; - std::string extraOptions; + std::string envVar; + std::string extraOptions = + this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions"); if(this->MemoryTesterStyle == cmCTestMemCheckHandler::ADDRESS_SANITIZER) { envVar = "ASAN_OPTIONS"; - extraOptions = " detect_leaks=1"; + extraOptions += " detect_leaks=1"; + } + else if(this->MemoryTesterStyle == + cmCTestMemCheckHandler::THREAD_SANITIZER) + { + envVar = "TSAN_OPTIONS"; + } + else if(this->MemoryTesterStyle == + cmCTestMemCheckHandler::MEMORY_SANITIZER) + { + envVar = "MSAN_OPTIONS"; + } + else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) + { + envVar = "UBSAN_OPTIONS"; } std::string outputFile = envVar + "=log_path=\"" - + this->MemoryTesterOutputFile + "\""; + + this->MemoryTesterOutputFile + "\" "; this->MemoryTesterEnvironmentVariable = outputFile + extraOptions; break; } @@ -728,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); } @@ -770,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 2195dab..69fdd9f 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -49,9 +49,11 @@ private: VALGRIND, PURIFY, BOUNDS_CHECKER, - // checkers after hear do not use the standard error list + // checkers after here do not use the standard error list + ADDRESS_SANITIZER, THREAD_SANITIZER, - ADDRESS_SANITIZER + MEMORY_SANITIZER, + UB_SANITIZER }; public: enum { // Memory faults diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index b9e6721..7ba434c 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -319,8 +319,8 @@ void cmCTestMultiProcessHandler::UpdateCostData() { std::string fname = this->CTest->GetCostDataFile(); std::string tmpout = fname + ".tmp"; - std::fstream fout; - fout.open(tmpout.c_str(), std::ios::out); + cmsys::ofstream fout; + fout.open(tmpout.c_str()); PropertiesMap temp = this->Properties; @@ -610,8 +610,8 @@ void cmCTestMultiProcessHandler::WriteCheckpoint(int index) { std::string fname = this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt"; - std::fstream fout; - fout.open(fname.c_str(), std::ios::app | std::ios::out); + cmsys::ofstream fout; + fout.open(fname.c_str(), std::ios::app); fout << index << "\n"; fout.close(); } diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index 6b98056..0742be1 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -71,6 +71,7 @@ protected: cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: " << atts[tagCount+1]<< std::endl); std::string filename = atts[tagCount+1]; + this->CurFileName = ""; for(size_t i=0;i < FilePaths.size();i++) { finalpath = FilePaths[i] + "/" + filename; |