summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorZach Mullen <zach.mullen@kitware.com>2009-08-28 19:08:03 (GMT)
committerZach Mullen <zach.mullen@kitware.com>2009-08-28 19:08:03 (GMT)
commitb0b5ffcf5caf85cc47ec6a38e3f3e801f8c73bb0 (patch)
tree9e883593bf4ae6fb0878c56f77e4d88ec09a1927 /Source/CTest
parent996bb51a1d95645cf2274932be19e6a8a81de55b (diff)
downloadCMake-b0b5ffcf5caf85cc47ec6a38e3f3e801f8c73bb0.zip
CMake-b0b5ffcf5caf85cc47ec6a38e3f3e801f8c73bb0.tar.gz
CMake-b0b5ffcf5caf85cc47ec6a38e3f3e801f8c73bb0.tar.bz2
MemCheck should now work again in ctest
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx26
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.h11
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx4
-rw-r--r--Source/CTest/cmCTestRunTest.cxx67
-rw-r--r--Source/CTest/cmCTestRunTest.h2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx9
-rw-r--r--Source/CTest/cmCTestTestHandler.h13
7 files changed, 67 insertions, 65 deletions
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index a0d74a3..60b82e7 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -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
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index 8a9e4e7..c50d0ff 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -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);
};
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 88d1696..157e187 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -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)
{
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 9214a95..bbc23b2 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -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 << "\"";
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index 521759a..1fbe5bb 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -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
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f2e917a..af7c222 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -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>&)
{
}
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 55fb853..4c7cbc8 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -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,