2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2005-01-27 23:54:47 +03:00
|
|
|
|
|
|
|
#include "cmCTestMemCheckHandler.h"
|
2007-07-24 22:43:31 +04:00
|
|
|
#include "cmXMLParser.h"
|
2005-01-27 23:54:47 +03:00
|
|
|
#include "cmCTest.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include <cmsys/Process.h>
|
|
|
|
#include <cmsys/RegularExpression.hxx>
|
|
|
|
#include <cmsys/Base64.h>
|
|
|
|
#include "cmMakefile.h"
|
2009-02-06 00:31:37 +03:00
|
|
|
#include "cmXMLSafe.h"
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
#include <stdlib.h>
|
2005-01-27 23:54:47 +03:00
|
|
|
#include <math.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
2007-07-24 22:43:31 +04:00
|
|
|
struct CatToErrorType
|
|
|
|
{
|
|
|
|
const char* ErrorCategory;
|
|
|
|
int ErrorCode;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static CatToErrorType cmCTestMemCheckBoundsChecker[] = {
|
|
|
|
// Error tags
|
|
|
|
{"Write Overrun", cmCTestMemCheckHandler::ABW},
|
|
|
|
{"Read Overrun", cmCTestMemCheckHandler::ABR},
|
|
|
|
{"Memory Overrun", cmCTestMemCheckHandler::ABW},
|
|
|
|
{"Allocation Conflict", cmCTestMemCheckHandler::FMM},
|
|
|
|
{"Bad Pointer Use", cmCTestMemCheckHandler::FMW},
|
|
|
|
{"Dangling Pointer", cmCTestMemCheckHandler::FMR},
|
|
|
|
{0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
// parse the xml file storing the installed version of Xcode on
|
|
|
|
// the machine
|
|
|
|
class cmBoundsCheckerParser : public cmXMLParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmBoundsCheckerParser(cmCTest* c) { this->CTest = c;}
|
|
|
|
void StartElement(const char* name, const char** atts)
|
|
|
|
{
|
|
|
|
if(strcmp(name, "MemoryLeak") == 0)
|
|
|
|
{
|
|
|
|
this->Errors.push_back(cmCTestMemCheckHandler::MLK);
|
|
|
|
}
|
|
|
|
if(strcmp(name, "ResourceLeak") == 0)
|
|
|
|
{
|
|
|
|
this->Errors.push_back(cmCTestMemCheckHandler::MLK);
|
|
|
|
}
|
|
|
|
if(strcmp(name, "Error") == 0)
|
|
|
|
{
|
|
|
|
this->ParseError(atts);
|
|
|
|
}
|
|
|
|
if(strcmp(name, "Dangling Pointer") == 0)
|
|
|
|
{
|
|
|
|
this->ParseError(atts);
|
|
|
|
}
|
|
|
|
// Create the log
|
|
|
|
cmOStringStream ostr;
|
|
|
|
ostr << name << ":\n";
|
|
|
|
int i = 0;
|
|
|
|
for(; atts[i] != 0; i+=2)
|
|
|
|
{
|
2009-02-06 00:31:37 +03:00
|
|
|
ostr << " " << cmXMLSafe(atts[i])
|
|
|
|
<< " - " << cmXMLSafe(atts[i+1]) << "\n";
|
2007-07-24 22:43:31 +04:00
|
|
|
}
|
|
|
|
ostr << "\n";
|
|
|
|
this->Log += ostr.str();
|
|
|
|
}
|
|
|
|
void EndElement(const char* )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* GetAttribute(const char* name, const char** atts)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for(; atts[i] != 0; ++i)
|
|
|
|
{
|
|
|
|
if(strcmp(name, atts[i]) == 0)
|
|
|
|
{
|
|
|
|
return atts[i+1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
void ParseError(const char** atts)
|
|
|
|
{
|
|
|
|
CatToErrorType* ptr = cmCTestMemCheckBoundsChecker;
|
|
|
|
const char* cat = this->GetAttribute("ErrorCategory", atts);
|
|
|
|
if(!cat)
|
|
|
|
{
|
|
|
|
this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"No Category found in Bounds checker XML\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while(ptr->ErrorCategory && cat)
|
|
|
|
{
|
|
|
|
if(strcmp(ptr->ErrorCategory, cat) == 0)
|
|
|
|
{
|
|
|
|
this->Errors.push_back(ptr->ErrorCode);
|
|
|
|
return; // found it we are done
|
|
|
|
}
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
if(ptr->ErrorCategory)
|
|
|
|
{
|
|
|
|
this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"Found unknown Bounds Checker error "
|
|
|
|
<< ptr->ErrorCategory << std::endl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmCTest* CTest;
|
|
|
|
std::vector<int> Errors;
|
|
|
|
std::string Log;
|
|
|
|
};
|
|
|
|
|
2007-07-27 18:55:24 +04:00
|
|
|
#define BOUNDS_CHECKER_MARKER \
|
|
|
|
"******######*****Begin BOUNDS CHECKER XML******######******"
|
2005-01-27 23:54:47 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
static const char* cmCTestMemCheckResultStrings[] = {
|
|
|
|
"ABR",
|
|
|
|
"ABW",
|
|
|
|
"ABWL",
|
|
|
|
"COR",
|
|
|
|
"EXU",
|
|
|
|
"FFM",
|
|
|
|
"FIM",
|
|
|
|
"FMM",
|
|
|
|
"FMR",
|
|
|
|
"FMW",
|
|
|
|
"FUM",
|
|
|
|
"IPR",
|
|
|
|
"IPW",
|
|
|
|
"MAF",
|
|
|
|
"MLK",
|
|
|
|
"MPK",
|
|
|
|
"NPR",
|
|
|
|
"ODS",
|
|
|
|
"PAR",
|
|
|
|
"PLK",
|
|
|
|
"UMC",
|
|
|
|
"UMR",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2007-07-24 22:43:31 +04:00
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
static const char* cmCTestMemCheckResultLongStrings[] = {
|
|
|
|
"Threading Problem",
|
|
|
|
"ABW",
|
|
|
|
"ABWL",
|
|
|
|
"COR",
|
|
|
|
"EXU",
|
|
|
|
"FFM",
|
|
|
|
"FIM",
|
|
|
|
"Mismatched deallocation",
|
|
|
|
"FMR",
|
|
|
|
"FMW",
|
|
|
|
"FUM",
|
|
|
|
"IPR",
|
|
|
|
"IPW",
|
|
|
|
"MAF",
|
|
|
|
"Memory Leak",
|
|
|
|
"Potential Memory Leak",
|
|
|
|
"NPR",
|
|
|
|
"ODS",
|
|
|
|
"Invalid syscall param",
|
|
|
|
"PLK",
|
|
|
|
"Uninitialized Memory Conditional",
|
|
|
|
"Uninitialized Memory Read",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
cmCTestMemCheckHandler::cmCTestMemCheckHandler()
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemCheck = true;
|
2006-03-16 19:29:12 +03:00
|
|
|
this->CustomMaximumPassedTestOutputSize = 0;
|
|
|
|
this->CustomMaximumFailedTestOutputSize = 0;
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
|
2005-06-17 21:04:56 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void cmCTestMemCheckHandler::Initialize()
|
|
|
|
{
|
|
|
|
this->Superclass::Initialize();
|
2007-08-11 00:28:48 +04:00
|
|
|
this->CustomMaximumPassedTestOutputSize = 0;
|
|
|
|
this->CustomMaximumFailedTestOutputSize = 0;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTester = "";
|
2010-08-18 18:14:09 +04:00
|
|
|
this->MemoryTesterOptions.clear();
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterStyle = UNKNOWN;
|
|
|
|
this->MemoryTesterOutputFile = "";
|
2005-06-17 21:04:56 +04:00
|
|
|
int cc;
|
|
|
|
for ( cc = 0; cc < NO_MEMORY_FAULT; cc ++ )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterGlobalResults[cc] = 0;
|
2005-06-17 21:04:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int cmCTestMemCheckHandler::PreProcessHandler()
|
|
|
|
{
|
|
|
|
if ( !this->InitializeMemoryChecking() )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( !this->ExecuteCommands(this->CustomPreMemCheck) )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +03:00
|
|
|
"Problem executing pre-memcheck command(s)." << std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int cmCTestMemCheckHandler::PostProcessHandler()
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( !this->ExecuteCommands(this->CustomPostMemCheck) )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +03:00
|
|
|
"Problem executing post-memcheck command(s)." << std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2006-03-09 19:17:10 +03:00
|
|
|
void cmCTestMemCheckHandler::GenerateTestCommand(
|
2009-08-28 23:08:03 +04:00
|
|
|
std::vector<std::string>& args)
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
std::vector<cmStdString>::size_type pp;
|
|
|
|
std::string memcheckcommand = "";
|
2006-03-10 23:03:09 +03:00
|
|
|
memcheckcommand = this->MemoryTester;
|
2010-08-18 18:14:09 +04:00
|
|
|
for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2010-08-18 18:14:09 +04:00
|
|
|
args.push_back(this->MemoryTesterOptions[pp]);
|
|
|
|
memcheckcommand += " \"";
|
|
|
|
memcheckcommand += this->MemoryTesterOptions[pp];
|
|
|
|
memcheckcommand += "\"";
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< memcheckcommand << std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
|
|
|
|
{
|
|
|
|
this->cmCTestTestHandler::PopulateCustomVectors(mf);
|
2006-03-29 21:01:24 +04:00
|
|
|
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK",
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CustomPreMemCheck);
|
2006-03-29 21:01:24 +04:00
|
|
|
this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK",
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CustomPostMemCheck);
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2006-03-29 21:01:24 +04:00
|
|
|
this->CTest->PopulateCustomVector(mf,
|
2006-03-09 19:17:10 +03:00
|
|
|
"CTEST_CUSTOM_MEMCHECK_IGNORE",
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CustomTestsIgnore);
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( !this->CTest->GetProduceXML() )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-12 17:11:29 +03:00
|
|
|
this->CTest->StartXML(os, this->AppendXML);
|
2005-01-27 23:54:47 +03:00
|
|
|
os << "<DynamicAnalysis Checker=\"";
|
2006-03-10 23:03:09 +03:00
|
|
|
switch ( this->MemoryTesterStyle )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
case cmCTestMemCheckHandler::VALGRIND:
|
|
|
|
os << "Valgrind";
|
|
|
|
break;
|
|
|
|
case cmCTestMemCheckHandler::PURIFY:
|
|
|
|
os << "Purify";
|
|
|
|
break;
|
|
|
|
case cmCTestMemCheckHandler::BOUNDS_CHECKER:
|
|
|
|
os << "BoundsChecker";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
os << "Unknown";
|
|
|
|
}
|
|
|
|
os << "\">" << std::endl;
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
os << "\t<StartDateTime>" << this->StartTest << "</StartDateTime>\n"
|
2008-01-30 19:17:36 +03:00
|
|
|
<< "\t<StartTestTime>" << this->StartTestTime << "</StartTestTime>\n"
|
|
|
|
<< "\t<TestList>\n";
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestMemCheckHandler::TestResultsVector::size_type cc;
|
|
|
|
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestTestResult *result = &this->TestResults[cc];
|
|
|
|
std::string testPath = result->Path + "/" + result->Name;
|
2009-02-06 00:31:37 +03:00
|
|
|
os << "\t\t<Test>" << cmXMLSafe(
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetShortPathToFile(testPath.c_str()))
|
2005-01-27 23:54:47 +03:00
|
|
|
<< "</Test>" << std::endl;
|
|
|
|
}
|
|
|
|
os << "\t</TestList>\n";
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
2006-03-09 19:17:10 +03:00
|
|
|
"-- Processing memory checking output: ");
|
2006-03-30 22:49:56 +04:00
|
|
|
size_t total = this->TestResults.size();
|
|
|
|
size_t step = total / 10;
|
|
|
|
size_t current = 0;
|
2006-03-10 23:03:09 +03:00
|
|
|
for ( cc = 0; cc < this->TestResults.size(); cc ++ )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestTestResult *result = &this->TestResults[cc];
|
2005-01-27 23:54:47 +03:00
|
|
|
std::string memcheckstr;
|
|
|
|
int memcheckresults[cmCTestMemCheckHandler::NO_MEMORY_FAULT];
|
|
|
|
int kk;
|
2006-03-10 23:03:09 +03:00
|
|
|
bool res = this->ProcessMemCheckOutput(result->Output, memcheckstr,
|
2006-03-09 19:17:10 +03:00
|
|
|
memcheckresults);
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( res && result->Status == cmCTestMemCheckHandler::COMPLETED )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2006-03-16 19:29:12 +03:00
|
|
|
this->CleanTestOutput(memcheckstr,
|
|
|
|
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
|
2009-02-02 21:24:26 +03:00
|
|
|
this->WriteTestResultHeader(os, result);
|
|
|
|
os << "\t\t<Results>" << std::endl;
|
2005-01-27 23:54:47 +03:00
|
|
|
for ( kk = 0; cmCTestMemCheckResultLongStrings[kk]; kk ++ )
|
|
|
|
{
|
|
|
|
if ( memcheckresults[kk] )
|
|
|
|
{
|
2006-03-09 19:17:10 +03:00
|
|
|
os << "\t\t\t<Defect type=\"" << cmCTestMemCheckResultLongStrings[kk]
|
|
|
|
<< "\">"
|
|
|
|
<< memcheckresults[kk]
|
2005-01-27 23:54:47 +03:00
|
|
|
<< "</Defect>" << std::endl;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterGlobalResults[kk] += memcheckresults[kk];
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2011-05-26 22:42:41 +04:00
|
|
|
|
|
|
|
std::string logTag;
|
|
|
|
if(this->CTest->ShouldCompressMemCheckOutput())
|
|
|
|
{
|
|
|
|
this->CTest->CompressString(memcheckstr);
|
|
|
|
logTag = "\t<Log compression=\"gzip\" encoding=\"base64\">\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logTag = "\t<Log>\n";
|
|
|
|
}
|
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
os
|
2005-01-27 23:54:47 +03:00
|
|
|
<< "\t\t</Results>\n"
|
2011-05-26 22:42:41 +04:00
|
|
|
<< logTag << memcheckstr << std::endl
|
2009-02-02 21:24:26 +03:00
|
|
|
<< "\t</Log>\n";
|
|
|
|
this->WriteTestResultFooter(os, result);
|
2005-01-27 23:54:47 +03:00
|
|
|
if ( current < cc )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush);
|
2005-01-27 23:54:47 +03:00
|
|
|
current += step;
|
|
|
|
}
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
os << "\t<DefectList>" << std::endl;
|
|
|
|
for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->MemoryTesterGlobalResults[cc] )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2005-06-01 01:32:40 +04:00
|
|
|
#ifdef cerr
|
|
|
|
# undef cerr
|
|
|
|
#endif
|
2005-01-27 23:54:47 +03:00
|
|
|
std::cerr.width(35);
|
2005-06-01 01:32:40 +04:00
|
|
|
#define cerr no_cerr
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
cmCTestMemCheckResultLongStrings[cc] << " - "
|
|
|
|
<< this->MemoryTesterGlobalResults[cc] << std::endl);
|
2006-03-09 19:17:10 +03:00
|
|
|
os << "\t\t<Defect Type=\"" << cmCTestMemCheckResultLongStrings[cc]
|
|
|
|
<< "\"/>" << std::endl;
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
os << "\t</DefectList>" << std::endl;
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
os << "\t<EndDateTime>" << this->EndTest << "</EndDateTime>" << std::endl;
|
2008-01-30 19:17:36 +03:00
|
|
|
os << "\t<EndTestTime>" << this->EndTestTime
|
|
|
|
<< "</EndTestTime>" << std::endl;
|
2006-03-09 19:17:10 +03:00
|
|
|
os << "<ElapsedMinutes>"
|
2006-03-10 23:03:09 +03:00
|
|
|
<< static_cast<int>(this->ElapsedTestingTime/6)/10.0
|
2005-01-27 23:54:47 +03:00
|
|
|
<< "</ElapsedMinutes>\n";
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
os << "</DynamicAnalysis>" << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->EndXML(os);
|
2005-01-27 23:54:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool cmCTestMemCheckHandler::InitializeMemoryChecking()
|
|
|
|
{
|
|
|
|
// Setup the command
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"MemoryCheckCommand").c_str()) )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTester
|
|
|
|
= cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"MemoryCheckCommand").c_str());
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"PurifyCommand").c_str()) )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTester
|
|
|
|
= cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"PurifyCommand").c_str());
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"ValgrindCommand").c_str()) )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTester
|
|
|
|
= cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"ValgrindCommand").c_str());
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2007-07-24 22:43:31 +04:00
|
|
|
else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
|
|
|
"BoundsCheckerCommand").c_str()) )
|
|
|
|
{
|
|
|
|
this->MemoryTester
|
|
|
|
= cmSystemTools::ConvertToOutputPath(this->CTest->GetCTestConfiguration(
|
|
|
|
"BoundsCheckerCommand").c_str());
|
|
|
|
}
|
2005-01-27 23:54:47 +03:00
|
|
|
else
|
|
|
|
{
|
2006-10-13 18:27:01 +04:00
|
|
|
cmCTestLog(this->CTest, WARNING,
|
2006-03-10 23:03:09 +03:00
|
|
|
"Memory checker (MemoryCheckCommand) "
|
2006-03-09 19:17:10 +03:00
|
|
|
"not set, or cannot find the specified program."
|
2005-06-01 01:32:40 +04:00
|
|
|
<< std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->MemoryTester[0] == '\"' &&
|
|
|
|
this->MemoryTester[this->MemoryTester.size()-1] == '\"' )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTester
|
|
|
|
= this->MemoryTester.substr(1, this->MemoryTester.size()-2);
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the options
|
2010-08-18 18:14:09 +04:00
|
|
|
std::string memoryTesterOptions;
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->CTest->GetCTestConfiguration(
|
|
|
|
"MemoryCheckCommandOptions").size() )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2010-08-18 18:14:09 +04:00
|
|
|
memoryTesterOptions = this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"MemoryCheckCommandOptions");
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( this->CTest->GetCTestConfiguration(
|
|
|
|
"ValgrindCommandOptions").size() )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2010-08-18 18:14:09 +04:00
|
|
|
memoryTesterOptions = this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"ValgrindCommandOptions");
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2010-08-18 18:14:09 +04:00
|
|
|
this->MemoryTesterOptions
|
|
|
|
= cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterOutputFile
|
|
|
|
= this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log";
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->MemoryTester.find("valgrind") != std::string::npos )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
|
2010-08-18 18:14:09 +04:00
|
|
|
if ( this->MemoryTesterOptions.empty() )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2010-08-18 18:14:09 +04:00
|
|
|
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");
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->CTest->GetCTestConfiguration(
|
|
|
|
"MemoryCheckSuppressionFile").size() )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"MemoryCheckSuppressionFile").c_str()) )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +03:00
|
|
|
"Cannot find memory checker suppression file: "
|
2006-03-10 23:03:09 +03:00
|
|
|
<< this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"MemoryCheckSuppressionFile").c_str() << std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return false;
|
|
|
|
}
|
2010-08-18 18:14:09 +04:00
|
|
|
std::string suppressions = "--suppressions="
|
|
|
|
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
|
|
|
|
this->MemoryTesterOptions.push_back(suppressions);
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( this->MemoryTester.find("purify") != std::string::npos )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
|
2010-08-18 18:14:09 +04:00
|
|
|
std::string outputFile;
|
2005-01-27 23:54:47 +03:00
|
|
|
#ifdef _WIN32
|
2009-05-27 19:14:08 +04:00
|
|
|
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;
|
|
|
|
}
|
2010-08-18 18:14:09 +04:00
|
|
|
std::string filterFiles = "/FilterFiles="
|
|
|
|
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
|
|
|
|
this->MemoryTesterOptions.push_back(filterFiles);
|
2009-05-27 19:14:08 +04:00
|
|
|
}
|
2010-08-18 18:14:09 +04:00
|
|
|
outputFile = "/SAVETEXTDATA=";
|
2005-01-27 23:54:47 +03:00
|
|
|
#else
|
2010-08-18 18:14:09 +04:00
|
|
|
outputFile = "-log-file=";
|
2005-01-27 23:54:47 +03:00
|
|
|
#endif
|
2010-08-18 18:14:09 +04:00
|
|
|
outputFile += this->MemoryTesterOutputFile;
|
|
|
|
this->MemoryTesterOptions.push_back(outputFile);
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
2007-07-24 22:43:31 +04:00
|
|
|
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;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
|
2010-08-18 18:14:09 +04:00
|
|
|
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");
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"Do not understand memory checker: " << this->MemoryTester.c_str()
|
|
|
|
<< std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<cmStdString>::size_type cc;
|
|
|
|
for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MemoryTesterGlobalResults[cc] = 0;
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2006-03-09 19:17:10 +03:00
|
|
|
bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str,
|
2005-01-27 23:54:47 +03:00
|
|
|
std::string& log, int* results)
|
|
|
|
{
|
|
|
|
std::string::size_type cc;
|
|
|
|
for ( cc = 0; cc < cmCTestMemCheckHandler::NO_MEMORY_FAULT; cc ++ )
|
|
|
|
{
|
|
|
|
results[cc] = 0;
|
|
|
|
}
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
return this->ProcessMemCheckValgrindOutput(str, log, results);
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
return this->ProcessMemCheckPurifyOutput(str, log, results);
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( this->MemoryTesterStyle ==
|
|
|
|
cmCTestMemCheckHandler::BOUNDS_CHECKER )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
2007-07-24 22:43:31 +04:00
|
|
|
return this->ProcessMemCheckBoundsCheckerOutput(str, log, results);
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
log.append("\nMemory checking style used was: ");
|
|
|
|
log.append("None that I know");
|
|
|
|
log = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
|
2007-07-24 22:43:31 +04:00
|
|
|
const std::string& str, std::string& log,
|
2005-01-27 23:54:47 +03:00
|
|
|
int* results)
|
2007-07-24 22:43:31 +04:00
|
|
|
{
|
|
|
|
std::vector<cmStdString> lines;
|
|
|
|
cmSystemTools::Split(str.c_str(), lines);
|
2005-01-27 23:54:47 +03:00
|
|
|
cmOStringStream ostr;
|
|
|
|
log = "";
|
|
|
|
|
|
|
|
cmsys::RegularExpression pfW("^\\[[WEI]\\] ([A-Z][A-Z][A-Z][A-Z]*): ");
|
|
|
|
|
|
|
|
int defects = 0;
|
|
|
|
|
2007-07-24 22:43:31 +04:00
|
|
|
for( std::vector<cmStdString>::iterator i = lines.begin();
|
|
|
|
i != lines.end(); ++i)
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
|
2007-07-24 22:43:31 +04:00
|
|
|
if ( pfW.find(*i) )
|
2005-01-27 23:54:47 +03:00
|
|
|
{
|
|
|
|
int cc;
|
|
|
|
for ( cc = 0; cc < cmCTestMemCheckHandler::NO_MEMORY_FAULT; cc ++ )
|
|
|
|
{
|
|
|
|
if ( pfW.match(1) == cmCTestMemCheckResultStrings[cc] )
|
|
|
|
{
|
|
|
|
failure = cc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( cc == cmCTestMemCheckHandler::NO_MEMORY_FAULT )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown Purify memory fault: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< pfW.match(1) << std::endl);
|
|
|
|
ostr << "*** Unknown Purify memory fault: " << pfW.match(1)
|
|
|
|
<< std::endl;
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( failure != NO_MEMORY_FAULT )
|
|
|
|
{
|
|
|
|
ostr << "<b>" << cmCTestMemCheckResultStrings[failure] << "</b> ";
|
|
|
|
results[failure] ++;
|
|
|
|
defects ++;
|
|
|
|
}
|
2009-02-06 00:31:37 +03:00
|
|
|
ostr << cmXMLSafe(*i) << std::endl;
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
log = ostr.str();
|
|
|
|
if ( defects )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
|
2006-03-09 19:17:10 +03:00
|
|
|
const std::string& str, std::string& log,
|
2005-01-27 23:54:47 +03:00
|
|
|
int* results)
|
|
|
|
{
|
|
|
|
std::vector<cmStdString> lines;
|
|
|
|
cmSystemTools::Split(str.c_str(), lines);
|
2007-07-27 00:38:00 +04:00
|
|
|
bool unlimitedOutput = false;
|
|
|
|
if(str.find("CTEST_FULL_OUTPUT") != str.npos ||
|
|
|
|
this->CustomMaximumFailedTestOutputSize == 0)
|
|
|
|
{
|
|
|
|
unlimitedOutput = true;
|
|
|
|
}
|
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
std::string::size_type cc;
|
|
|
|
|
|
|
|
cmOStringStream ostr;
|
|
|
|
log = "";
|
|
|
|
|
|
|
|
int defects = 0;
|
|
|
|
|
|
|
|
cmsys::RegularExpression valgrindLine("^==[0-9][0-9]*==");
|
|
|
|
|
|
|
|
cmsys::RegularExpression vgFIM(
|
|
|
|
"== .*Invalid free\\(\\) / delete / delete\\[\\]");
|
|
|
|
cmsys::RegularExpression vgFMM(
|
|
|
|
"== .*Mismatched free\\(\\) / delete / delete \\[\\]");
|
2009-10-29 15:38:04 +03:00
|
|
|
cmsys::RegularExpression vgMLK1(
|
2011-06-09 16:15:43 +04:00
|
|
|
"== .*[0-9,]+ bytes in [0-9,]+ blocks are definitely lost"
|
|
|
|
" in loss record [0-9,]+ of [0-9,]+");
|
2009-10-29 15:38:04 +03:00
|
|
|
cmsys::RegularExpression vgMLK2(
|
2011-06-09 16:15:43 +04:00
|
|
|
"== .*[0-9,]+ \\([0-9,]+ direct, [0-9,]+ indirect\\)"
|
|
|
|
" bytes in [0-9,]+ blocks are definitely lost"
|
|
|
|
" in loss record [0-9,]+ of [0-9,]+");
|
2005-01-27 23:54:47 +03:00
|
|
|
cmsys::RegularExpression vgPAR(
|
|
|
|
"== .*Syscall param .* contains unaddressable byte\\(s\\)");
|
|
|
|
cmsys::RegularExpression vgMPK1(
|
2011-06-09 16:15:43 +04:00
|
|
|
"== .*[0-9,]+ bytes in [0-9,]+ blocks are possibly lost in"
|
|
|
|
" loss record [0-9,]+ of [0-9,]+");
|
2005-01-27 23:54:47 +03:00
|
|
|
cmsys::RegularExpression vgMPK2(
|
2011-06-09 16:15:43 +04:00
|
|
|
"== .*[0-9,]+ bytes in [0-9,]+ blocks are still reachable"
|
|
|
|
" in loss record [0-9,]+ of [0-9,]+");
|
2005-01-27 23:54:47 +03:00
|
|
|
cmsys::RegularExpression vgUMC(
|
|
|
|
"== .*Conditional jump or move depends on uninitialised value\\(s\\)");
|
2006-03-09 19:17:10 +03:00
|
|
|
cmsys::RegularExpression vgUMR1(
|
2011-06-09 16:15:43 +04:00
|
|
|
"== .*Use of uninitialised value of size [0-9,]+");
|
|
|
|
cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9,]+");
|
2005-01-27 23:54:47 +03:00
|
|
|
cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address ");
|
2006-03-09 19:17:10 +03:00
|
|
|
cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains "
|
|
|
|
"uninitialised or unaddressable byte\\(s\\)");
|
2007-08-04 00:35:22 +04:00
|
|
|
cmsys::RegularExpression vgUMR5("== .*Syscall param .* uninitialised");
|
2011-06-09 16:15:43 +04:00
|
|
|
cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9,]+");
|
2006-03-09 19:17:10 +03:00
|
|
|
cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
|
|
|
|
"locked by a different thread");
|
2007-07-27 00:38:00 +04:00
|
|
|
std::vector<std::string::size_type> nonValGrindOutput;
|
2005-06-01 01:32:40 +04:00
|
|
|
double sttime = cmSystemTools::GetTime();
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
|
2007-07-27 00:38:00 +04:00
|
|
|
std::string::size_type totalOutputSize = 0;
|
|
|
|
bool outputFull = false;
|
2005-01-27 23:54:47 +03:00
|
|
|
for ( cc = 0; cc < lines.size(); cc ++ )
|
|
|
|
{
|
2007-08-11 00:28:48 +04:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "test line "
|
|
|
|
<< lines[cc] << std::endl);
|
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
if ( valgrindLine.find(lines[cc]) )
|
|
|
|
{
|
2007-08-11 00:28:48 +04:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "valgrind line "
|
|
|
|
<< lines[cc] << std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
|
2006-03-09 19:17:10 +03:00
|
|
|
if ( vgFIM.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::FIM;
|
|
|
|
}
|
|
|
|
else if ( vgFMM.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::FMM;
|
|
|
|
}
|
2009-10-29 15:38:04 +03:00
|
|
|
else if ( vgMLK1.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::MLK;
|
|
|
|
}
|
|
|
|
else if ( vgMLK2.find(lines[cc]) )
|
2006-03-09 19:17:10 +03:00
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::MLK;
|
|
|
|
}
|
|
|
|
else if ( vgPAR.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::PAR;
|
|
|
|
}
|
|
|
|
else if ( vgMPK1.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::MPK;
|
|
|
|
}
|
|
|
|
else if ( vgMPK2.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::MPK;
|
|
|
|
}
|
|
|
|
else if ( vgUMC.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::UMC;
|
|
|
|
}
|
|
|
|
else if ( vgUMR1.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::UMR;
|
|
|
|
}
|
|
|
|
else if ( vgUMR2.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::UMR;
|
|
|
|
}
|
|
|
|
else if ( vgUMR3.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::UMR;
|
|
|
|
}
|
|
|
|
else if ( vgUMR4.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::UMR;
|
|
|
|
}
|
2007-08-04 00:35:22 +04:00
|
|
|
else if ( vgUMR5.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::UMR;
|
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
else if ( vgIPW.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::IPW;
|
|
|
|
}
|
|
|
|
else if ( vgABR.find(lines[cc]) )
|
|
|
|
{
|
|
|
|
failure = cmCTestMemCheckHandler::ABR;
|
|
|
|
}
|
2005-01-27 23:54:47 +03:00
|
|
|
|
|
|
|
if ( failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT )
|
|
|
|
{
|
|
|
|
ostr << "<b>" << cmCTestMemCheckResultStrings[failure] << "</b> ";
|
|
|
|
results[failure] ++;
|
|
|
|
defects ++;
|
|
|
|
}
|
2007-08-11 00:28:48 +04:00
|
|
|
totalOutputSize += lines[cc].size();
|
2009-02-06 00:31:37 +03:00
|
|
|
ostr << cmXMLSafe(lines[cc]) << std::endl;
|
2007-07-27 00:38:00 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nonValGrindOutput.push_back(cc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Now put all all the non valgrind output into the test output
|
|
|
|
if(!outputFull)
|
|
|
|
{
|
|
|
|
for(std::vector<std::string::size_type>::iterator i =
|
|
|
|
nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i)
|
|
|
|
{
|
|
|
|
totalOutputSize += lines[*i].size();
|
2007-08-11 00:28:48 +04:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "before xml safe "
|
|
|
|
<< lines[*i] << std::endl);
|
|
|
|
cmCTestLog(this->CTest, DEBUG, "after xml safe "
|
2009-02-06 00:31:37 +03:00
|
|
|
<< cmXMLSafe(lines[*i]) << std::endl);
|
2007-08-11 00:28:48 +04:00
|
|
|
|
2009-02-06 00:31:37 +03:00
|
|
|
ostr << cmXMLSafe(lines[*i]) << std::endl;
|
2007-07-27 00:38:00 +04:00
|
|
|
if(!unlimitedOutput && totalOutputSize >
|
|
|
|
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
|
|
|
|
{
|
|
|
|
outputFull = true;
|
|
|
|
ostr << "....\n";
|
2007-08-11 00:28:48 +04:00
|
|
|
ostr << "Test Output for this test has been truncated see testing"
|
2007-07-27 18:55:24 +04:00
|
|
|
" machine logs for full output,\n";
|
|
|
|
ostr << "or put CTEST_FULL_OUTPUT in the output of "
|
|
|
|
"this test program.\n";
|
2007-07-27 00:38:00 +04:00
|
|
|
}
|
2005-01-27 23:54:47 +03:00
|
|
|
}
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "End test (elapsed: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< (cmSystemTools::GetTime() - sttime) << std::endl);
|
2005-01-27 23:54:47 +03:00
|
|
|
log = ostr.str();
|
|
|
|
if ( defects )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2007-07-24 22:43:31 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
|
|
|
|
const std::string& str, std::string& log,
|
|
|
|
int* results)
|
|
|
|
{
|
|
|
|
log = "";
|
|
|
|
double sttime = cmSystemTools::GetTime();
|
|
|
|
std::vector<cmStdString> lines;
|
|
|
|
cmSystemTools::Split(str.c_str(), lines);
|
|
|
|
cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
|
|
|
|
std::vector<cmStdString>::size_type cc;
|
|
|
|
for ( cc = 0; cc < lines.size(); cc ++ )
|
|
|
|
{
|
|
|
|
if(lines[cc] == BOUNDS_CHECKER_MARKER)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmBoundsCheckerParser parser(this->CTest);
|
|
|
|
parser.InitializeParser();
|
|
|
|
if(cc < lines.size())
|
|
|
|
{
|
|
|
|
for(cc++; cc < lines.size(); ++cc)
|
|
|
|
{
|
|
|
|
std::string& theLine = lines[cc];
|
|
|
|
// check for command line arguments that are not escaped
|
|
|
|
// correctly by BC
|
|
|
|
if(theLine.find("TargetArgs=") != theLine.npos)
|
|
|
|
{
|
|
|
|
// skip this because BC gets it wrong and we can't parse it
|
|
|
|
}
|
|
|
|
else if(!parser.ParseChunk(theLine.c_str(), theLine.size()))
|
|
|
|
{
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"Error in ParseChunk: " << theLine.c_str()
|
|
|
|
<< std::endl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int defects = 0;
|
|
|
|
for(cc =0; cc < parser.Errors.size(); ++cc)
|
|
|
|
{
|
|
|
|
results[parser.Errors[cc]]++;
|
|
|
|
defects++;
|
|
|
|
}
|
|
|
|
cmCTestLog(this->CTest, DEBUG, "End test (elapsed: "
|
|
|
|
<< (cmSystemTools::GetTime() - sttime) << std::endl);
|
|
|
|
if(defects)
|
|
|
|
{
|
|
|
|
// only put the output of Bounds Checker if there were
|
|
|
|
// errors or leaks detected
|
|
|
|
log = parser.Log;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method puts the bounds checker output file into the output
|
|
|
|
// for the test
|
|
|
|
void
|
|
|
|
cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res)
|
|
|
|
{
|
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
|
|
|
"PostProcessBoundsCheckerTest for : "
|
|
|
|
<< res.Name.c_str() << std::endl);
|
|
|
|
if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) )
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
if ( !ifs )
|
|
|
|
{
|
2007-07-27 18:55:24 +04:00
|
|
|
std::string log = "Cannot read memory tester output file: "
|
|
|
|
+ this->MemoryTesterOutputFile;
|
2007-07-24 22:43:31 +04:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
res.Output += BOUNDS_CHECKER_MARKER;
|
|
|
|
res.Output += "\n";
|
|
|
|
std::string line;
|
|
|
|
while ( cmSystemTools::GetLineFromStream(ifs, line) )
|
|
|
|
{
|
|
|
|
res.Output += line;
|
|
|
|
res.Output += "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmSystemTools::Delay(1000);
|
|
|
|
cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str());
|
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
|
|
|
|
<< this->BoundsCheckerDPBDFile.c_str() << std::endl);
|
|
|
|
cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str());
|
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
|
|
|
|
<< this->BoundsCheckerXMLFile.c_str() << std::endl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res)
|
|
|
|
{
|
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
|
|
|
"PostProcessPurifyTest for : "
|
|
|
|
<< res.Name.c_str() << std::endl);
|
|
|
|
if ( !cmSystemTools::FileExists(this->MemoryTesterOutputFile.c_str()) )
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
if ( !ifs )
|
|
|
|
{
|
2007-07-27 18:55:24 +04:00
|
|
|
std::string log = "Cannot read memory tester output file: "
|
|
|
|
+ this->MemoryTesterOutputFile;
|
2007-07-24 22:43:31 +04:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string line;
|
|
|
|
while ( cmSystemTools::GetLineFromStream(ifs, line) )
|
|
|
|
{
|
|
|
|
res.Output += line;
|
2009-05-27 19:14:08 +04:00
|
|
|
res.Output += "\n";
|
2007-07-24 22:43:31 +04:00
|
|
|
}
|
|
|
|
}
|