diff options
author | Zach Mullen <zach.mullen@kitware.com> | 2009-10-29 19:30:12 (GMT) |
---|---|---|
committer | Zach Mullen <zach.mullen@kitware.com> | 2009-10-29 19:30:12 (GMT) |
commit | 8612aa10b681fb31bcf3e4959b151fc7f3a5442e (patch) | |
tree | 60854e460425b7becc46e2ca93f9626a4262f2f1 /Source/CTest | |
parent | e183581b1459aba72758f395d7e1b74ff8f6aade (diff) | |
download | CMake-8612aa10b681fb31bcf3e4959b151fc7f3a5442e.zip CMake-8612aa10b681fb31bcf3e4959b151fc7f3a5442e.tar.gz CMake-8612aa10b681fb31bcf3e4959b151fc7f3a5442e.tar.bz2 |
Hook for scheduling tests in a random order
This may help statistically detect implicit dependencies among unit
tests while running in parallel.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestTestCommand.cxx | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestCommand.h | 8 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 18 |
3 files changed, 29 insertions, 3 deletions
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index a719b09..23cc20e 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -24,6 +24,7 @@ cmCTestTestCommand::cmCTestTestCommand() this->Arguments[ctt_EXCLUDE_LABEL] = "EXCLUDE_LABEL"; this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL"; this->Arguments[ctt_PARALLEL_LEVEL] = "PARALLEL_LEVEL"; + this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM"; this->Arguments[ctt_LAST] = 0; this->Last = ctt_LAST; } @@ -91,6 +92,11 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() handler->SetOption("ParallelLevel", this->Values[ctt_PARALLEL_LEVEL]); } + if(this->Values[ctt_SCHEDULE_RANDOM]) + { + handler->SetOption("ScheduleRandom", + this->Values[ctt_SCHEDULE_RANDOM]); + } return handler; } diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 73ce913..12314df 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -61,7 +61,8 @@ public: " [INCLUDE include regex] [RETURN_VALUE res] \n" " [EXCLUDE_LABEL exclude regex] \n" " [INCLUDE_LABEL label regex] \n" - " [PARALLEL_LEVEL level]) \n" + " [PARALLEL_LEVEL level] \n" + " [SCHEDULE_RANDOM on]) \n" "Tests the given build directory and stores results in Test.xml. The " "second argument is a variable that will hold value. Optionally, " "you can specify the starting test number START, the ending test number " @@ -70,7 +71,9 @@ public: "to not run EXCLUDE. EXCLUDE_LABEL and INCLUDE_LABEL are regular " "expression for test to be included or excluded by the test " "property LABEL. PARALLEL_LEVEL should be set to a positive number " - "representing the number of tests to be run in parallel." + "representing the number of tests to be run in parallel. " + "SCHEDULE_RANDOM will launch tests in a random order, and is " + "typically used to detect implicit test dependencies." "\n" CTEST_COMMAND_APPEND_OPTION_DOCS; } @@ -92,6 +95,7 @@ protected: ctt_EXCLUDE_LABEL, ctt_INCLUDE_LABEL, ctt_PARALLEL_LEVEL, + ctt_SCHEDULE_RANDOM, ctt_LAST }; }; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3572b11..56ddec7 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -491,11 +491,16 @@ int cmCTestTestHandler::ProcessHandler() { // Update internal data structure from generic one this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation")); - this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion"))); + this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion"))); + if(cmSystemTools::IsOn(this->GetOption("ScheduleRandom"))) + { + this->CTest->SetScheduleType("Random"); + } if(this->GetOption("ParallelLevel")) { this->CTest->SetParallelLevel(atoi(this->GetOption("ParallelLevel"))); } + const char* val; val = this->GetOption("LabelRegularExpression"); if ( val ) @@ -1021,12 +1026,23 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, cmCTestMultiProcessHandler::TestMap tests; cmCTestMultiProcessHandler::PropertiesMap properties; + bool randomSchedule = this->CTest->GetScheduleType() == "Random"; + if(randomSchedule) + { + srand((unsigned)time(0)); + } + for (ListOfTests::iterator it = this->TestList.begin(); it != this->TestList.end(); ++it) { cmCTestTestProperties& p = *it; cmCTestMultiProcessHandler::TestSet depends; + if(randomSchedule) + { + p.Cost = rand(); + } + if(p.Depends.size()) { for(std::vector<std::string>::iterator i = p.Depends.begin(); |