cmCTestMemCheckHandler.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 cmCTestMemCheckHandler_h
  14. #define cmCTestMemCheckHandler_h
  15. #include "cmCTestTestHandler.h"
  16. #include "cmListFileCache.h"
  17. class cmMakefile;
  18. /** \class cmCTestMemCheckHandler
  19. * \brief A class that handles ctest -S invocations
  20. *
  21. */
  22. class cmCTestMemCheckHandler : public cmCTestTestHandler
  23. {
  24. public:
  25. cmTypeMacro(cmCTestMemCheckHandler, cmCTestTestHandler);
  26. void PopulateCustomVectors(cmMakefile *mf);
  27. cmCTestMemCheckHandler();
  28. void Initialize();
  29. protected:
  30. virtual int PreProcessHandler();
  31. virtual int PostProcessHandler();
  32. virtual void GenerateTestCommand(std::vector<const char*>& args);
  33. private:
  34. enum { // Memory checkers
  35. UNKNOWN = 0,
  36. VALGRIND,
  37. PURIFY,
  38. BOUNDS_CHECKER
  39. };
  40. public:
  41. enum { // Memory faults
  42. ABR = 0,
  43. ABW,
  44. ABWL,
  45. COR,
  46. EXU,
  47. FFM,
  48. FIM,
  49. FMM,
  50. FMR,
  51. FMW,
  52. FUM,
  53. IPR,
  54. IPW,
  55. MAF,
  56. MLK,
  57. MPK,
  58. NPR,
  59. ODS,
  60. PAR,
  61. PLK,
  62. UMC,
  63. UMR,
  64. NO_MEMORY_FAULT
  65. };
  66. private:
  67. enum { // Program statuses
  68. NOT_RUN = 0,
  69. TIMEOUT,
  70. SEGFAULT,
  71. ILLEGAL,
  72. INTERRUPT,
  73. NUMERICAL,
  74. OTHER_FAULT,
  75. FAILED,
  76. BAD_COMMAND,
  77. COMPLETED
  78. };
  79. std::string BoundsCheckerDPBDFile;
  80. std::string BoundsCheckerXMLFile;
  81. std::string MemoryTester;
  82. std::vector<cmStdString> MemoryTesterOptionsParsed;
  83. std::string MemoryTesterOptions;
  84. int MemoryTesterStyle;
  85. std::string MemoryTesterOutputFile;
  86. int MemoryTesterGlobalResults[NO_MEMORY_FAULT];
  87. ///! Initialize memory checking subsystem.
  88. bool InitializeMemoryChecking();
  89. /**
  90. * Generate the Dart compatible output
  91. */
  92. void GenerateDartOutput(std::ostream& os);
  93. std::vector<cmStdString> CustomPreMemCheck;
  94. std::vector<cmStdString> CustomPostMemCheck;
  95. //! Parse Valgrind/Purify/Bounds Checker result out of the output
  96. //string. After running, log holds the output and results hold the
  97. //different memmory errors.
  98. bool ProcessMemCheckOutput(const std::string& str,
  99. std::string& log, int* results);
  100. bool ProcessMemCheckValgrindOutput(const std::string& str,
  101. std::string& log, int* results);
  102. bool ProcessMemCheckPurifyOutput(const std::string& str,
  103. std::string& log, int* results);
  104. bool ProcessMemCheckBoundsCheckerOutput(const std::string& str,
  105. std::string& log, int* results);
  106. /**
  107. * Run one test
  108. */
  109. virtual void ProcessOneTest(cmCTestTestProperties *props,
  110. std::vector<cmStdString> &passed,
  111. std::vector<cmStdString> &failed,
  112. int count, int tmsize);
  113. void PostProcessPurifyTest(cmCTestTestResult& res);
  114. void PostProcessBoundsCheckerTest(cmCTestTestResult& res);
  115. };
  116. #endif