cmCTestMultiProcessHandler.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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., Insight Consortium. 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 cmCTestMultiProcessHandler_h
  14. #define cmCTestMultiProcessHandler_h
  15. class cmProcess;
  16. #include <cmStandardIncludes.h>
  17. #include <cmCTestTestHandler.h>
  18. /** \class cmCTestMultiProcessHandler
  19. * \brief run parallel ctest
  20. *
  21. * cmCTestMultiProcessHandler
  22. */
  23. class cmCTestMultiProcessHandler
  24. {
  25. public:
  26. struct TestSet : public std::set<int> {};
  27. struct TestMap : public std::map<int, TestSet> {};
  28. cmCTestMultiProcessHandler();
  29. // Set the tests
  30. void SetTests(TestMap& tests,
  31. std::map<int, cmStdString>& testNames);
  32. // Set the max number of tests that can be run at the same time.
  33. void SetParallelLevel(size_t);
  34. void RunTests();
  35. void PrintTests();
  36. void SetCTestCommand(const char* c) { this->CTestCommand = c;}
  37. void SetTestCacheFile(const char* c) { this->CTestCacheFile = c;}
  38. void SetPassFailVectors(std::vector<cmStdString>* passed,
  39. std::vector<cmStdString>* failed)
  40. {
  41. this->Passed = passed;
  42. this->Failed = failed;
  43. }
  44. void SetTestResults(std::vector<cmCTestTestHandler::cmCTestTestResult>* r)
  45. {
  46. this->TestResults = r;
  47. }
  48. void SetCTest(cmCTest* ctest) { this->CTest = ctest;}
  49. protected:
  50. cmCTest* CTest;
  51. // Start the next test or tests as many as are allowed by
  52. // ParallelLevel
  53. void StartNextTests();
  54. void StartTestProcess(int test);
  55. bool StartTest(int test);
  56. void EndTest(cmProcess*);
  57. // Return true if there are still tests running
  58. // check all running processes for output and exit case
  59. bool CheckOutput();
  60. // map from test number to set of depend tests
  61. TestMap Tests;
  62. std::map<int, cmStdString> TestNames;
  63. std::map<int, bool> TestRunningMap;
  64. std::map<int, bool> TestFinishMap;
  65. std::map<int, cmStdString> TestOutput;
  66. std::string CTestCommand;
  67. std::string CTestCacheFile;
  68. std::vector<cmStdString>* Passed;
  69. std::vector<cmStdString>* Failed;
  70. std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
  71. int ProcessId;
  72. size_t ParallelLevel; // max number of process that can be run at once
  73. std::set<cmProcess*> RunningTests; // current running tests
  74. };
  75. #endif