CTest: improve memory checker type detection
If the checker was explicitely set with a "TypeCommand" variable (e.g. ValgrindCommand) then we now just believe that this is valgrind, even if nothing in the path matches "valgrind". Only when "MemoryCheckCommand" was used we still scan the path to find out what checker we have.
This commit is contained in:
parent
fcae1dacea
commit
d26c9b69c5
|
@ -412,24 +412,45 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
|
||||||
{
|
{
|
||||||
this->MemoryTester
|
this->MemoryTester
|
||||||
= 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(
|
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
||||||
"PurifyCommand").c_str()) )
|
"PurifyCommand").c_str()) )
|
||||||
{
|
{
|
||||||
this->MemoryTester
|
this->MemoryTester
|
||||||
= this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
|
= this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
|
||||||
|
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
|
||||||
}
|
}
|
||||||
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
||||||
"ValgrindCommand").c_str()) )
|
"ValgrindCommand").c_str()) )
|
||||||
{
|
{
|
||||||
this->MemoryTester
|
this->MemoryTester
|
||||||
= this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
|
= this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
|
||||||
|
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
|
||||||
}
|
}
|
||||||
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
||||||
"BoundsCheckerCommand").c_str()) )
|
"BoundsCheckerCommand").c_str()) )
|
||||||
{
|
{
|
||||||
this->MemoryTester
|
this->MemoryTester
|
||||||
= this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
|
= this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
|
||||||
|
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -467,82 +488,81 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
|
||||||
this->MemoryTesterOutputFile
|
this->MemoryTesterOutputFile
|
||||||
= this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log";
|
= this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log";
|
||||||
|
|
||||||
if ( this->MemoryTester.find("valgrind") != std::string::npos )
|
switch ( this->MemoryTesterStyle )
|
||||||
{
|
{
|
||||||
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
|
case cmCTestMemCheckHandler::VALGRIND:
|
||||||
if ( this->MemoryTesterOptions.empty() )
|
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()) )
|
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
this->MemoryTesterOptions.push_back("-q");
|
||||||
"Cannot find memory checker suppression file: "
|
this->MemoryTesterOptions.push_back("--tool=memcheck");
|
||||||
<< this->CTest->GetCTestConfiguration(
|
this->MemoryTesterOptions.push_back("--leak-check=yes");
|
||||||
"MemoryCheckSuppressionFile").c_str() << std::endl);
|
this->MemoryTesterOptions.push_back("--show-reachable=yes");
|
||||||
return false;
|
this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes");
|
||||||
|
this->MemoryTesterOptions.push_back("--num-callers=50");
|
||||||
}
|
}
|
||||||
std::string suppressions = "--suppressions="
|
if ( this->CTest->GetCTestConfiguration(
|
||||||
+ 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(
|
|
||||||
"MemoryCheckSuppressionFile").size() )
|
"MemoryCheckSuppressionFile").size() )
|
||||||
{
|
|
||||||
if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
|
||||||
"MemoryCheckSuppressionFile").c_str()) )
|
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
||||||
"Cannot find memory checker suppression file: "
|
"MemoryCheckSuppressionFile").c_str()) )
|
||||||
<< this->CTest->GetCTestConfiguration(
|
{
|
||||||
"MemoryCheckSuppressionFile").c_str() << std::endl);
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
return false;
|
"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);
|
||||||
}
|
}
|
||||||
std::string filterFiles = "/FilterFiles="
|
break;
|
||||||
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
|
case cmCTestMemCheckHandler::PURIFY:
|
||||||
this->MemoryTesterOptions.push_back(filterFiles);
|
{
|
||||||
}
|
std::string outputFile;
|
||||||
outputFile = "/SAVETEXTDATA=";
|
#ifdef _WIN32
|
||||||
|
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 filterFiles = "/FilterFiles="
|
||||||
|
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
|
||||||
|
this->MemoryTesterOptions.push_back(filterFiles);
|
||||||
|
}
|
||||||
|
outputFile = "/SAVETEXTDATA=";
|
||||||
#else
|
#else
|
||||||
outputFile = "-log-file=";
|
outputFile = "-log-file=";
|
||||||
#endif
|
#endif
|
||||||
outputFile += this->MemoryTesterOutputFile;
|
outputFile += this->MemoryTesterOutputFile;
|
||||||
this->MemoryTesterOptions.push_back(outputFile);
|
this->MemoryTesterOptions.push_back(outputFile);
|
||||||
}
|
break;
|
||||||
else if ( this->MemoryTester.find("BC") != std::string::npos )
|
}
|
||||||
{
|
case cmCTestMemCheckHandler::BOUNDS_CHECKER:
|
||||||
this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
|
{
|
||||||
std::string dpbdFile = this->CTest->GetBinaryDir()
|
this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
|
||||||
+ "/Testing/Temporary/MemoryChecker.DPbd";
|
std::string dpbdFile = this->CTest->GetBinaryDir()
|
||||||
this->BoundsCheckerDPBDFile = dpbdFile;
|
+ "/Testing/Temporary/MemoryChecker.DPbd";
|
||||||
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
|
this->BoundsCheckerDPBDFile = dpbdFile;
|
||||||
this->MemoryTesterOptions.push_back("/B");
|
this->MemoryTesterOptions.push_back("/B");
|
||||||
this->MemoryTesterOptions.push_back(dpbdFile);
|
this->MemoryTesterOptions.push_back(dpbdFile);
|
||||||
this->MemoryTesterOptions.push_back("/X");
|
this->MemoryTesterOptions.push_back("/X");
|
||||||
this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile);
|
this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile);
|
||||||
this->MemoryTesterOptions.push_back("/M");
|
this->MemoryTesterOptions.push_back("/M");
|
||||||
}
|
break;
|
||||||
else
|
}
|
||||||
{
|
default:
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
"Do not understand memory checker: " << this->MemoryTester.c_str()
|
"Do not understand memory checker: " << this->MemoryTester.c_str()
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmStdString>::size_type cc;
|
std::vector<cmStdString>::size_type cc;
|
||||||
|
|
Loading…
Reference in New Issue