2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2004-09-09 16:41:05 +04:00
|
|
|
#ifndef cmCTestTestHandler_h
|
|
|
|
#define cmCTestTestHandler_h
|
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <cmConfigure.h>
|
|
|
|
|
2005-01-27 19:43:22 +03:00
|
|
|
#include "cmCTestGenericHandler.h"
|
2016-08-24 23:01:40 +03:00
|
|
|
#include "cmTypeMacro.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2005-06-07 17:06:38 +04:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
class cmCTest;
|
2004-09-09 16:41:05 +04:00
|
|
|
class cmMakefile;
|
2015-05-24 21:40:47 +03:00
|
|
|
class cmXMLWriter;
|
2004-09-09 16:41:05 +04:00
|
|
|
|
|
|
|
/** \class cmCTestTestHandler
|
|
|
|
* \brief A class that handles ctest -S invocations
|
|
|
|
*
|
|
|
|
*/
|
2005-01-27 19:43:22 +03:00
|
|
|
class cmCTestTestHandler : public cmCTestGenericHandler
|
2004-09-09 16:41:05 +04:00
|
|
|
{
|
2009-08-19 16:58:36 +04:00
|
|
|
friend class cmCTestRunTest;
|
2009-08-26 20:09:06 +04:00
|
|
|
friend class cmCTestMultiProcessHandler;
|
2009-09-10 19:16:08 +04:00
|
|
|
friend class cmCTestBatchTestHandler;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2004-09-09 16:41:05 +04:00
|
|
|
public:
|
2005-06-17 21:04:56 +04:00
|
|
|
cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler);
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
/**
|
2004-09-09 16:41:05 +04:00
|
|
|
* The main entry point for this class
|
|
|
|
*/
|
2016-06-27 22:25:27 +03:00
|
|
|
int ProcessHandler() CM_OVERRIDE;
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
/**
|
2004-11-13 17:55:31 +03:00
|
|
|
* When both -R and -I are used should te resulting test list be the
|
|
|
|
* intersection or the union of the lists. By default it is the
|
|
|
|
* intersection.
|
|
|
|
*/
|
2006-03-10 23:03:09 +03:00
|
|
|
void SetUseUnion(bool val) { this->UseUnion = val; }
|
2004-11-13 17:55:31 +03:00
|
|
|
|
2013-09-24 22:20:38 +04:00
|
|
|
/**
|
|
|
|
* Set whether or not CTest should only execute the tests that failed
|
|
|
|
* on the previous run. By default this is false.
|
|
|
|
*/
|
|
|
|
void SetRerunFailed(bool val) { this->RerunFailed = val; }
|
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
/**
|
|
|
|
* This method is called when reading CTest custom file
|
|
|
|
*/
|
2016-06-27 22:25:27 +03:00
|
|
|
void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-09 16:41:05 +04:00
|
|
|
///! Control the use of the regular expresisons, call these methods to turn
|
2016-05-16 17:34:04 +03:00
|
|
|
/// them on
|
2004-09-09 16:41:05 +04:00
|
|
|
void UseIncludeRegExp();
|
|
|
|
void UseExcludeRegExp();
|
2016-05-16 17:34:04 +03:00
|
|
|
void SetIncludeRegExp(const char*);
|
|
|
|
void SetExcludeRegExp(const char*);
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void SetMaxIndex(int n) { this->MaxIndex = n; }
|
|
|
|
int GetMaxIndex() { return this->MaxIndex; }
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2015-09-17 18:06:27 +03:00
|
|
|
void SetTestOutputSizePassed(int n)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
this->CustomMaximumPassedTestOutputSize = n;
|
|
|
|
}
|
2015-09-17 18:06:27 +03:00
|
|
|
void SetTestOutputSizeFailed(int n)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
this->CustomMaximumFailedTestOutputSize = n;
|
|
|
|
}
|
2015-09-17 18:06:27 +03:00
|
|
|
|
2004-09-09 16:41:05 +04:00
|
|
|
///! pass the -I argument down
|
|
|
|
void SetTestsToRunInformation(const char*);
|
|
|
|
|
2005-01-27 23:54:47 +03:00
|
|
|
cmCTestTestHandler();
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2005-06-07 17:06:38 +04:00
|
|
|
/*
|
|
|
|
* Add the test to the list of tests to be executed
|
|
|
|
*/
|
2009-12-10 23:37:04 +03:00
|
|
|
bool AddTest(const std::vector<std::string>& args);
|
2005-06-07 17:06:38 +04:00
|
|
|
|
2005-09-07 07:31:41 +04:00
|
|
|
/*
|
|
|
|
* Set tests properties
|
|
|
|
*/
|
|
|
|
bool SetTestsProperties(const std::vector<std::string>& args);
|
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
void Initialize() CM_OVERRIDE;
|
2005-06-17 21:04:56 +04:00
|
|
|
|
2008-12-19 05:59:25 +03:00
|
|
|
// NOTE: This struct is Saved/Restored
|
|
|
|
// in cmCTestTestHandler, if you add to this class
|
|
|
|
// then you must add the new members to that code or
|
|
|
|
// ctest -j N will break for that feature
|
2005-01-28 00:49:10 +03:00
|
|
|
struct cmCTestTestProperties
|
|
|
|
{
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string Name;
|
|
|
|
std::string Directory;
|
2006-03-10 23:03:09 +03:00
|
|
|
std::vector<std::string> Args;
|
2009-12-10 23:37:04 +03:00
|
|
|
std::vector<std::string> RequiredFiles;
|
2008-07-03 17:31:33 +04:00
|
|
|
std::vector<std::string> Depends;
|
2009-12-15 20:07:15 +03:00
|
|
|
std::vector<std::string> AttachedFiles;
|
2009-12-16 22:50:16 +03:00
|
|
|
std::vector<std::string> AttachOnFail;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::pair<cmsys::RegularExpression, std::string> >
|
|
|
|
ErrorRegularExpressions;
|
|
|
|
std::vector<std::pair<cmsys::RegularExpression, std::string> >
|
|
|
|
RequiredRegularExpressions;
|
|
|
|
std::vector<std::pair<cmsys::RegularExpression, std::string> >
|
|
|
|
TimeoutRegularExpressions;
|
2014-02-10 09:21:34 +04:00
|
|
|
std::map<std::string, std::string> Measurements;
|
2006-03-10 23:03:09 +03:00
|
|
|
bool IsInBasedOnREOptions;
|
|
|
|
bool WillFail;
|
2009-09-08 21:39:13 +04:00
|
|
|
float Cost;
|
2010-02-26 00:23:49 +03:00
|
|
|
int PreviousRuns;
|
2009-09-07 18:26:17 +04:00
|
|
|
bool RunSerial;
|
2007-01-25 19:16:16 +03:00
|
|
|
double Timeout;
|
2011-01-03 22:41:25 +03:00
|
|
|
bool ExplicitTimeout;
|
2016-02-18 21:59:18 +03:00
|
|
|
double AlternateTimeout;
|
2008-07-03 17:31:33 +04:00
|
|
|
int Index;
|
2016-05-16 17:34:04 +03:00
|
|
|
// Requested number of process slots
|
2009-09-03 18:47:14 +04:00
|
|
|
int Processors;
|
2012-09-21 19:37:08 +04:00
|
|
|
// return code of test which will mark test as "not run"
|
|
|
|
int SkipReturnCode;
|
2008-11-26 22:38:43 +03:00
|
|
|
std::vector<std::string> Environment;
|
2009-01-07 18:41:37 +03:00
|
|
|
std::vector<std::string> Labels;
|
2010-03-02 23:34:37 +03:00
|
|
|
std::set<std::string> LockedResources;
|
2016-09-07 07:04:07 +03:00
|
|
|
std::set<std::string> FixturesSetup;
|
|
|
|
std::set<std::string> FixturesCleanup;
|
|
|
|
std::set<std::string> FixturesRequired;
|
|
|
|
std::set<std::string> RequireSuccessDepends;
|
2005-01-28 00:49:10 +03:00
|
|
|
};
|
|
|
|
|
2006-10-13 17:30:33 +04:00
|
|
|
struct cmCTestTestResult
|
|
|
|
{
|
|
|
|
std::string Name;
|
|
|
|
std::string Path;
|
2009-02-25 01:23:51 +03:00
|
|
|
std::string Reason;
|
2006-10-13 17:30:33 +04:00
|
|
|
std::string FullCommandLine;
|
2016-05-16 17:34:04 +03:00
|
|
|
double ExecutionTime;
|
|
|
|
int ReturnValue;
|
|
|
|
int Status;
|
|
|
|
bool CompressOutput;
|
2006-10-13 17:30:33 +04:00
|
|
|
std::string CompletionStatus;
|
|
|
|
std::string Output;
|
2015-05-24 02:00:12 +03:00
|
|
|
std::string DartString;
|
2016-05-16 17:34:04 +03:00
|
|
|
int TestCount;
|
2006-10-13 17:30:33 +04:00
|
|
|
cmCTestTestProperties* Properties;
|
|
|
|
};
|
|
|
|
|
2011-08-03 18:24:59 +04:00
|
|
|
struct cmCTestTestResultLess
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
bool operator()(const cmCTestTestResult& lhs,
|
|
|
|
const cmCTestTestResult& rhs) const
|
2011-08-03 18:24:59 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return lhs.TestCount < rhs.TestCount;
|
2011-08-03 18:24:59 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// add configurations to a search path for an executable
|
2016-05-16 17:34:04 +03:00
|
|
|
static void AddConfigurations(cmCTest* ctest,
|
|
|
|
std::vector<std::string>& attempted,
|
|
|
|
std::vector<std::string>& attemptedConfigs,
|
|
|
|
std::string filepath, std::string& filename);
|
2007-03-19 20:04:10 +03:00
|
|
|
|
|
|
|
// full signature static method to find an executable
|
2016-05-16 17:34:04 +03:00
|
|
|
static std::string FindExecutable(cmCTest* ctest, const char* testCommand,
|
|
|
|
std::string& resultingConfig,
|
|
|
|
std::vector<std::string>& extraPaths,
|
|
|
|
std::vector<std::string>& failed);
|
2007-03-19 20:04:10 +03:00
|
|
|
|
2009-08-26 20:09:06 +04:00
|
|
|
typedef std::vector<cmCTestTestProperties> ListOfTests;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2006-10-13 22:44:35 +04:00
|
|
|
protected:
|
2011-08-03 18:24:59 +04:00
|
|
|
// compute a final test list
|
2005-01-27 23:54:47 +03:00
|
|
|
virtual int PreProcessHandler();
|
|
|
|
virtual int PostProcessHandler();
|
2013-08-08 00:25:48 +04:00
|
|
|
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
|
2014-02-10 09:21:34 +04:00
|
|
|
int ExecuteCommands(std::vector<std::string>& vec);
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2015-05-24 21:40:47 +03:00
|
|
|
void WriteTestResultHeader(cmXMLWriter& xml, cmCTestTestResult* result);
|
|
|
|
void WriteTestResultFooter(cmXMLWriter& xml, cmCTestTestResult* result);
|
2009-12-15 20:07:15 +03:00
|
|
|
// Write attached test files into the xml
|
2015-05-24 21:40:47 +03:00
|
|
|
void AttachFiles(cmXMLWriter& xml, cmCTestTestResult* result);
|
2009-02-02 21:24:26 +03:00
|
|
|
|
2006-03-16 19:34:58 +03:00
|
|
|
//! Clean test output to specified length
|
|
|
|
bool CleanTestOutput(std::string& output, size_t length);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
double ElapsedTestingTime;
|
2005-01-27 23:54:47 +03:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
typedef std::vector<cmCTestTestResult> TestResultsVector;
|
2016-05-16 17:34:04 +03:00
|
|
|
TestResultsVector TestResults;
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> CustomTestsIgnore;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string StartTest;
|
|
|
|
std::string EndTest;
|
|
|
|
unsigned int StartTestTime;
|
|
|
|
unsigned int EndTestTime;
|
2006-03-10 23:03:09 +03:00
|
|
|
bool MemCheck;
|
2006-03-16 19:34:58 +03:00
|
|
|
int CustomMaximumPassedTestOutputSize;
|
|
|
|
int CustomMaximumFailedTestOutputSize;
|
2009-09-02 18:08:40 +04:00
|
|
|
int MaxIndex;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2008-07-03 17:31:33 +04:00
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
enum
|
|
|
|
{ // Program statuses
|
2005-01-27 23:54:47 +03:00
|
|
|
NOT_RUN = 0,
|
|
|
|
TIMEOUT,
|
|
|
|
SEGFAULT,
|
|
|
|
ILLEGAL,
|
|
|
|
INTERRUPT,
|
|
|
|
NUMERICAL,
|
|
|
|
OTHER_FAULT,
|
|
|
|
FAILED,
|
|
|
|
BAD_COMMAND,
|
|
|
|
COMPLETED
|
|
|
|
};
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2008-07-03 17:31:33 +04:00
|
|
|
private:
|
2004-09-09 16:41:05 +04:00
|
|
|
/**
|
|
|
|
* Generate the Dart compatible output
|
|
|
|
*/
|
2015-05-24 21:40:47 +03:00
|
|
|
virtual void GenerateDartOutput(cmXMLWriter& xml);
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2009-08-19 17:24:55 +04:00
|
|
|
void PrintLabelSummary();
|
2004-09-09 16:41:05 +04:00
|
|
|
/**
|
2007-01-25 19:16:16 +03:00
|
|
|
* Run the tests for a directory and any subdirectories
|
2004-09-09 16:41:05 +04:00
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
void ProcessDirectory(std::vector<std::string>& passed,
|
|
|
|
std::vector<std::string>& failed);
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-09 16:41:05 +04:00
|
|
|
/**
|
|
|
|
* Get the list of tests in directory and subdirectories.
|
|
|
|
*/
|
2005-06-07 17:06:38 +04:00
|
|
|
void GetListOfTests();
|
2008-07-03 17:31:33 +04:00
|
|
|
// compute the lists of tests that will actually run
|
|
|
|
// based on union regex and -I stuff
|
|
|
|
void ComputeTestList();
|
2011-03-11 16:04:58 +03:00
|
|
|
|
2013-09-24 22:20:38 +04:00
|
|
|
// compute the lists of tests that will actually run
|
|
|
|
// based on LastTestFailed.log
|
|
|
|
void ComputeTestListForRerunFailed();
|
|
|
|
|
2016-09-07 07:04:07 +03:00
|
|
|
// add required setup/cleanup tests not already in the
|
|
|
|
// list of tests to be run and update dependencies between
|
|
|
|
// tests to account for fixture setup/cleanup
|
|
|
|
void UpdateForFixtures(ListOfTests& tests) const;
|
|
|
|
|
2013-09-24 22:20:38 +04:00
|
|
|
void UpdateMaxTestNameWidth();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool GetValue(const char* tag, std::string& value, std::istream& fin);
|
|
|
|
bool GetValue(const char* tag, int& value, std::istream& fin);
|
|
|
|
bool GetValue(const char* tag, size_t& value, std::istream& fin);
|
|
|
|
bool GetValue(const char* tag, bool& value, std::istream& fin);
|
|
|
|
bool GetValue(const char* tag, double& value, std::istream& fin);
|
2004-09-09 16:41:05 +04:00
|
|
|
/**
|
|
|
|
* Find the executable for a test
|
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string FindTheExecutable(const char* exe);
|
2004-09-09 16:41:05 +04:00
|
|
|
|
|
|
|
const char* GetTestStatus(int status);
|
2008-07-07 03:58:38 +04:00
|
|
|
void ExpandTestsToRunInformation(size_t numPossibleTests);
|
2013-09-24 22:20:38 +04:00
|
|
|
void ExpandTestsToRunInformationForRerunFailed();
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> CustomPreTest;
|
|
|
|
std::vector<std::string> CustomPostTest;
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<int> TestsToRun;
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2009-02-10 22:24:24 +03:00
|
|
|
bool UseIncludeLabelRegExpFlag;
|
|
|
|
bool UseExcludeLabelRegExpFlag;
|
2006-03-10 23:03:09 +03:00
|
|
|
bool UseIncludeRegExpFlag;
|
|
|
|
bool UseExcludeRegExpFlag;
|
|
|
|
bool UseExcludeRegExpFirst;
|
2009-02-10 22:24:24 +03:00
|
|
|
std::string IncludeLabelRegExp;
|
|
|
|
std::string ExcludeLabelRegExp;
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string IncludeRegExp;
|
|
|
|
std::string ExcludeRegExp;
|
2009-02-10 22:24:24 +03:00
|
|
|
cmsys::RegularExpression IncludeLabelRegularExpression;
|
|
|
|
cmsys::RegularExpression ExcludeLabelRegularExpression;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmsys::RegularExpression IncludeTestsRegularExpression;
|
|
|
|
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
2004-09-09 16:41:05 +04:00
|
|
|
|
2015-05-24 21:40:47 +03:00
|
|
|
void GenerateRegressionImages(cmXMLWriter& xml, const std::string& dart);
|
2009-01-15 18:32:56 +03:00
|
|
|
cmsys::RegularExpression DartStuff1;
|
2009-02-10 22:24:24 +03:00
|
|
|
void CheckLabelFilter(cmCTestTestProperties& it);
|
|
|
|
void CheckLabelFilterExclude(cmCTestTestProperties& it);
|
|
|
|
void CheckLabelFilterInclude(cmCTestTestProperties& it);
|
2004-09-09 16:41:05 +04:00
|
|
|
|
|
|
|
std::string TestsToRunString;
|
2006-03-10 23:03:09 +03:00
|
|
|
bool UseUnion;
|
|
|
|
ListOfTests TestList;
|
2008-07-03 17:31:33 +04:00
|
|
|
size_t TotalNumberOfTests;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmsys::RegularExpression DartStuff;
|
2005-08-18 21:50:16 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
std::ostream* LogFile;
|
2013-09-24 22:20:38 +04:00
|
|
|
|
|
|
|
bool RerunFailed;
|
2004-09-09 16:41:05 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|