cmCTestMultiProcessHandler: Simplify test startup batching

Once a test is ready to run, count it against the number of tests to
start in the current batch whether or not the test process actually
starts successfully.  If a test process does fail to start, simply
schedule a new startup batch on the next loop iteration.
This commit is contained in:
Brad King
2023-11-20 19:09:03 -05:00
parent e528cd795f
commit 086a41c0f3
4 changed files with 14 additions and 20 deletions
+10 -13
View File
@@ -162,7 +162,7 @@ void cmCTestMultiProcessHandler::RunTests()
this->UpdateCostData();
}
bool cmCTestMultiProcessHandler::StartTestProcess(int test)
void cmCTestMultiProcessHandler::StartTestProcess(int test)
{
if (this->HaveAffinity && this->Properties[test]->WantAffinity) {
size_t needProcessors = this->GetProcessorsUsed(test);
@@ -241,7 +241,7 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
e << "Resource spec file:\n\n " << this->ResourceSpecFile;
cmCTestRunTest::StartFailure(std::move(testRun), this->Total, e.str(),
"Insufficient resources");
return false;
return;
}
cmWorkingDirectory workdir(this->Properties[test]->Directory);
@@ -251,13 +251,12 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
this->Properties[test]->Directory + " : " +
std::strerror(workdir.GetLastResult()),
"Failed to change working directory");
return false;
return;
}
// Ownership of 'testRun' has moved to another structure.
// When the test finishes, FinishTestProcess will be called.
return cmCTestRunTest::StartTest(std::move(testRun), this->Completed,
this->Total);
cmCTestRunTest::StartTest(std::move(testRun), this->Completed, this->Total);
}
bool cmCTestMultiProcessHandler::AllocateResources(int index)
@@ -461,9 +460,9 @@ std::string cmCTestMultiProcessHandler::GetName(int test)
return this->Properties[test]->Name;
}
bool cmCTestMultiProcessHandler::StartTest(int test)
void cmCTestMultiProcessHandler::StartTest(int test)
{
return this->StartTestProcess(test);
this->StartTestProcess(test);
}
void cmCTestMultiProcessHandler::StartNextTests()
@@ -583,9 +582,8 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
// The test is ready to run.
if (this->StartTest(test)) {
numToStart -= processors;
}
numToStart -= processors;
this->StartTest(test);
}
if (allTestsFailedTestLoadCheck) {
@@ -694,9 +692,8 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
properties->Affinity.clear();
runner.reset();
if (started) {
this->StartNextTestsOnIdle();
}
this->StartNextTestsOnIdle();
}
void cmCTestMultiProcessHandler::UpdateCostData()
+2 -2
View File
@@ -108,8 +108,8 @@ protected:
// Start the next test or tests as many as are allowed by
// ParallelLevel
void StartNextTests();
bool StartTestProcess(int test);
bool StartTest(int test);
void StartTestProcess(int test);
void StartTest(int test);
// Mark the checkpoint for the given test
void WriteCheckpoint(int index);
+1 -4
View File
@@ -530,7 +530,7 @@ std::string cmCTestRunTest::GetTestPrefix(size_t completed, size_t total) const
return outputStream.str();
}
bool cmCTestRunTest::StartTest(std::unique_ptr<cmCTestRunTest> runner,
void cmCTestRunTest::StartTest(std::unique_ptr<cmCTestRunTest> runner,
size_t completed, size_t total)
{
auto* testRun = runner.get();
@@ -539,10 +539,7 @@ bool cmCTestRunTest::StartTest(std::unique_ptr<cmCTestRunTest> runner,
if (!testRun->StartTest(completed, total)) {
testRun->FinalizeTest(false);
return false;
}
return true;
}
// Starts the execution of a test. Returns once it has started
+1 -1
View File
@@ -56,7 +56,7 @@ public:
// Read and store output. Returns true if it must be called again.
void CheckOutput(std::string const& line);
static bool StartTest(std::unique_ptr<cmCTestRunTest> runner,
static void StartTest(std::unique_ptr<cmCTestRunTest> runner,
size_t completed, size_t total);
static bool StartAgain(std::unique_ptr<cmCTestRunTest> runner,
size_t completed);