From a5be3916eeee82d5237f9ace85a74fc052240717 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 24 Feb 2020 11:41:06 -0500 Subject: CTest: Provide more detailed information on resource allocation error --- Source/CTest/cmCTestMultiProcessHandler.cxx | 34 +++++++++++++++++++++- Source/CTest/cmCTestTestHandler.cxx | 1 + Source/CTest/cmCTestTestHandler.h | 1 + .../notenough1-ctest-s-res-stderr.txt | 12 +++++++- .../notenough2-ctest-s-res-stderr.txt | 9 +++++- .../notenough3-ctest-s-res-stderr.txt | 19 +++++++++++- 6 files changed, 72 insertions(+), 4 deletions(-) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 6343353..2192843 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -197,7 +197,39 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test) this->LockResources(test); if (!this->ResourceAllocationErrors[test].empty()) { - testRun->StartFailure("Insufficient resources", "Failed to start"); + std::ostringstream e; + e << "Insufficient resources for test " << this->Properties[test]->Name + << ":\n\n"; + for (auto const& it : this->ResourceAllocationErrors[test]) { + switch (it.second) { + case ResourceAllocationError::NoResourceType: + e << " Test requested resources of type '" << it.first + << "' which does not exist\n"; + break; + + case ResourceAllocationError::InsufficientResources: + e << " Test requested resources of type '" << it.first + << "' in the following amounts:\n"; + for (auto const& group : this->Properties[test]->ResourceGroups) { + for (auto const& requirement : group) { + if (requirement.ResourceType == it.first) { + e << " " << requirement.SlotsNeeded + << (requirement.SlotsNeeded == 1 ? " slot\n" : " slots\n"); + } + } + } + e << " but only the following units were available:\n"; + for (auto const& res : + this->ResourceAllocator.GetResources().at(it.first)) { + e << " '" << res.first << "': " << res.second.Total + << (res.second.Total == 1 ? " slot\n" : " slots\n"); + } + break; + } + e << "\n"; + } + e << "Resource spec file:\n\n " << this->TestHandler->ResourceSpecFile; + testRun->StartFailure(e.str(), "Insufficient resources"); this->FinishTestProcess(testRun, false); return false; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 78c68be..4f324ea 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -548,6 +548,7 @@ bool cmCTestTestHandler::ProcessOptions() val = this->GetOption("ResourceSpecFile"); if (val) { this->UseResourceSpec = true; + this->ResourceSpecFile = val; auto result = this->ResourceSpec.ReadFromJSONFile(val); if (result != cmCTestResourceSpec::ReadFileResult::READ_OK) { cmCTestLog(this->CTest, ERROR_MESSAGE, diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 55237f9..b1c8755 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -338,6 +338,7 @@ private: bool UseResourceSpec; cmCTestResourceSpec ResourceSpec; + std::string ResourceSpecFile; void GenerateRegressionImages(cmXMLWriter& xml, const std::string& dart); cmsys::RegularExpression DartStuff1; diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt index 41df5af..91d7ef9 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt +++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt @@ -1,4 +1,14 @@ -^Insufficient resources +^Insufficient resources for test Test1: + + Test requested resources of type 'fluxcapacitors' in the following amounts: + 200 slots + but only the following units were available: + 'outatime': 121 slots + +Resource spec file: + + [^ +]*/Tests/RunCMake/CTestResourceAllocation/resspec.json CMake Error at [^ ]*/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res/test\.cmake:[0-9]+ \(message\): Tests did not pass$ diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt index 6c2f554..5c75a3d 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt +++ b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt @@ -1,4 +1,11 @@ -^Insufficient resources +^Insufficient resources for test Test1: + + Test requested resources of type 'terminators' which does not exist + +Resource spec file: + + [^ +]*/Tests/RunCMake/CTestResourceAllocation/resspec.json CMake Error at [^ ]*/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res/test\.cmake:[0-9]+ \(message\): Tests did not pass$ diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt index 82dfdef..4902a19 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt +++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt @@ -1,4 +1,21 @@ -^Insufficient resources +^Insufficient resources for test Test1: + + Test requested resources of type 'widgets' in the following amounts: + 12 slots + but only the following units were available: + '0': 4 slots + '1': 2 slots + '2': 4 slots + '3': 8 slots + '4': 1 slot + '5': 1 slot + '6': 1 slot + '7': 1 slot + +Resource spec file: + + [^ +]*/Tests/RunCMake/CTestResourceAllocation/resspec.json CMake Error at [^ ]*/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res/test\.cmake:[0-9]+ \(message\): Tests did not pass$ -- cgit v0.12