diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2013-08-07 20:25:48 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2013-08-07 20:25:48 (GMT) |
commit | 6f9aaad150f769cd73df408514cf5dc42c020074 (patch) | |
tree | 3b4f2b157d40db6b8d6ea5af708e01c11cadb060 /Source/CTest/cmCTestMemCheckHandler.cxx | |
parent | 7c9f0c664f5782c09c686b8e51fe50245463914b (diff) | |
download | CMake-6f9aaad150f769cd73df408514cf5dc42c020074.zip CMake-6f9aaad150f769cd73df408514cf5dc42c020074.tar.gz CMake-6f9aaad150f769cd73df408514cf5dc42c020074.tar.bz2 |
CTest: create one output file per memcheck (#14303)
The output file used for memory checker runs must be unique for every test run
in parallel, so simply make them unique for every test run. Simply use the test
index to avoid collisions.
Diffstat (limited to 'Source/CTest/cmCTestMemCheckHandler.cxx')
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.cxx | 101 |
1 files changed, 70 insertions, 31 deletions
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 8baa673..3ae2ac6 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -200,6 +200,7 @@ void cmCTestMemCheckHandler::Initialize() this->CustomMaximumPassedTestOutputSize = 0; this->CustomMaximumFailedTestOutputSize = 0; this->MemoryTester = ""; + this->MemoryTesterDynamicOptions.clear(); this->MemoryTesterOptions.clear(); this->MemoryTesterStyle = UNKNOWN; this->MemoryTesterOutputFile = ""; @@ -242,12 +243,28 @@ int cmCTestMemCheckHandler::PostProcessHandler() //---------------------------------------------------------------------- void cmCTestMemCheckHandler::GenerateTestCommand( - std::vector<std::string>& args) + std::vector<std::string>& args, int test) { std::vector<cmStdString>::size_type pp; - std::string memcheckcommand = ""; - memcheckcommand + cmStdString index; + cmOStringStream stream; + std::string memcheckcommand = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); + stream << test; + index = stream.str(); + for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ ) + { + cmStdString arg = this->MemoryTesterDynamicOptions[pp]; + cmStdString::size_type pos = arg.find("??"); + if (pos != cmStdString::npos) + { + arg.replace(pos, 2, index); + } + args.push_back(arg); + memcheckcommand += " \""; + memcheckcommand += arg; + memcheckcommand += "\""; + } for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ ) { args.push_back(this->MemoryTesterOptions[pp]); @@ -478,7 +495,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() = cmSystemTools::ParseArguments(memoryTesterOptions.c_str()); this->MemoryTesterOutputFile - = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; + = this->CTest->GetBinaryDir() + + "/Testing/Temporary/MemoryChecker.??.log"; switch ( this->MemoryTesterStyle ) { @@ -510,7 +528,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } std::string outputFile = "--log-file=" + this->MemoryTesterOutputFile; - this->MemoryTesterOptions.push_back(outputFile); + this->MemoryTesterDynamicOptions.push_back(outputFile); break; } case cmCTestMemCheckHandler::PURIFY: @@ -538,19 +556,19 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() outputFile = "-log-file="; #endif outputFile += this->MemoryTesterOutputFile; - this->MemoryTesterOptions.push_back(outputFile); + this->MemoryTesterDynamicOptions.push_back(outputFile); break; } case cmCTestMemCheckHandler::BOUNDS_CHECKER: { this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; std::string dpbdFile = this->CTest->GetBinaryDir() - + "/Testing/Temporary/MemoryChecker.DPbd"; + + "/Testing/Temporary/MemoryChecker.??.DPbd"; this->BoundsCheckerDPBDFile = dpbdFile; - this->MemoryTesterOptions.push_back("/B"); - this->MemoryTesterOptions.push_back(dpbdFile); - this->MemoryTesterOptions.push_back("/X"); - this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); + this->MemoryTesterDynamicOptions.push_back("/B"); + this->MemoryTesterDynamicOptions.push_back(dpbdFile); + this->MemoryTesterDynamicOptions.push_back("/X"); + this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile); this->MemoryTesterOptions.push_back("/M"); break; } @@ -898,25 +916,23 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( // This method puts the bounds checker output file into the output // for the test void -cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res) +cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, + int test) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessBoundsCheckerTest for : " << res.Name.c_str() << std::endl); - if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) ) + cmStdString ofile = testOutputFileName(test); + if ( ofile.empty() ) { - std::string log = "Cannot find memory tester output file: " - + this->MemoryTesterOutputFile; - cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } // put a scope around this to close ifs so the file can be removed { - std::ifstream ifs(this->MemoryTesterOutputFile.c_str()); + std::ifstream ifs(ofile.c_str()); if ( !ifs ) { - std::string log = "Cannot read memory tester output file: " - + this->MemoryTesterOutputFile; + std::string log = "Cannot read memory tester output file: " + ofile; cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } @@ -939,38 +955,39 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res) } void -cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res) +cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res, + int test) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessPurifyTest for : " << res.Name.c_str() << std::endl); - appendMemTesterOutput(res); + appendMemTesterOutput(res, test); } void -cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res) +cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res, + int test) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessValgrindTest for : " << res.Name.c_str() << std::endl); - appendMemTesterOutput(res); + appendMemTesterOutput(res, test); } void -cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res) +cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, + int test) { - if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) ) + cmStdString ofile = testOutputFileName(test); + + if ( ofile.empty() ) { - std::string log = "Cannot find memory tester output file: " - + this->MemoryTesterOutputFile; - cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } - std::ifstream ifs(this->MemoryTesterOutputFile.c_str()); + std::ifstream ifs(ofile.c_str()); if ( !ifs ) { - std::string log = "Cannot read memory tester output file: " - + this->MemoryTesterOutputFile; + std::string log = "Cannot read memory tester output file: " + ofile; cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } @@ -981,3 +998,25 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res) res.Output += "\n"; } } + +cmStdString +cmCTestMemCheckHandler::testOutputFileName(int test) +{ + cmStdString index; + cmOStringStream stream; + stream << test; + index = stream.str(); + cmStdString ofile = this->MemoryTesterOutputFile; + cmStdString::size_type pos = ofile.find("??"); + ofile.replace(pos, 2, index); + + if ( !cmSystemTools::FileExists(ofile.c_str()) ) + { + std::string log = "Cannot find memory tester output file: " + + ofile; + cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); + ofile = ""; + } + + return ofile; +} |