cmCTestMultiProcessHandler.h 3.0 KB

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