MemCheck should now work again in ctest
This commit is contained in:
parent
996bb51a1d
commit
b0b5ffcf5c
|
@ -249,15 +249,14 @@ int cmCTestMemCheckHandler::PostProcessHandler()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
void cmCTestMemCheckHandler::GenerateTestCommand(
|
||||
std::vector<const char*>& args)
|
||||
std::vector<std::string>& args)
|
||||
{
|
||||
std::vector<cmStdString>::size_type pp;
|
||||
args.push_back(this->MemoryTester.c_str());
|
||||
std::string memcheckcommand = "";
|
||||
memcheckcommand = this->MemoryTester;
|
||||
for ( pp = 0; pp < this->MemoryTesterOptionsParsed.size(); pp ++ )
|
||||
{
|
||||
args.push_back(this->MemoryTesterOptionsParsed[pp].c_str());
|
||||
args.push_back(this->MemoryTesterOptionsParsed[pp]);
|
||||
memcheckcommand += " ";
|
||||
memcheckcommand += cmSystemTools::EscapeSpaces(
|
||||
this->MemoryTesterOptionsParsed[pp].c_str());
|
||||
|
@ -867,27 +866,6 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
|
|||
}
|
||||
return true;
|
||||
}
|
||||
//TODO ZACH move this logic into cmCTestRunTest
|
||||
void
|
||||
cmCTestMemCheckHandler::ProcessOneTest(cmCTestTestProperties *props,
|
||||
std::vector<cmStdString> &passed,
|
||||
std::vector<cmStdString> &failed,
|
||||
int count, int tmsize)
|
||||
{
|
||||
// run parent test
|
||||
cmCTestTestHandler::ProcessOneTest(props, passed, failed, count, tmsize);
|
||||
cmCTestTestResult& res = this->TestResults[this->TestResults.size()-1];
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "process test output now: "
|
||||
<< props->Name.c_str() << " " << res.Name.c_str() << std::endl);
|
||||
if( this->MemoryTesterStyle == cmCTestMemCheckHandler::BOUNDS_CHECKER)
|
||||
{
|
||||
this->PostProcessBoundsCheckerTest(res);
|
||||
}
|
||||
else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY )
|
||||
{
|
||||
this->PostProcessPurifyTest(res);
|
||||
}
|
||||
}
|
||||
|
||||
// This method puts the bounds checker output file into the output
|
||||
// for the test
|
||||
|
|
|
@ -30,6 +30,7 @@ class cmMakefile;
|
|||
*/
|
||||
class cmCTestMemCheckHandler : public cmCTestTestHandler
|
||||
{
|
||||
friend class cmCTestRunTest;
|
||||
public:
|
||||
cmTypeMacro(cmCTestMemCheckHandler, cmCTestTestHandler);
|
||||
|
||||
|
@ -41,7 +42,7 @@ public:
|
|||
protected:
|
||||
virtual int PreProcessHandler();
|
||||
virtual int PostProcessHandler();
|
||||
virtual void GenerateTestCommand(std::vector<const char*>& args);
|
||||
virtual void GenerateTestCommand(std::vector<std::string>& args);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -121,13 +122,7 @@ private:
|
|||
std::string& log, int* results);
|
||||
bool ProcessMemCheckBoundsCheckerOutput(const std::string& str,
|
||||
std::string& log, int* results);
|
||||
/**
|
||||
* Run one test
|
||||
*/
|
||||
virtual void ProcessOneTest(cmCTestTestProperties *props,
|
||||
std::vector<cmStdString> &passed,
|
||||
std::vector<cmStdString> &failed,
|
||||
int count, int tmsize);
|
||||
|
||||
void PostProcessPurifyTest(cmCTestTestResult& res);
|
||||
void PostProcessBoundsCheckerTest(cmCTestTestResult& res);
|
||||
};
|
||||
|
|
|
@ -247,9 +247,9 @@ void cmCTestMultiProcessHandler::PrintTestList()
|
|||
testRun.SetTestProperties(&p);
|
||||
testRun.ComputeArguments(); //logs the command in verbose mode
|
||||
|
||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3)
|
||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3)
|
||||
<< count << "/");
|
||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3)
|
||||
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3)
|
||||
<< this->Total << " ");
|
||||
if (this->TestHandler->MemCheck)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
=========================================================================*/
|
||||
|
||||
#include "cmCTestRunTest.h"
|
||||
#include "cmCTestMemCheckHandler.h"
|
||||
#include "cmCTest.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
|
@ -245,10 +246,35 @@ bool cmCTestRunTest::EndTest(int completed, int total)
|
|||
this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
|
||||
this->TestHandler->TestResults.push_back( this->TestResult );
|
||||
|
||||
this->MemCheckPostProcess();
|
||||
|
||||
delete this->TestProcess;
|
||||
return passed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void cmCTestRunTest::MemCheckPostProcess()
|
||||
{
|
||||
if(!this->TestHandler->MemCheck)
|
||||
{
|
||||
return;
|
||||
}
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
|
||||
<< ": process test output now: "
|
||||
<< this->TestProperties->Name.c_str() << " "
|
||||
<< this->TestResult.Name.c_str() << std::endl);
|
||||
cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
|
||||
(this->TestHandler);
|
||||
if(handler->MemoryTesterStyle == cmCTestMemCheckHandler::BOUNDS_CHECKER)
|
||||
{
|
||||
handler->PostProcessBoundsCheckerTest(this->TestResult);
|
||||
}
|
||||
else if(handler->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY)
|
||||
{
|
||||
handler->PostProcessPurifyTest(this->TestResult);
|
||||
}
|
||||
}
|
||||
|
||||
void cmCTestRunTest::SetTestHandler(cmCTestTestHandler * handler)
|
||||
{
|
||||
this->TestHandler = handler;
|
||||
|
@ -292,21 +318,36 @@ bool cmCTestRunTest::StartTest()
|
|||
|
||||
void cmCTestRunTest::ComputeArguments()
|
||||
{
|
||||
std::vector<std::string>& args = this->TestProperties->Args;
|
||||
// find the test executable
|
||||
this->ActualCommand
|
||||
= this->TestHandler->FindTheExecutable(args[1].c_str());
|
||||
this->TestCommand
|
||||
= cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
|
||||
// add the arguments
|
||||
std::vector<std::string>::const_iterator j =
|
||||
this->TestProperties->Args.begin();
|
||||
++j; // skip test name
|
||||
++j; // skip command as it is in actualCommand
|
||||
|
||||
//TODO ZACH the problem is here for memcheck. We need to call
|
||||
//memcheckhandler.GenerateTestCommand BEFORE we run the process.
|
||||
// this->TestHandler->GenerateTestCommand(this->Arguments);
|
||||
// find the test executable
|
||||
if(this->TestHandler->MemCheck)
|
||||
{
|
||||
cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
|
||||
(this->TestHandler);
|
||||
this->ActualCommand = handler->MemoryTester.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ActualCommand =
|
||||
this->TestHandler->FindTheExecutable(
|
||||
this->TestProperties->Args[1].c_str());
|
||||
++j; //skip the executable (it will be actualCommand)
|
||||
}
|
||||
this->TestCommand
|
||||
= cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
|
||||
|
||||
//Prepends memcheck args to our command string
|
||||
this->TestHandler->GenerateTestCommand(this->Arguments);
|
||||
for(std::vector<std::string>::iterator i = this->Arguments.begin();
|
||||
i != this->Arguments.end(); ++i)
|
||||
{
|
||||
this->TestCommand += " ";
|
||||
this->TestCommand += cmSystemTools::EscapeSpaces(j->c_str());
|
||||
}
|
||||
|
||||
for(;j != this->TestProperties->Args.end(); ++j)
|
||||
{
|
||||
this->TestCommand += " ";
|
||||
|
@ -413,10 +454,10 @@ void cmCTestRunTest::WriteLogOutputTop(int completed, int total)
|
|||
std::string outname = this->TestProperties->Name + " ";
|
||||
outname.resize(maxTestNameWidth, '.');
|
||||
|
||||
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
|
||||
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
|
||||
<< this->TestHandler->TotalNumberOfTests << " Testing: "
|
||||
<< this->TestProperties->Name << std::endl;
|
||||
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
|
||||
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
|
||||
<< this->TestHandler->TotalNumberOfTests
|
||||
<< " Test: " << this->TestProperties->Name.c_str() << std::endl;
|
||||
*this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\"";
|
||||
|
|
|
@ -64,6 +64,8 @@ private:
|
|||
bool CreateProcess(double testTimeOut,
|
||||
std::vector<std::string>* environment);
|
||||
void WriteLogOutputTop(int completed, int total);
|
||||
//Run post processing of the process output for MemCheck
|
||||
void MemCheckPostProcess();
|
||||
|
||||
cmCTestTestHandler::cmCTestTestProperties * TestProperties;
|
||||
//Pointer back to the "parent"; the handler that invoked this test run
|
||||
|
|
|
@ -709,7 +709,7 @@ void cmCTestTestHandler::PrintLabelSummary()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//----------------------------------------------------------------------
|
||||
void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it,
|
||||
std::vector<cmStdString> &passed,
|
||||
|
@ -791,9 +791,6 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it,
|
|||
}
|
||||
arguments.push_back(0);
|
||||
|
||||
/**
|
||||
* Run an executable command and put the stdout in output.
|
||||
*/
|
||||
std::string output;
|
||||
int retVal = 0;
|
||||
|
||||
|
@ -1026,7 +1023,7 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it,
|
|||
cres.CompletionStatus = "Completed";
|
||||
this->TestResults.push_back( cres );
|
||||
}
|
||||
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it)
|
||||
{
|
||||
|
@ -1363,7 +1360,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void cmCTestTestHandler::GenerateTestCommand(std::vector<const char*>&)
|
||||
void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ protected:
|
|||
// comput a final test list
|
||||
virtual int PreProcessHandler();
|
||||
virtual int PostProcessHandler();
|
||||
virtual void GenerateTestCommand(std::vector<const char*>& args);
|
||||
virtual void GenerateTestCommand(std::vector<std::string>& args);
|
||||
int ExecuteCommands(std::vector<cmStdString>& vec);
|
||||
|
||||
void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result);
|
||||
|
@ -157,17 +157,6 @@ protected:
|
|||
bool MemCheck;
|
||||
int CustomMaximumPassedTestOutputSize;
|
||||
int CustomMaximumFailedTestOutputSize;
|
||||
protected:
|
||||
/**
|
||||
* Run one test
|
||||
*/
|
||||
virtual void ProcessOneTest(cmCTestTestProperties *props,
|
||||
std::vector<cmStdString> &passed,
|
||||
std::vector<cmStdString> &failed,
|
||||
int count, int tmsize);
|
||||
|
||||
|
||||
|
||||
public:
|
||||
enum { // Program statuses
|
||||
NOT_RUN = 0,
|
||||
|
|
Loading…
Reference in New Issue