| 332 | } |
| 333 | |
| 334 | bool cmCTestMultiProcessHandler::AllocateResources(int index) |
| 335 | { |
| 336 | if (!this->UseResourceSpec) { |
| 337 | return true; |
| 338 | } |
| 339 | |
| 340 | // If the test needs unavailable resources then do not allocate anything |
| 341 | // because it will never run. We will issue the recorded errors instead. |
| 342 | if (!this->ResourceAvailabilityErrors[index].empty()) { |
| 343 | return true; |
| 344 | } |
| 345 | |
| 346 | std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations; |
| 347 | if (!this->TryAllocateResources(index, allocations)) { |
| 348 | return false; |
| 349 | } |
| 350 | |
| 351 | auto& allocatedResources = this->AllocatedResources[index]; |
| 352 | allocatedResources.resize(this->Properties[index]->ResourceGroups.size()); |
| 353 | for (auto const& it : allocations) { |
| 354 | for (auto const& alloc : it.second) { |
| 355 | bool result = this->ResourceAllocator.AllocateResource( |
| 356 | it.first, alloc.Id, alloc.SlotsNeeded); |
| 357 | (void)result; |
| 358 | assert(result); |
| 359 | allocatedResources[alloc.ProcessIndex][it.first].push_back( |
| 360 | { alloc.Id, static_cast<unsigned int>(alloc.SlotsNeeded) }); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | return true; |
| 365 | } |
| 366 | |
| 367 | bool cmCTestMultiProcessHandler::TryAllocateResources( |
| 368 | int index, |
no test coverage detected