summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-10-17 20:43:02 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-10-17 20:43:02 (GMT)
commita2871e93ee7782838ae59ff91e42a2ce967e8ce0 (patch)
tree099554de457573fae7a60c47224d1e6d77cc4d66 /Source/CTest
parenta56b8e436f4f7e90f62c83fc6e9a1374e73c0624 (diff)
parent995a35fe12e9582c4488a7bc2deb66b0e4d25315 (diff)
downloadCMake-a2871e93ee7782838ae59ff91e42a2ce967e8ce0.zip
CMake-a2871e93ee7782838ae59ff91e42a2ce967e8ce0.tar.gz
CMake-a2871e93ee7782838ae59ff91e42a2ce967e8ce0.tar.bz2
Merge topic 'test-ctest-memcheck'
995a35f CTest: add a check with a quoted memory checker de8bffc CTest: add a test for CTEST_CUSTOM_MEMCHECK_IGNORE d26c9b6 CTest: improve memory checker type detection fcae1da CTest: add tests that simulate memcheck runs 6187876 CTest: fix pre and post test commands with spaces 95bc8aa CTest: fix usage of memory checker with spaces in path
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx173
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx5
2 files changed, 98 insertions, 80 deletions
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index a2a16d3..80218ad 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -247,7 +247,8 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
{
std::vector<cmStdString>::size_type pp;
std::string memcheckcommand = "";
- memcheckcommand = this->MemoryTester;
+ memcheckcommand
+ = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ )
{
args.push_back(this->MemoryTesterOptions[pp]);
@@ -410,29 +411,46 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
"MemoryCheckCommand").c_str()) )
{
this->MemoryTester
- = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
- "MemoryCheckCommand").c_str());
+ = this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str();
+
+ // determine the checker type
+ if ( this->MemoryTester.find("valgrind") != std::string::npos )
+ {
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
+ }
+ else if ( this->MemoryTester.find("purify") != std::string::npos )
+ {
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
+ }
+ else if ( this->MemoryTester.find("BC") != std::string::npos )
+ {
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
+ }
+ else
+ {
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN;
+ }
}
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
"PurifyCommand").c_str()) )
{
this->MemoryTester
- = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
- "PurifyCommand").c_str());
+ = this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
}
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
"ValgrindCommand").c_str()) )
{
this->MemoryTester
- = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
- "ValgrindCommand").c_str());
+ = this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
}
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
"BoundsCheckerCommand").c_str()) )
{
this->MemoryTester
- = cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
- "BoundsCheckerCommand").c_str());
+ = this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
+ this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
}
else
{
@@ -470,82 +488,81 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTesterOutputFile
= this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log";
- if ( this->MemoryTester.find("valgrind") != std::string::npos )
+ switch ( this->MemoryTesterStyle )
{
- this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
- if ( this->MemoryTesterOptions.empty() )
- {
- this->MemoryTesterOptions.push_back("-q");
- this->MemoryTesterOptions.push_back("--tool=memcheck");
- this->MemoryTesterOptions.push_back("--leak-check=yes");
- this->MemoryTesterOptions.push_back("--show-reachable=yes");
- this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes");
- this->MemoryTesterOptions.push_back("--num-callers=50");
- }
- if ( this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").size() )
- {
- if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str()) )
+ case cmCTestMemCheckHandler::VALGRIND:
+ if ( this->MemoryTesterOptions.empty() )
{
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find memory checker suppression file: "
- << this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str() << std::endl);
- return false;
- }
- std::string suppressions = "--suppressions="
- + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
- this->MemoryTesterOptions.push_back(suppressions);
- }
- }
- else if ( this->MemoryTester.find("purify") != std::string::npos )
- {
- this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
- std::string outputFile;
-#ifdef _WIN32
- if( this->CTest->GetCTestConfiguration(
+ this->MemoryTesterOptions.push_back("-q");
+ this->MemoryTesterOptions.push_back("--tool=memcheck");
+ this->MemoryTesterOptions.push_back("--leak-check=yes");
+ this->MemoryTesterOptions.push_back("--show-reachable=yes");
+ this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes");
+ this->MemoryTesterOptions.push_back("--num-callers=50");
+ }
+ if ( this->CTest->GetCTestConfiguration(
"MemoryCheckSuppressionFile").size() )
+ {
+ if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile").c_str()) )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot find memory checker suppression file: "
+ << this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile").c_str() << std::endl);
+ return false;
+ }
+ std::string suppressions = "--suppressions="
+ + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
+ this->MemoryTesterOptions.push_back(suppressions);
+ }
+ break;
+ case cmCTestMemCheckHandler::PURIFY:
{
- if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str()) )
+ std::string outputFile;
+#ifdef _WIN32
+ if( this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile").size() )
{
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot find memory checker suppression file: "
- << this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str() << std::endl);
- return false;
- }
- std::string filterFiles = "/FilterFiles="
- + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
- this->MemoryTesterOptions.push_back(filterFiles);
- }
- outputFile = "/SAVETEXTDATA=";
+ if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile").c_str()) )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot find memory checker suppression file: "
+ << this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile").c_str() << std::endl);
+ return false;
+ }
+ std::string filterFiles = "/FilterFiles="
+ + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
+ this->MemoryTesterOptions.push_back(filterFiles);
+ }
+ outputFile = "/SAVETEXTDATA=";
#else
- outputFile = "-log-file=";
+ outputFile = "-log-file=";
#endif
- outputFile += this->MemoryTesterOutputFile;
- this->MemoryTesterOptions.push_back(outputFile);
- }
- else if ( this->MemoryTester.find("BC") != std::string::npos )
- {
- this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
- std::string dpbdFile = this->CTest->GetBinaryDir()
- + "/Testing/Temporary/MemoryChecker.DPbd";
- this->BoundsCheckerDPBDFile = dpbdFile;
- this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
- this->MemoryTesterOptions.push_back("/B");
- this->MemoryTesterOptions.push_back(dpbdFile);
- this->MemoryTesterOptions.push_back("/X");
- this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile);
- this->MemoryTesterOptions.push_back("/M");
- }
- else
- {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Do not understand memory checker: " << this->MemoryTester.c_str()
- << std::endl);
- return false;
+ outputFile += this->MemoryTesterOutputFile;
+ this->MemoryTesterOptions.push_back(outputFile);
+ break;
+ }
+ case cmCTestMemCheckHandler::BOUNDS_CHECKER:
+ {
+ this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
+ std::string dpbdFile = this->CTest->GetBinaryDir()
+ + "/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->MemoryTesterOptions.push_back("/M");
+ break;
+ }
+ default:
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Do not understand memory checker: " << this->MemoryTester.c_str()
+ << std::endl);
+ return false;
}
std::vector<cmStdString>::size_type cc;
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index ead449e..b796b83 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1304,9 +1304,10 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec)
for ( it = vec.begin(); it != vec.end(); ++it )
{
int retVal = 0;
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it
+ std::string cmd = cmSystemTools::ConvertToOutputPath(it->c_str());
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << cmd
<< std::endl);
- if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0,
+ if ( !cmSystemTools::RunSingleCommand(cmd.c_str(), 0, &retVal, 0,
cmSystemTools::OUTPUT_MERGE
/*this->Verbose*/) || retVal != 0 )
{