BUG: Fixed segfault and bad reporting if a ctest executable could not be found. Also added some batch testing code that is not yet complete.

This commit is contained in:
Zach Mullen 2009-09-10 11:16:08 -04:00
parent 55e4ac5ad1
commit 4b4e801eba
6 changed files with 38 additions and 48 deletions

View File

@ -342,6 +342,7 @@ INCLUDE_DIRECTORIES(
# #
SET(CTEST_SRCS cmCTest.cxx SET(CTEST_SRCS cmCTest.cxx
CTest/cmProcess.cxx CTest/cmProcess.cxx
CTest/cmCTestBatchTestHandler.cxx
CTest/cmCTestBuildAndTestHandler.cxx CTest/cmCTestBuildAndTestHandler.cxx
CTest/cmCTestBuildCommand.cxx CTest/cmCTestBuildCommand.cxx
CTest/cmCTestBuildHandler.cxx CTest/cmCTestBuildHandler.cxx

View File

@ -27,6 +27,11 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
this->Completed = 0; this->Completed = 0;
this->RunningCount = 0; this->RunningCount = 0;
} }
cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler()
{
}
// Set the tests // Set the tests
void void
cmCTestMultiProcessHandler::SetTests(TestMap& tests, cmCTestMultiProcessHandler::SetTests(TestMap& tests,
@ -55,11 +60,6 @@ void cmCTestMultiProcessHandler::SetParallelLevel(size_t level)
//--------------------------------------------------------- //---------------------------------------------------------
void cmCTestMultiProcessHandler::RunTests() void cmCTestMultiProcessHandler::RunTests()
{ {
if(this->CTest->GetBatchJobs())
{
this->SubmitBatchTests();
return;
}
this->CheckResume(); this->CheckResume();
this->TestHandler->SetMaxIndex(this->FindMaxIndex()); this->TestHandler->SetMaxIndex(this->FindMaxIndex());
this->StartNextTests(); this->StartNextTests();
@ -75,18 +75,6 @@ void cmCTestMultiProcessHandler::RunTests()
this->MarkFinished(); this->MarkFinished();
} }
//---------------------------------------------------------
void cmCTestMultiProcessHandler::SubmitBatchTests()
{
for(cmCTest::CTestConfigurationMap::iterator i =
this->CTest->CTestConfiguration.begin();
i != this->CTest->CTestConfiguration.end(); ++i)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, i->first
<< " = " << i->second << std::endl);
}
}
//--------------------------------------------------------- //---------------------------------------------------------
void cmCTestMultiProcessHandler::StartTestProcess(int test) void cmCTestMultiProcessHandler::StartTestProcess(int test)
{ {

View File

@ -36,13 +36,13 @@ public:
std::map<int, cmCTestTestHandler::cmCTestTestProperties*> {}; std::map<int, cmCTestTestHandler::cmCTestTestProperties*> {};
cmCTestMultiProcessHandler(); cmCTestMultiProcessHandler();
virtual ~cmCTestMultiProcessHandler();
// Set the tests // Set the tests
void SetTests(TestMap& tests, PropertiesMap& properties); void SetTests(TestMap& tests, PropertiesMap& properties);
// Set the max number of tests that can be run at the same time. // Set the max number of tests that can be run at the same time.
void SetParallelLevel(size_t); void SetParallelLevel(size_t);
void RunTests(); virtual void RunTests();
void PrintTestList(); void PrintTestList();
void SubmitBatchTests();
void SetPassFailVectors(std::vector<cmStdString>* passed, void SetPassFailVectors(std::vector<cmStdString>* passed,
std::vector<cmStdString>* failed) std::vector<cmStdString>* failed)

View File

@ -92,9 +92,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
this->WriteLogOutputTop(completed, total); this->WriteLogOutputTop(completed, total);
std::string reason; std::string reason;
bool passed = true; bool passed = true;
int res = this->TestProcess->GetProcessStatus(); int res = started ? this->TestProcess->GetProcessStatus()
: cmsysProcess_State_Error;
int retVal = this->TestProcess->GetExitValue(); int retVal = this->TestProcess->GetExitValue();
std::vector<std::pair<cmsys::RegularExpression, std::vector<std::pair<cmsys::RegularExpression,
std::string> >::iterator passIt; std::string> >::iterator passIt;
bool forceFail = false; bool forceFail = false;
@ -197,7 +197,6 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
} }
passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED; passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED;
char buf[1024]; char buf[1024];
sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime()); sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime());
cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n" ); cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n" );
@ -208,9 +207,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
this->DartProcessing(); this->DartProcessing();
// if this is doing MemCheck then all the output needs to be put into // if this is doing MemCheck then all the output needs to be put into
// Output since that is what is parsed by cmCTestMemCheckHandler // Output since that is what is parsed by cmCTestMemCheckHandler
if(!this->TestHandler->MemCheck) if(!this->TestHandler->MemCheck && started)
{ {
if ( this->TestResult.Status == cmCTestTestHandler::COMPLETED ) if (this->TestResult.Status == cmCTestTestHandler::COMPLETED)
{ {
this->TestHandler->CleanTestOutput(this->ProcessOutput, this->TestHandler->CleanTestOutput(this->ProcessOutput,
static_cast<size_t> static_cast<size_t>
@ -224,7 +223,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
} }
} }
this->TestResult.Reason = reason; this->TestResult.Reason = reason;
if ( this->TestHandler->LogFile ) if (this->TestHandler->LogFile)
{ {
bool pass = true; bool pass = true;
const char* reasonType = "Test Pass Reason"; const char* reasonType = "Test Pass Reason";
@ -272,10 +271,10 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
this->TestResult.ReturnValue = this->TestProcess->GetExitValue(); this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
this->TestResult.CompletionStatus = "Completed"; this->TestResult.CompletionStatus = "Completed";
this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime(); this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
this->TestHandler->TestResults.push_back( this->TestResult ); this->TestHandler->TestResults.push_back(this->TestResult);
}
this->MemCheckPostProcess();
this->MemCheckPostProcess();
}
delete this->TestProcess; delete this->TestProcess;
return passed; return passed;
} }
@ -324,20 +323,18 @@ bool cmCTestRunTest::StartTest()
this->TestResult.Name = this->TestProperties->Name; this->TestResult.Name = this->TestProperties->Name;
this->TestResult.Path = this->TestProperties->Directory.c_str(); this->TestResult.Path = this->TestProperties->Directory.c_str();
// continue if we did not find the executable // log and return if we did not find the executable
if (this->TestCommand == "") if (this->ActualCommand == "")
{ {
this->TestProcess = new cmProcess;
*this->TestHandler->LogFile << "Unable to find executable: " *this->TestHandler->LogFile << "Unable to find executable: "
<< args[1].c_str() << std::endl; << args[1].c_str() << std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: " cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: "
<< args[1].c_str() << std::endl); << args[1].c_str() << std::endl);
this->TestResult.Output = "Unable to find executable: " + args[1]; this->TestResult.Output = "Unable to find executable: " + args[1];
if ( !this->CTest->GetShowOnly() ) this->TestResult.FullCommandLine = "";
{ this->TestHandler->TestResults.push_back(this->TestResult);
this->TestResult.FullCommandLine = this->ActualCommand; return false;
this->TestHandler->TestResults.push_back( this->TestResult );
return false;
}
} }
this->StartTime = this->CTest->CurrentTime(); this->StartTime = this->CTest->CurrentTime();

View File

@ -17,6 +17,7 @@
#include "cmCTestTestHandler.h" #include "cmCTestTestHandler.h"
#include "cmCTestMultiProcessHandler.h" #include "cmCTestMultiProcessHandler.h"
#include "cmCTestBatchTestHandler.h"
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestRunTest.h" #include "cmCTestRunTest.h"
#include "cmake.h" #include "cmake.h"
@ -999,10 +1000,11 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime()); this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
double elapsed_time_start = cmSystemTools::GetTime(); double elapsed_time_start = cmSystemTools::GetTime();
cmCTestMultiProcessHandler parallel; cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs() ?
parallel.SetCTest(this->CTest); new cmCTestBatchTestHandler : new cmCTestMultiProcessHandler;
parallel.SetParallelLevel(this->CTest->GetParallelLevel()); parallel->SetCTest(this->CTest);
parallel.SetTestHandler(this); parallel->SetParallelLevel(this->CTest->GetParallelLevel());
parallel->SetTestHandler(this);
*this->LogFile << "Start testing: " *this->LogFile << "Start testing: "
<< this->CTest->CurrentTime() << std::endl << this->CTest->CurrentTime() << std::endl
@ -1013,7 +1015,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
cmCTestMultiProcessHandler::PropertiesMap properties; cmCTestMultiProcessHandler::PropertiesMap properties;
for (ListOfTests::iterator it = this->TestList.begin(); for (ListOfTests::iterator it = this->TestList.begin();
it != this->TestList.end(); it ++ ) it != this->TestList.end(); ++it)
{ {
cmCTestTestProperties& p = *it; cmCTestTestProperties& p = *it;
cmCTestMultiProcessHandler::TestSet depends; cmCTestMultiProcessHandler::TestSet depends;
@ -1021,10 +1023,10 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
if(p.Depends.size()) if(p.Depends.size())
{ {
for(std::vector<std::string>::iterator i = p.Depends.begin(); for(std::vector<std::string>::iterator i = p.Depends.begin();
i != p.Depends.end(); ++i) i != p.Depends.end(); ++i)
{ {
for(ListOfTests::iterator it2 = this->TestList.begin(); for(ListOfTests::iterator it2 = this->TestList.begin();
it2 != this->TestList.end(); it2 ++ ) it2 != this->TestList.end(); ++it2)
{ {
if(it2->Name == *i) if(it2->Name == *i)
{ {
@ -1037,18 +1039,19 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
tests[it->Index] = depends; tests[it->Index] = depends;
properties[it->Index] = &*it; properties[it->Index] = &*it;
} }
parallel.SetTests(tests, properties); parallel->SetTests(tests, properties);
parallel.SetPassFailVectors(&passed, &failed); parallel->SetPassFailVectors(&passed, &failed);
this->TestResults.clear(); this->TestResults.clear();
parallel.SetTestResults(&this->TestResults); parallel->SetTestResults(&this->TestResults);
if(this->CTest->GetShowOnly()) if(this->CTest->GetShowOnly())
{ {
parallel.PrintTestList(); parallel->PrintTestList();
} }
else else
{ {
parallel.RunTests(); parallel->RunTests();
} }
delete parallel;
this->EndTest = this->CTest->CurrentTime(); this->EndTest = this->CTest->CurrentTime();
this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime()); this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
this->ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start; this->ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start;

View File

@ -32,6 +32,7 @@ class cmCTestTestHandler : public cmCTestGenericHandler
{ {
friend class cmCTestRunTest; friend class cmCTestRunTest;
friend class cmCTestMultiProcessHandler; friend class cmCTestMultiProcessHandler;
friend class cmCTestBatchTestHandler;
public: public:
cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler); cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler);