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
|
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <cmConfigure.h> // IWYU pragma: keep
|
|
|
|
|
2009-08-19 16:58:36 +04:00
|
|
|
#include <cmCTestTestHandler.h>
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
class cmCTest;
|
|
|
|
class cmProcess;
|
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();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void SetNumberOfRuns(int n) { this->NumberOfRunsLeft = n; }
|
|
|
|
void SetRunUntilFailOn() { this->RunUntilFail = true; }
|
|
|
|
void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties* prop)
|
|
|
|
{
|
|
|
|
this->TestProperties = prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCTestTestHandler::cmCTestTestProperties* GetTestProperties()
|
|
|
|
{
|
|
|
|
return this->TestProperties;
|
|
|
|
}
|
2009-08-19 16:58:36 +04:00
|
|
|
|
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
|
|
|
|
2016-09-07 07:04:07 +03:00
|
|
|
void AddFailedDependency(const std::string& failedTest)
|
|
|
|
{
|
|
|
|
this->FailedDependencies.insert(failedTest);
|
|
|
|
}
|
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
std::string GetProcessOutput() { return this->ProcessOutput; }
|
2009-08-19 16:58:36 +04:00
|
|
|
|
2010-06-15 18:29:35 +04:00
|
|
|
bool IsStopTimePassed() { return this->StopTimePassed; }
|
|
|
|
|
2009-08-19 16:58:36 +04:00
|
|
|
cmCTestTestHandler::cmCTestTestResult GetTestResults()
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
return this->TestResult;
|
|
|
|
}
|
2009-08-19 16:58:36 +04:00
|
|
|
|
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();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// launch the test process, return whether it started correctly
|
2009-10-05 18:20:52 +04:00
|
|
|
bool StartTest(size_t total);
|
2016-05-16 17:34:04 +03: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);
|
2016-05-16 17:34:04 +03:00
|
|
|
// Called by ctest -N to log the command string
|
2009-08-28 19:08:39 +04:00
|
|
|
void ComputeArguments();
|
2010-02-26 00:23:49 +03:00
|
|
|
|
|
|
|
void ComputeWeightedCost();
|
2015-03-06 00:51:10 +03:00
|
|
|
|
|
|
|
bool StartAgain();
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2009-08-28 19:08:39 +04:00
|
|
|
private:
|
2015-03-06 00:51:10 +03:00
|
|
|
bool NeedsToRerun();
|
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();
|
2011-01-03 22:41:25 +03:00
|
|
|
bool ForkProcess(double testTimeOut, bool explicitTimeout,
|
|
|
|
std::vector<std::string>* environment);
|
2009-08-31 17:50:35 +04:00
|
|
|
void WriteLogOutputTop(size_t completed, size_t total);
|
2016-05-16 17:34:04 +03:00
|
|
|
// Run post processing of the process output for MemCheck
|
2009-08-28 23:08:03 +04:00
|
|
|
void MemCheckPostProcess();
|
2009-08-27 18:37:30 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestTestHandler::cmCTestTestProperties* TestProperties;
|
|
|
|
// Pointer back to the "parent"; the handler that invoked this test run
|
|
|
|
cmCTestTestHandler* TestHandler;
|
|
|
|
cmCTest* CTest;
|
|
|
|
cmProcess* TestProcess;
|
|
|
|
// 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.)
|
|
|
|
// bool OptimizeForCTest;
|
2009-08-26 20:09:06 +04:00
|
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
// The test results
|
2009-08-19 16:58:36 +04:00
|
|
|
cmCTestTestHandler::cmCTestTestResult TestResult;
|
2009-08-26 20:09:06 +04:00
|
|
|
int Index;
|
2016-09-07 07:04:07 +03:00
|
|
|
std::set<std::string> FailedDependencies;
|
2009-08-26 20:09:06 +04:00
|
|
|
std::string StartTime;
|
|
|
|
std::string ActualCommand;
|
2009-08-28 19:08:39 +04:00
|
|
|
std::vector<std::string> Arguments;
|
2010-06-15 18:29:35 +04:00
|
|
|
bool StopTimePassed;
|
2015-03-06 00:51:10 +03:00
|
|
|
bool RunUntilFail;
|
|
|
|
int NumberOfRunsLeft;
|
|
|
|
bool RunAgain;
|
|
|
|
size_t TotalNumberOfTests;
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (n >= 10) {
|
2009-09-02 18:08:40 +04:00
|
|
|
numWidth = 2;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (n >= 100) {
|
2009-09-02 18:08:40 +04:00
|
|
|
numWidth = 3;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-02 18:08:40 +04:00
|
|
|
return numWidth;
|
|
|
|
}
|
2009-12-10 22:38:32 +03:00
|
|
|
|
2009-08-19 16:58:36 +04:00
|
|
|
#endif
|