cmCTestTestHandler.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. /*
  35. * When both -R and -I are used should te resulting test list be the
  36. * intersection or the union of the lists. By default it is the
  37. * intersection.
  38. */
  39. void SetUseUnion(bool val) { m_UseUnion = val; }
  40. void PopulateCustomVectors(cmMakefile *mf);
  41. ///! Control the use of the regular expresisons, call these methods to turn
  42. ///them on
  43. void UseIncludeRegExp();
  44. void UseExcludeRegExp();
  45. void SetIncludeRegExp(const char *);
  46. void SetExcludeRegExp(const char *);
  47. cmCTestTestHandler();
  48. ///! pass the -I argument down
  49. void SetTestsToRunInformation(const char*);
  50. typedef std::vector<cmListFileArgument> tm_VectorOfListFileArgs;
  51. private:
  52. enum { // Memory checkers
  53. UNKNOWN = 0,
  54. VALGRIND,
  55. PURIFY,
  56. BOUNDS_CHECKER
  57. };
  58. enum { // Memory faults
  59. ABR = 0,
  60. ABW,
  61. ABWL,
  62. COR,
  63. EXU,
  64. FFM,
  65. FIM,
  66. FMM,
  67. FMR,
  68. FMW,
  69. FUM,
  70. IPR,
  71. IPW,
  72. MAF,
  73. MLK,
  74. MPK,
  75. NPR,
  76. ODS,
  77. PAR,
  78. PLK,
  79. UMC,
  80. UMR,
  81. NO_MEMORY_FAULT
  82. };
  83. enum { // Program statuses
  84. NOT_RUN = 0,
  85. TIMEOUT,
  86. SEGFAULT,
  87. ILLEGAL,
  88. INTERRUPT,
  89. NUMERICAL,
  90. OTHER_FAULT,
  91. FAILED,
  92. BAD_COMMAND,
  93. COMPLETED
  94. };
  95. bool m_Verbose;
  96. cmCTest *m_CTest;
  97. std::string m_MemoryTester;
  98. std::vector<cmStdString> m_MemoryTesterOptionsParsed;
  99. std::string m_MemoryTesterOptions;
  100. int m_MemoryTesterStyle;
  101. std::string m_MemoryTesterOutputFile;
  102. int m_MemoryTesterGlobalResults[NO_MEMORY_FAULT];
  103. struct cmCTestTestResult
  104. {
  105. std::string m_Name;
  106. std::string m_Path;
  107. std::string m_FullCommandLine;
  108. double m_ExecutionTime;
  109. int m_ReturnValue;
  110. int m_Status;
  111. std::string m_CompletionStatus;
  112. std::string m_Output;
  113. std::string m_RegressionImages;
  114. int m_TestCount;
  115. };
  116. typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
  117. tm_TestResultsVector m_TestResults;
  118. int ExecuteCommands(std::vector<cmStdString>& vec);
  119. ///! Initialize memory checking subsystem.
  120. bool InitializeMemoryChecking();
  121. /**
  122. * Generate the Dart compatible output
  123. */
  124. void GenerateDartTestOutput(std::ostream& os);
  125. void GenerateDartMemCheckOutput(std::ostream& os);
  126. /**
  127. * Run the test for a directory and any subdirectories
  128. */
  129. void ProcessDirectory(std::vector<cmStdString> &passed,
  130. std::vector<cmStdString> &failed,
  131. bool memcheck);
  132. struct cmCTestTestProperties
  133. {
  134. cmStdString m_Name;
  135. cmStdString m_Directory;
  136. tm_VectorOfListFileArgs m_Args;
  137. bool m_IsInBasedOnREOptions;
  138. };
  139. typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
  140. /**
  141. * Get the list of tests in directory and subdirectories.
  142. */
  143. void GetListOfTests(tm_ListOfTests* testlist, bool memcheck);
  144. /**
  145. * Find the executable for a test
  146. */
  147. std::string FindTheExecutable(const char *exe);
  148. const char* GetTestStatus(int status);
  149. void ExpandTestsToRunInformation(int numPossibleTests);
  150. std::vector<cmStdString> m_CustomPreTest;
  151. std::vector<cmStdString> m_CustomPostTest;
  152. std::vector<cmStdString> m_CustomPreMemCheck;
  153. std::vector<cmStdString> m_CustomPostMemCheck;
  154. std::vector<cmStdString> m_CustomTestsIgnore;
  155. std::vector<cmStdString> m_CustomMemCheckIgnore;
  156. std::string m_StartTest;
  157. std::string m_EndTest;
  158. double m_ElapsedTestingTime;
  159. std::vector<int> m_TestsToRun;
  160. bool m_UseIncludeRegExp;
  161. bool m_UseExcludeRegExp;
  162. bool m_UseExcludeRegExpFirst;
  163. std::string m_IncludeRegExp;
  164. std::string m_ExcludeRegExp;
  165. std::string GenerateRegressionImages(const std::string& xml);
  166. //! Parse Valgrind/Purify/Bounds Checker result out of the output
  167. //string. After running, log holds the output and results hold the
  168. //different memmory errors.
  169. bool ProcessMemCheckOutput(const std::string& str,
  170. std::string& log, int* results);
  171. bool ProcessMemCheckValgrindOutput(const std::string& str,
  172. std::string& log, int* results);
  173. bool ProcessMemCheckPurifyOutput(const std::string& str,
  174. std::string& log, int* results);
  175. std::string TestsToRunString;
  176. bool m_UseUnion;
  177. };
  178. #endif