2004-09-09 12:41:05 +00:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
2006-03-09 16:17:10 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
2004-09-09 12:41:05 +00:00
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
|
|
|
|
#ifndef cmCTestTestHandler_h
|
|
|
|
#define cmCTestTestHandler_h
|
|
|
|
|
|
|
|
|
2005-01-27 16:43:22 +00:00
|
|
|
#include "cmCTestGenericHandler.h"
|
2005-06-07 13:06:38 +00:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2004-09-09 12:41:05 +00:00
|
|
|
|
|
|
|
class cmMakefile;
|
|
|
|
|
|
|
|
/** \class cmCTestTestHandler
|
|
|
|
* \brief A class that handles ctest -S invocations
|
|
|
|
*
|
|
|
|
*/
|
2005-01-27 16:43:22 +00:00
|
|
|
class cmCTestTestHandler : public cmCTestGenericHandler
|
2004-09-09 12:41:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-06-17 17:04:56 +00:00
|
|
|
cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler);
|
2004-09-09 12:41:05 +00:00
|
|
|
|
2005-01-27 20:54:47 +00:00
|
|
|
/**
|
2004-09-09 12:41:05 +00:00
|
|
|
* The main entry point for this class
|
|
|
|
*/
|
2005-01-27 20:54:47 +00:00
|
|
|
int ProcessHandler();
|
2006-03-09 16:17:10 +00:00
|
|
|
|
2005-01-27 20:54:47 +00:00
|
|
|
/**
|
2004-11-13 14:55:31 +00: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 20:03:09 +00:00
|
|
|
void SetUseUnion(bool val) { this->UseUnion = val; }
|
2004-11-13 14:55:31 +00:00
|
|
|
|
2005-01-27 20:54:47 +00:00
|
|
|
/**
|
|
|
|
* This method is called when reading CTest custom file
|
|
|
|
*/
|
2004-11-13 14:55:31 +00:00
|
|
|
void PopulateCustomVectors(cmMakefile *mf);
|
2006-03-09 16:17:10 +00:00
|
|
|
|
2004-09-09 12:41:05 +00:00
|
|
|
///! Control the use of the regular expresisons, call these methods to turn
|
|
|
|
///them on
|
|
|
|
void UseIncludeRegExp();
|
|
|
|
void UseExcludeRegExp();
|
|
|
|
void SetIncludeRegExp(const char *);
|
|
|
|
void SetExcludeRegExp(const char *);
|
2006-03-09 16:17:10 +00:00
|
|
|
|
2004-09-09 12:41:05 +00:00
|
|
|
|
|
|
|
///! pass the -I argument down
|
|
|
|
void SetTestsToRunInformation(const char*);
|
|
|
|
|
2005-01-27 20:54:47 +00:00
|
|
|
cmCTestTestHandler();
|
2004-09-09 12:41:05 +00:00
|
|
|
|
2005-06-07 13:06:38 +00:00
|
|
|
/*
|
|
|
|
* Add the test to the list of tests to be executed
|
|
|
|
*/
|
|
|
|
bool AddTest(const std::vector<std::string>& args);
|
|
|
|
|
2005-09-07 03:31:41 +00:00
|
|
|
/*
|
|
|
|
* Set tests properties
|
|
|
|
*/
|
|
|
|
bool SetTestsProperties(const std::vector<std::string>& args);
|
|
|
|
|
2005-06-17 17:04:56 +00:00
|
|
|
void Initialize();
|
|
|
|
|
2005-01-27 21:49:10 +00:00
|
|
|
struct cmCTestTestProperties
|
|
|
|
{
|
2006-03-10 20:03:09 +00:00
|
|
|
cmStdString Name;
|
|
|
|
cmStdString Directory;
|
|
|
|
std::vector<std::string> Args;
|
2008-07-03 13:31:33 +00:00
|
|
|
std::vector<std::string> Depends;
|
2007-09-24 15:10:55 +00:00
|
|
|
std::vector<std::pair<cmsys::RegularExpression,
|
|
|
|
std::string> > ErrorRegularExpressions;
|
|
|
|
std::vector<std::pair<cmsys::RegularExpression,
|
|
|
|
std::string> > RequiredRegularExpressions;
|
2006-10-13 13:30:33 +00:00
|
|
|
std::map<cmStdString, cmStdString> Measurements;
|
2006-03-10 20:03:09 +00:00
|
|
|
bool IsInBasedOnREOptions;
|
|
|
|
bool WillFail;
|
2007-01-25 16:16:16 +00:00
|
|
|
double Timeout;
|
2008-07-03 13:31:33 +00:00
|
|
|
int Index;
|
2008-11-26 19:38:43 +00:00
|
|
|
std::vector<std::string> Environment;
|
2005-01-27 21:49:10 +00:00
|
|
|
};
|
|
|
|
|
2006-10-13 13:30:33 +00:00
|
|
|
struct cmCTestTestResult
|
|
|
|
{
|
|
|
|
std::string Name;
|
|
|
|
std::string Path;
|
|
|
|
std::string FullCommandLine;
|
|
|
|
double ExecutionTime;
|
|
|
|
int ReturnValue;
|
|
|
|
int Status;
|
|
|
|
std::string CompletionStatus;
|
|
|
|
std::string Output;
|
|
|
|
std::string RegressionImages;
|
|
|
|
int TestCount;
|
|
|
|
cmCTestTestProperties* Properties;
|
|
|
|
};
|
|
|
|
|
2007-03-19 17:04:10 +00:00
|
|
|
// add configuraitons to a search path for an executable
|
|
|
|
static void AddConfigurations(cmCTest *ctest,
|
|
|
|
std::vector<std::string> &attempted,
|
|
|
|
std::vector<std::string> &attemptedConfigs,
|
|
|
|
std::string filepath,
|
|
|
|
std::string &filename);
|
|
|
|
|
|
|
|
// full signature static method to find an executable
|
|
|
|
static std::string FindExecutable(cmCTest *ctest,
|
|
|
|
const char *testCommand,
|
|
|
|
std::string &resultingConfig,
|
|
|
|
std::vector<std::string> &extraPaths,
|
|
|
|
std::vector<std::string> &failed);
|
|
|
|
|
2006-10-13 18:44:35 +00:00
|
|
|
protected:
|
2008-07-03 13:31:33 +00:00
|
|
|
// comput a final test list
|
2005-01-27 20:54:47 +00:00
|
|
|
virtual int PreProcessHandler();
|
|
|
|
virtual int PostProcessHandler();
|
|
|
|
virtual void GenerateTestCommand(std::vector<const char*>& args);
|
|
|
|
int ExecuteCommands(std::vector<cmStdString>& vec);
|
|
|
|
|
2006-03-16 16:34:58 +00:00
|
|
|
//! Clean test output to specified length
|
|
|
|
bool CleanTestOutput(std::string& output, size_t length);
|
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
double ElapsedTestingTime;
|
2005-01-27 20:54:47 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
typedef std::vector<cmCTestTestResult> TestResultsVector;
|
|
|
|
TestResultsVector TestResults;
|
2004-09-09 12:41:05 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
std::vector<cmStdString> CustomTestsIgnore;
|
|
|
|
std::string StartTest;
|
|
|
|
std::string EndTest;
|
2008-01-30 16:17:36 +00:00
|
|
|
unsigned int StartTestTime;
|
|
|
|
unsigned int EndTestTime;
|
2006-03-10 20:03:09 +00:00
|
|
|
bool MemCheck;
|
2006-03-16 16:34:58 +00:00
|
|
|
int CustomMaximumPassedTestOutputSize;
|
|
|
|
int CustomMaximumFailedTestOutputSize;
|
2007-07-24 18:43:31 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Run one test
|
|
|
|
*/
|
|
|
|
virtual void ProcessOneTest(cmCTestTestProperties *props,
|
|
|
|
std::vector<cmStdString> &passed,
|
|
|
|
std::vector<cmStdString> &failed,
|
|
|
|
int count, int tmsize);
|
|
|
|
|
2006-03-16 16:34:58 +00:00
|
|
|
|
2005-01-27 20:54:47 +00:00
|
|
|
|
2008-07-03 13:31:33 +00:00
|
|
|
public:
|
2005-01-27 20:54:47 +00:00
|
|
|
enum { // Program statuses
|
|
|
|
NOT_RUN = 0,
|
|
|
|
TIMEOUT,
|
|
|
|
SEGFAULT,
|
|
|
|
ILLEGAL,
|
|
|
|
INTERRUPT,
|
|
|
|
NUMERICAL,
|
|
|
|
OTHER_FAULT,
|
|
|
|
FAILED,
|
|
|
|
BAD_COMMAND,
|
|
|
|
COMPLETED
|
|
|
|
};
|
2004-09-09 12:41:05 +00:00
|
|
|
|
2008-07-03 13:31:33 +00:00
|
|
|
private:
|
2004-09-09 12:41:05 +00:00
|
|
|
/**
|
|
|
|
* Generate the Dart compatible output
|
|
|
|
*/
|
2005-01-27 20:54:47 +00:00
|
|
|
virtual void GenerateDartOutput(std::ostream& os);
|
2004-09-09 12:41:05 +00:00
|
|
|
|
|
|
|
/**
|
2007-01-25 16:16:16 +00:00
|
|
|
* Run the tests for a directory and any subdirectories
|
2004-09-09 12:41:05 +00:00
|
|
|
*/
|
2006-03-09 16:17:10 +00:00
|
|
|
void ProcessDirectory(std::vector<cmStdString> &passed,
|
2005-01-27 20:54:47 +00:00
|
|
|
std::vector<cmStdString> &failed);
|
2006-03-09 16:17:10 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
typedef std::vector<cmCTestTestProperties> ListOfTests;
|
2004-09-09 12:41:05 +00:00
|
|
|
/**
|
|
|
|
* Get the list of tests in directory and subdirectories.
|
|
|
|
*/
|
2005-06-07 13:06:38 +00:00
|
|
|
void GetListOfTests();
|
2008-07-03 13:31:33 +00:00
|
|
|
// compute the lists of tests that will actually run
|
|
|
|
// based on union regex and -I stuff
|
|
|
|
void ComputeTestList();
|
|
|
|
|
|
|
|
// Save the state of the test list and return the file
|
|
|
|
// name it was saved to
|
|
|
|
std::string SaveTestList();
|
|
|
|
void LoadTestList();
|
|
|
|
bool GetValue(const char* tag,
|
|
|
|
std::string& value,
|
|
|
|
std::ifstream& fin);
|
|
|
|
bool GetValue(const char* tag,
|
|
|
|
int& value,
|
|
|
|
std::ifstream& fin);
|
|
|
|
bool GetValue(const char* tag,
|
|
|
|
size_t& value,
|
|
|
|
std::ifstream& fin);
|
|
|
|
bool GetValue(const char* tag,
|
|
|
|
bool& value,
|
|
|
|
std::ifstream& fin);
|
|
|
|
bool GetValue(const char* tag,
|
|
|
|
double& value,
|
|
|
|
std::ifstream& fin);
|
|
|
|
// run in -j N mode
|
|
|
|
void ProcessParallel(std::vector<cmStdString> &passed,
|
|
|
|
std::vector<cmStdString> &failed);
|
2004-09-09 12:41:05 +00:00
|
|
|
/**
|
|
|
|
* Find the executable for a test
|
|
|
|
*/
|
|
|
|
std::string FindTheExecutable(const char *exe);
|
|
|
|
|
|
|
|
const char* GetTestStatus(int status);
|
2008-07-06 23:58:38 +00:00
|
|
|
void ExpandTestsToRunInformation(size_t numPossibleTests);
|
2004-09-09 12:41:05 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
std::vector<cmStdString> CustomPreTest;
|
|
|
|
std::vector<cmStdString> CustomPostTest;
|
2004-09-09 12:41:05 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
std::vector<int> TestsToRun;
|
2004-09-09 12:41:05 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
bool UseIncludeRegExpFlag;
|
|
|
|
bool UseExcludeRegExpFlag;
|
|
|
|
bool UseExcludeRegExpFirst;
|
|
|
|
std::string IncludeRegExp;
|
|
|
|
std::string ExcludeRegExp;
|
|
|
|
cmsys::RegularExpression IncludeTestsRegularExpression;
|
|
|
|
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
2004-09-09 12:41:05 +00:00
|
|
|
|
|
|
|
std::string GenerateRegressionImages(const std::string& xml);
|
|
|
|
|
|
|
|
std::string TestsToRunString;
|
2006-03-10 20:03:09 +00:00
|
|
|
bool UseUnion;
|
|
|
|
ListOfTests TestList;
|
2008-07-03 13:31:33 +00:00
|
|
|
size_t TotalNumberOfTests;
|
2006-03-10 20:03:09 +00:00
|
|
|
cmsys::RegularExpression DartStuff;
|
2005-08-18 17:50:16 +00:00
|
|
|
|
2006-03-10 20:03:09 +00:00
|
|
|
std::ostream* LogFile;
|
2004-09-09 12:41:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|