2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2009-08-19 16:58:36 +04: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.
|
2009-08-19 16:58:36 +04: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.
|
|
|
|
============================================================================*/
|
2009-08-19 16:58:36 +04:00
|
|
|
#ifndef cmCTestRunTest_h
|
|
|
|
#define cmCTestRunTest_h
|
|
|
|
|
|
|
|
#include <cmStandardIncludes.h>
|
|
|
|
#include <cmCTestTestHandler.h>
|
2009-08-26 20:09:06 +04:00
|
|
|
#include <cmProcess.h>
|
2009-08-19 16:58:36 +04:00
|
|
|
|
|
|
|
/** \class cmRunTest
|
|
|
|
* \brief represents a single test to be run
|
|
|
|
*
|
|
|
|
* cmRunTest contains the information related to running a single test
|
|
|
|
*/
|
|
|
|
class cmCTestRunTest
|
|
|
|
{
|
|
|
|
public:
|
2009-09-11 18:09:48 +04:00
|
|
|
cmCTestRunTest(cmCTestTestHandler* handler);
|
2009-08-19 16:58:36 +04:00
|
|
|
~cmCTestRunTest();
|
|
|
|
|
|
|
|
void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties * prop)
|
|
|
|
{ this->TestProperties = prop; }
|
|
|
|
|
|
|
|
cmCTestTestHandler::cmCTestTestProperties * GetTestProperties()
|
|
|
|
{ return this->TestProperties; }
|
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
void SetIndex(int i) { this->Index = i; }
|
|
|
|
|
|
|
|
int GetIndex() { return this->Index; }
|
2009-08-19 16:58:36 +04:00
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
std::string GetProcessOutput() { return this->ProcessOutput; }
|
2009-08-19 16:58:36 +04:00
|
|
|
|
|
|
|
cmCTestTestHandler::cmCTestTestResult GetTestResults()
|
|
|
|
{ return this->TestResult; }
|
|
|
|
|
2009-09-11 20:26:41 +04:00
|
|
|
// Read and store output. Returns true if it must be called again.
|
|
|
|
bool CheckOutput();
|
|
|
|
|
2009-12-17 19:14:49 +03:00
|
|
|
// Compresses the output, writing to CompressedOutput
|
|
|
|
void CompressOutput();
|
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
//launch the test process, return whether it started correctly
|
2009-10-05 18:20:52 +04:00
|
|
|
bool StartTest(size_t total);
|
2009-08-28 19:08:39 +04:00
|
|
|
//capture and report the test results
|
2009-09-03 23:33:44 +04:00
|
|
|
bool EndTest(size_t completed, size_t total, bool started);
|
2009-08-28 19:08:39 +04:00
|
|
|
//Called by ctest -N to log the command string
|
|
|
|
void ComputeArguments();
|
2010-02-26 00:23:49 +03:00
|
|
|
|
|
|
|
void ComputeWeightedCost();
|
2009-08-28 19:08:39 +04:00
|
|
|
private:
|
2009-08-26 20:09:06 +04:00
|
|
|
void DartProcessing();
|
2009-12-10 22:38:32 +03:00
|
|
|
void ExeNotFound(std::string exe);
|
2010-03-16 22:33:55 +03:00
|
|
|
// Figures out a final timeout which is min(STOP_TIME, NOW+TIMEOUT)
|
|
|
|
double ResolveTimeout();
|
|
|
|
bool ForkProcess(double testTimeOut,
|
2009-08-19 16:58:36 +04:00
|
|
|
std::vector<std::string>* environment);
|
2009-08-31 17:50:35 +04:00
|
|
|
void WriteLogOutputTop(size_t completed, size_t total);
|
2009-08-28 23:08:03 +04:00
|
|
|
//Run post processing of the process output for MemCheck
|
|
|
|
void MemCheckPostProcess();
|
2009-08-27 18:37:30 +04:00
|
|
|
|
2009-08-19 16:58:36 +04:00
|
|
|
cmCTestTestHandler::cmCTestTestProperties * TestProperties;
|
|
|
|
//Pointer back to the "parent"; the handler that invoked this test run
|
|
|
|
cmCTestTestHandler * TestHandler;
|
|
|
|
cmCTest * CTest;
|
2009-08-26 20:09:06 +04:00
|
|
|
cmProcess * TestProcess;
|
2009-08-19 16:58:36 +04:00
|
|
|
//If the executable to run is ctest, don't create a new process;
|
|
|
|
//just instantiate a new cmTest. (Can be disabled for a single test
|
|
|
|
//if this option is set to false.)
|
2009-08-26 20:09:06 +04:00
|
|
|
//bool OptimizeForCTest;
|
|
|
|
|
2009-12-10 22:38:32 +03:00
|
|
|
bool UsePrefixCommand;
|
|
|
|
std::string PrefixCommand;
|
|
|
|
|
2009-08-19 16:58:36 +04:00
|
|
|
std::string ProcessOutput;
|
2009-12-17 19:14:49 +03:00
|
|
|
std::string CompressedOutput;
|
|
|
|
double CompressionRatio;
|
2009-08-19 16:58:36 +04:00
|
|
|
//The test results
|
|
|
|
cmCTestTestHandler::cmCTestTestResult TestResult;
|
2009-08-26 20:09:06 +04:00
|
|
|
int Index;
|
|
|
|
std::string StartTime;
|
|
|
|
std::string TestCommand;
|
|
|
|
std::string ActualCommand;
|
2009-08-28 19:08:39 +04:00
|
|
|
std::vector<std::string> Arguments;
|
2009-08-19 16:58:36 +04:00
|
|
|
};
|
|
|
|
|
2009-09-08 17:12:44 +04:00
|
|
|
inline int getNumWidth(size_t n)
|
2009-09-02 18:08:40 +04:00
|
|
|
{
|
|
|
|
int numWidth = 1;
|
|
|
|
if(n >= 10)
|
|
|
|
{
|
|
|
|
numWidth = 2;
|
|
|
|
}
|
|
|
|
if(n >= 100)
|
|
|
|
{
|
|
|
|
numWidth = 3;
|
|
|
|
}
|
|
|
|
return numWidth;
|
|
|
|
}
|
2009-12-10 22:38:32 +03:00
|
|
|
|
2009-08-19 16:58:36 +04:00
|
|
|
#endif
|
|
|
|
|