cmCTestTestHandler.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmCTestTestHandler_h
  14. #define cmCTestTestHandler_h
  15. #include "cmStandardIncludes.h"
  16. #include "cmListFileCache.h"
  17. class cmCTest;
  18. class cmMakefile;
  19. /** \class cmCTestTestHandler
  20. * \brief A class that handles ctest -S invocations
  21. *
  22. */
  23. class cmCTestTestHandler
  24. {
  25. public:
  26. /*
  27. * The main entry point for this class
  28. */
  29. int TestDirectory(cmCTest *, bool memcheck);
  30. /*
  31. * If verbose then more informaiton is printed out
  32. */
  33. void SetVerbose(bool val) { m_Verbose = val; }
  34. void PopulateCustomVectors(cmMakefile *mf);
  35. ///! Control the use of the regular expresisons, call these methods to turn
  36. ///them on
  37. void UseIncludeRegExp();
  38. void UseExcludeRegExp();
  39. void SetIncludeRegExp(const char *);
  40. void SetExcludeRegExp(const char *);
  41. cmCTestTestHandler();
  42. ///! pass the -I argument down
  43. void SetTestsToRunInformation(const char*);
  44. private:
  45. enum { // Memory checkers
  46. UNKNOWN = 0,
  47. VALGRIND,
  48. PURIFY,
  49. BOUNDS_CHECKER
  50. };
  51. enum { // Memory faults
  52. ABR = 0,
  53. ABW,
  54. ABWL,
  55. COR,
  56. EXU,
  57. FFM,
  58. FIM,
  59. FMM,
  60. FMR,
  61. FMW,
  62. FUM,
  63. IPR,
  64. IPW,
  65. MAF,
  66. MLK,
  67. MPK,
  68. NPR,
  69. ODS,
  70. PAR,
  71. PLK,
  72. UMC,
  73. UMR,
  74. NO_MEMORY_FAULT
  75. };
  76. enum { // Program statuses
  77. NOT_RUN = 0,
  78. TIMEOUT,
  79. SEGFAULT,
  80. ILLEGAL,
  81. INTERRUPT,
  82. NUMERICAL,
  83. OTHER_FAULT,
  84. FAILED,
  85. BAD_COMMAND,
  86. COMPLETED
  87. };
  88. bool m_Verbose;
  89. cmCTest *m_CTest;
  90. std::string m_MemoryTester;
  91. std::vector<cmStdString> m_MemoryTesterOptionsParsed;
  92. std::string m_MemoryTesterOptions;
  93. int m_MemoryTesterStyle;
  94. std::string m_MemoryTesterOutputFile;
  95. int m_MemoryTesterGlobalResults[NO_MEMORY_FAULT];
  96. struct cmCTestTestResult
  97. {
  98. std::string m_Name;
  99. std::string m_Path;
  100. std::string m_FullCommandLine;
  101. double m_ExecutionTime;
  102. int m_ReturnValue;
  103. int m_Status;
  104. std::string m_CompletionStatus;
  105. std::string m_Output;
  106. std::string m_RegressionImages;
  107. int m_TestCount;
  108. };
  109. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  110. tm_TestResultsVector m_TestResults;
  111. int ExecuteCommands(std::vector<cmStdString>& vec);
  112. ///! Initialize memory checking subsystem.
  113. bool InitializeMemoryChecking();
  114. /**
  115. * Generate the Dart compatible output
  116. */
  117. void GenerateDartTestOutput(std::ostream& os);
  118. void GenerateDartMemCheckOutput(std::ostream& os);
  119. /**
  120. * Run the test for a directory and any subdirectories
  121. */
  122. void ProcessDirectory(std::vector<cmStdString> &passed,
  123. std::vector<cmStdString> &failed,
  124. bool memcheck);
  125. typedef std::vector<cmListFileArgument> tm_VectorOfListFileArgs;
  126. struct cmCTestTestProperties
  127. {
  128. cmStdString m_Name;
  129. cmStdString m_Directory;
  130. tm_VectorOfListFileArgs m_Args;
  131. };
  132. typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
  133. /**
  134. * Get the list of tests in directory and subdirectories.
  135. */
  136. void GetListOfTests(tm_ListOfTests* testlist, bool memcheck);
  137. /**
  138. * Find the executable for a test
  139. */
  140. std::string FindTheExecutable(const char *exe);
  141. const char* GetTestStatus(int status);
  142. void ExpandTestsToRunInformation(int numPossibleTests);
  143. std::vector<cmStdString> m_CustomPreTest;
  144. std::vector<cmStdString> m_CustomPostTest;
  145. std::vector<cmStdString> m_CustomPreMemCheck;
  146. std::vector<cmStdString> m_CustomPostMemCheck;
  147. std::vector<cmStdString> m_CustomTestsIgnore;
  148. std::vector<cmStdString> m_CustomMemCheckIgnore;
  149. std::string m_StartTest;
  150. std::string m_EndTest;
  151. double m_ElapsedTestingTime;
  152. std::vector<int> m_TestsToRun;
  153. bool m_UseIncludeRegExp;
  154. bool m_UseExcludeRegExp;
  155. bool m_UseExcludeRegExpFirst;
  156. std::string m_IncludeRegExp;
  157. std::string m_ExcludeRegExp;
  158. std::string GenerateRegressionImages(const std::string& xml);
  159. //! Parse Valgrind/Purify/Bounds Checker result out of the output
  160. //string. After running, log holds the output and results hold the
  161. //different memmory errors.
  162. bool ProcessMemCheckOutput(const std::string& str,
  163. std::string& log, int* results);
  164. bool ProcessMemCheckValgrindOutput(const std::string& str,
  165. std::string& log, int* results);
  166. bool ProcessMemCheckPurifyOutput(const std::string& str,
  167. std::string& log, int* results);
  168. ///! Maximum size of testing string
  169. std::string::size_type m_MaximumPassedTestResultSize;
  170. std::string::size_type m_MaximumFailedTestResultSize;
  171. std::string TestsToRunString;
  172. };
  173. #endif