cmCTestMultiProcessHandler.h 2.7 KB

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