cmCTestMemCheckHandler.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCTestMemCheckHandler_h
  11. #define cmCTestMemCheckHandler_h
  12. #include "cmCTestTestHandler.h"
  13. #include "cmListFileCache.h"
  14. class cmMakefile;
  15. /** \class cmCTestMemCheckHandler
  16. * \brief A class that handles ctest -S invocations
  17. *
  18. */
  19. class cmCTestMemCheckHandler : public cmCTestTestHandler
  20. {
  21. friend class cmCTestRunTest;
  22. public:
  23. cmTypeMacro(cmCTestMemCheckHandler, cmCTestTestHandler);
  24. void PopulateCustomVectors(cmMakefile *mf);
  25. cmCTestMemCheckHandler();
  26. void Initialize();
  27. protected:
  28. virtual int PreProcessHandler();
  29. virtual int PostProcessHandler();
  30. virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
  31. private:
  32. enum { // Memory checkers
  33. UNKNOWN = 0,
  34. VALGRIND,
  35. PURIFY,
  36. BOUNDS_CHECKER
  37. };
  38. public:
  39. enum { // Memory faults
  40. ABR = 0,
  41. ABW,
  42. ABWL,
  43. COR,
  44. EXU,
  45. FFM,
  46. FIM,
  47. FMM,
  48. FMR,
  49. FMW,
  50. FUM,
  51. IPR,
  52. IPW,
  53. MAF,
  54. MLK,
  55. MPK,
  56. NPR,
  57. ODS,
  58. PAR,
  59. PLK,
  60. UMC,
  61. UMR,
  62. NO_MEMORY_FAULT
  63. };
  64. private:
  65. enum { // Program statuses
  66. NOT_RUN = 0,
  67. TIMEOUT,
  68. SEGFAULT,
  69. ILLEGAL,
  70. INTERRUPT,
  71. NUMERICAL,
  72. OTHER_FAULT,
  73. FAILED,
  74. BAD_COMMAND,
  75. COMPLETED
  76. };
  77. std::string BoundsCheckerDPBDFile;
  78. std::string BoundsCheckerXMLFile;
  79. std::string MemoryTester;
  80. std::vector<std::string> MemoryTesterDynamicOptions;
  81. std::vector<std::string> MemoryTesterOptions;
  82. int MemoryTesterStyle;
  83. std::string MemoryTesterOutputFile;
  84. int MemoryTesterGlobalResults[NO_MEMORY_FAULT];
  85. ///! Initialize memory checking subsystem.
  86. bool InitializeMemoryChecking();
  87. /**
  88. * Generate the Dart compatible output
  89. */
  90. void GenerateDartOutput(std::ostream& os);
  91. std::vector<std::string> CustomPreMemCheck;
  92. std::vector<std::string> CustomPostMemCheck;
  93. //! Parse Valgrind/Purify/Bounds Checker result out of the output
  94. //string. After running, log holds the output and results hold the
  95. //different memmory errors.
  96. bool ProcessMemCheckOutput(const std::string& str,
  97. std::string& log, int* results);
  98. bool ProcessMemCheckValgrindOutput(const std::string& str,
  99. std::string& log, int* results);
  100. bool ProcessMemCheckPurifyOutput(const std::string& str,
  101. std::string& log, int* results);
  102. bool ProcessMemCheckBoundsCheckerOutput(const std::string& str,
  103. std::string& log, int* results);
  104. void PostProcessPurifyTest(cmCTestTestResult& res, int test);
  105. void PostProcessBoundsCheckerTest(cmCTestTestResult& res, int test);
  106. void PostProcessValgrindTest(cmCTestTestResult& res, int test);
  107. ///! append MemoryTesterOutputFile to the test log
  108. void AppendMemTesterOutput(cmCTestTestHandler::cmCTestTestResult& res,
  109. int test);
  110. ///! generate the output filename for the given test index
  111. std::string TestOutputFileName(int test);
  112. };
  113. #endif