mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
CTest: Rename hardware -> resources for source code
This commit is contained in:
@@ -919,8 +919,8 @@ set(CTEST_SRCS cmCTest.cxx
|
|||||||
CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
|
CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
|
||||||
CTest/cmCTestGenericHandler.cxx
|
CTest/cmCTestGenericHandler.cxx
|
||||||
CTest/cmCTestHandlerCommand.cxx
|
CTest/cmCTestHandlerCommand.cxx
|
||||||
CTest/cmCTestHardwareAllocator.cxx
|
CTest/cmCTestResourceAllocator.cxx
|
||||||
CTest/cmCTestHardwareSpec.cxx
|
CTest/cmCTestResourceSpec.cxx
|
||||||
CTest/cmCTestLaunch.cxx
|
CTest/cmCTestLaunch.cxx
|
||||||
CTest/cmCTestMemCheckCommand.cxx
|
CTest/cmCTestMemCheckCommand.cxx
|
||||||
CTest/cmCTestMemCheckHandler.cxx
|
CTest/cmCTestMemCheckHandler.cxx
|
||||||
|
@@ -23,7 +23,7 @@ namespace {
|
|||||||
/*
|
/*
|
||||||
* The following algorithm is used to do two things:
|
* The following algorithm is used to do two things:
|
||||||
*
|
*
|
||||||
* 1) Determine if a test's hardware requirements can fit within the hardware
|
* 1) Determine if a test's resource requirements can fit within the resources
|
||||||
* present on the system, and
|
* present on the system, and
|
||||||
* 2) Do the actual allocation
|
* 2) Do the actual allocation
|
||||||
*
|
*
|
||||||
@@ -34,46 +34,46 @@ namespace {
|
|||||||
* more combinations can be tried.
|
* more combinations can be tried.
|
||||||
*/
|
*/
|
||||||
template <typename AllocationStrategy>
|
template <typename AllocationStrategy>
|
||||||
static bool AllocateCTestHardware(
|
static bool AllocateCTestResources(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
const std::vector<std::string>& hardwareSorted, std::size_t currentIndex,
|
const std::vector<std::string>& resourcesSorted, std::size_t currentIndex,
|
||||||
std::vector<cmCTestBinPackerAllocation*>& allocations)
|
std::vector<cmCTestBinPackerAllocation*>& allocations)
|
||||||
{
|
{
|
||||||
// Iterate through all large enough resources until we find a solution
|
// Iterate through all large enough resources until we find a solution
|
||||||
std::size_t hardwareIndex = 0;
|
std::size_t resourceIndex = 0;
|
||||||
while (hardwareIndex < hardwareSorted.size()) {
|
while (resourceIndex < resourcesSorted.size()) {
|
||||||
auto const& resource = hardware.at(hardwareSorted[hardwareIndex]);
|
auto const& resource = resources.at(resourcesSorted[resourceIndex]);
|
||||||
if (resource.Free() >=
|
if (resource.Free() >=
|
||||||
static_cast<unsigned int>(allocations[currentIndex]->SlotsNeeded)) {
|
static_cast<unsigned int>(allocations[currentIndex]->SlotsNeeded)) {
|
||||||
// Preemptively allocate the resource
|
// Preemptively allocate the resource
|
||||||
allocations[currentIndex]->Id = hardwareSorted[hardwareIndex];
|
allocations[currentIndex]->Id = resourcesSorted[resourceIndex];
|
||||||
if (currentIndex + 1 >= allocations.size()) {
|
if (currentIndex + 1 >= allocations.size()) {
|
||||||
// We have a solution
|
// We have a solution
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the resource up the list until it is sorted again
|
// Move the resource up the list until it is sorted again
|
||||||
auto hardware2 = hardware;
|
auto resources2 = resources;
|
||||||
auto hardwareSorted2 = hardwareSorted;
|
auto resourcesSorted2 = resourcesSorted;
|
||||||
hardware2[hardwareSorted2[hardwareIndex]].Locked +=
|
resources2[resourcesSorted2[resourceIndex]].Locked +=
|
||||||
allocations[currentIndex]->SlotsNeeded;
|
allocations[currentIndex]->SlotsNeeded;
|
||||||
AllocationStrategy::IncrementalSort(hardware2, hardwareSorted2,
|
AllocationStrategy::IncrementalSort(resources2, resourcesSorted2,
|
||||||
hardwareIndex);
|
resourceIndex);
|
||||||
|
|
||||||
// Recurse one level deeper
|
// Recurse one level deeper
|
||||||
if (AllocateCTestHardware<AllocationStrategy>(
|
if (AllocateCTestResources<AllocationStrategy>(
|
||||||
hardware2, hardwareSorted2, currentIndex + 1, allocations)) {
|
resources2, resourcesSorted2, currentIndex + 1, allocations)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No solution found here, deallocate the resource and try the next one
|
// No solution found here, deallocate the resource and try the next one
|
||||||
allocations[currentIndex]->Id.clear();
|
allocations[currentIndex]->Id.clear();
|
||||||
auto freeSlots = hardware.at(hardwareSorted.at(hardwareIndex)).Free();
|
auto freeSlots = resources.at(resourcesSorted.at(resourceIndex)).Free();
|
||||||
do {
|
do {
|
||||||
++hardwareIndex;
|
++resourceIndex;
|
||||||
} while (hardwareIndex < hardwareSorted.size() &&
|
} while (resourceIndex < resourcesSorted.size() &&
|
||||||
hardware.at(hardwareSorted.at(hardwareIndex)).Free() ==
|
resources.at(resourcesSorted.at(resourceIndex)).Free() ==
|
||||||
freeSlots);
|
freeSlots);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,8 +82,8 @@ static bool AllocateCTestHardware(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename AllocationStrategy>
|
template <typename AllocationStrategy>
|
||||||
static bool AllocateCTestHardware(
|
static bool AllocateCTestResources(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<cmCTestBinPackerAllocation>& allocations)
|
std::vector<cmCTestBinPackerAllocation>& allocations)
|
||||||
{
|
{
|
||||||
// Sort the resource requirements in descending order by slots needed
|
// Sort the resource requirements in descending order by slots needed
|
||||||
@@ -99,103 +99,105 @@ static bool AllocateCTestHardware(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Sort the resources according to sort strategy
|
// Sort the resources according to sort strategy
|
||||||
std::vector<std::string> hardwareSorted;
|
std::vector<std::string> resourcesSorted;
|
||||||
hardwareSorted.reserve(hardware.size());
|
resourcesSorted.reserve(resources.size());
|
||||||
for (auto const& hw : hardware) {
|
for (auto const& res : resources) {
|
||||||
hardwareSorted.push_back(hw.first);
|
resourcesSorted.push_back(res.first);
|
||||||
}
|
}
|
||||||
AllocationStrategy::InitialSort(hardware, hardwareSorted);
|
AllocationStrategy::InitialSort(resources, resourcesSorted);
|
||||||
|
|
||||||
// Do the actual allocation
|
// Do the actual allocation
|
||||||
return AllocateCTestHardware<AllocationStrategy>(
|
return AllocateCTestResources<AllocationStrategy>(
|
||||||
hardware, hardwareSorted, std::size_t(0), allocationsPtr);
|
resources, resourcesSorted, std::size_t(0), allocationsPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RoundRobinAllocationStrategy
|
class RoundRobinAllocationStrategy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void InitialSort(
|
static void InitialSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<std::string>& hardwareSorted);
|
std::vector<std::string>& resourcesSorted);
|
||||||
|
|
||||||
static void IncrementalSort(
|
static void IncrementalSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<std::string>& hardwareSorted, std::size_t lastAllocatedIndex);
|
std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
void RoundRobinAllocationStrategy::InitialSort(
|
void RoundRobinAllocationStrategy::InitialSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<std::string>& hardwareSorted)
|
std::vector<std::string>& resourcesSorted)
|
||||||
{
|
{
|
||||||
std::stable_sort(
|
std::stable_sort(
|
||||||
hardwareSorted.rbegin(), hardwareSorted.rend(),
|
resourcesSorted.rbegin(), resourcesSorted.rend(),
|
||||||
[&hardware](const std::string& id1, const std::string& id2) {
|
[&resources](const std::string& id1, const std::string& id2) {
|
||||||
return hardware.at(id1).Free() < hardware.at(id2).Free();
|
return resources.at(id1).Free() < resources.at(id2).Free();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoundRobinAllocationStrategy::IncrementalSort(
|
void RoundRobinAllocationStrategy::IncrementalSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<std::string>& hardwareSorted, std::size_t lastAllocatedIndex)
|
std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex)
|
||||||
{
|
{
|
||||||
auto tmp = hardwareSorted[lastAllocatedIndex];
|
auto tmp = resourcesSorted[lastAllocatedIndex];
|
||||||
std::size_t i = lastAllocatedIndex;
|
std::size_t i = lastAllocatedIndex;
|
||||||
while (i < hardwareSorted.size() - 1 &&
|
while (i < resourcesSorted.size() - 1 &&
|
||||||
hardware.at(hardwareSorted[i + 1]).Free() > hardware.at(tmp).Free()) {
|
resources.at(resourcesSorted[i + 1]).Free() >
|
||||||
hardwareSorted[i] = hardwareSorted[i + 1];
|
resources.at(tmp).Free()) {
|
||||||
|
resourcesSorted[i] = resourcesSorted[i + 1];
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
hardwareSorted[i] = tmp;
|
resourcesSorted[i] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BlockAllocationStrategy
|
class BlockAllocationStrategy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void InitialSort(
|
static void InitialSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<std::string>& hardwareSorted);
|
std::vector<std::string>& resourcesSorted);
|
||||||
|
|
||||||
static void IncrementalSort(
|
static void IncrementalSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<std::string>& hardwareSorted, std::size_t lastAllocatedIndex);
|
std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
void BlockAllocationStrategy::InitialSort(
|
void BlockAllocationStrategy::InitialSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<std::string>& hardwareSorted)
|
std::vector<std::string>& resourcesSorted)
|
||||||
{
|
{
|
||||||
std::stable_sort(
|
std::stable_sort(
|
||||||
hardwareSorted.rbegin(), hardwareSorted.rend(),
|
resourcesSorted.rbegin(), resourcesSorted.rend(),
|
||||||
[&hardware](const std::string& id1, const std::string& id2) {
|
[&resources](const std::string& id1, const std::string& id2) {
|
||||||
return hardware.at(id1).Free() < hardware.at(id2).Free();
|
return resources.at(id1).Free() < resources.at(id2).Free();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockAllocationStrategy::IncrementalSort(
|
void BlockAllocationStrategy::IncrementalSort(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>&,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>&,
|
||||||
std::vector<std::string>& hardwareSorted, std::size_t lastAllocatedIndex)
|
std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex)
|
||||||
{
|
{
|
||||||
auto tmp = hardwareSorted[lastAllocatedIndex];
|
auto tmp = resourcesSorted[lastAllocatedIndex];
|
||||||
std::size_t i = lastAllocatedIndex;
|
std::size_t i = lastAllocatedIndex;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
hardwareSorted[i] = hardwareSorted[i - 1];
|
resourcesSorted[i] = resourcesSorted[i - 1];
|
||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
hardwareSorted[i] = tmp;
|
resourcesSorted[i] = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmAllocateCTestHardwareRoundRobin(
|
bool cmAllocateCTestResourcesRoundRobin(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<cmCTestBinPackerAllocation>& allocations)
|
std::vector<cmCTestBinPackerAllocation>& allocations)
|
||||||
{
|
{
|
||||||
return AllocateCTestHardware<RoundRobinAllocationStrategy>(hardware,
|
return AllocateCTestResources<RoundRobinAllocationStrategy>(resources,
|
||||||
allocations);
|
allocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmAllocateCTestHardwareBlock(
|
bool cmAllocateCTestResourcesBlock(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<cmCTestBinPackerAllocation>& allocations)
|
std::vector<cmCTestBinPackerAllocation>& allocations)
|
||||||
{
|
{
|
||||||
return AllocateCTestHardware<BlockAllocationStrategy>(hardware, allocations);
|
return AllocateCTestResources<BlockAllocationStrategy>(resources,
|
||||||
|
allocations);
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cmCTestHardwareAllocator.h"
|
#include "cmCTestResourceAllocator.h"
|
||||||
|
|
||||||
struct cmCTestBinPackerAllocation
|
struct cmCTestBinPackerAllocation
|
||||||
{
|
{
|
||||||
@@ -20,12 +20,12 @@ struct cmCTestBinPackerAllocation
|
|||||||
bool operator!=(const cmCTestBinPackerAllocation& other) const;
|
bool operator!=(const cmCTestBinPackerAllocation& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool cmAllocateCTestHardwareRoundRobin(
|
bool cmAllocateCTestResourcesRoundRobin(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<cmCTestBinPackerAllocation>& allocations);
|
std::vector<cmCTestBinPackerAllocation>& allocations);
|
||||||
|
|
||||||
bool cmAllocateCTestHardwareBlock(
|
bool cmAllocateCTestResourcesBlock(
|
||||||
const std::map<std::string, cmCTestHardwareAllocator::Resource>& hardware,
|
const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
|
||||||
std::vector<cmCTestBinPackerAllocation>& allocations);
|
std::vector<cmCTestBinPackerAllocation>& allocations);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -140,7 +140,7 @@ void cmCTestMultiProcessHandler::RunTests()
|
|||||||
assert(this->Completed == this->Total);
|
assert(this->Completed == this->Total);
|
||||||
assert(this->Tests.empty());
|
assert(this->Tests.empty());
|
||||||
}
|
}
|
||||||
assert(this->AllHardwareAvailable());
|
assert(this->AllResourcesAvailable());
|
||||||
|
|
||||||
this->MarkFinished();
|
this->MarkFinished();
|
||||||
this->UpdateCostData();
|
this->UpdateCostData();
|
||||||
@@ -177,9 +177,9 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
|
|||||||
}
|
}
|
||||||
testRun->SetIndex(test);
|
testRun->SetIndex(test);
|
||||||
testRun->SetTestProperties(this->Properties[test]);
|
testRun->SetTestProperties(this->Properties[test]);
|
||||||
if (this->TestHandler->UseHardwareSpec) {
|
if (this->TestHandler->UseResourceSpec) {
|
||||||
testRun->SetUseAllocatedHardware(true);
|
testRun->SetUseAllocatedResources(true);
|
||||||
testRun->SetAllocatedHardware(this->AllocatedHardware[test]);
|
testRun->SetAllocatedResources(this->AllocatedResources[test]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find any failed dependencies for this test. We assume the more common
|
// Find any failed dependencies for this test. We assume the more common
|
||||||
@@ -194,7 +194,7 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
|
|||||||
// working directory because FinishTestProcess() will try to unlock them
|
// working directory because FinishTestProcess() will try to unlock them
|
||||||
this->LockResources(test);
|
this->LockResources(test);
|
||||||
|
|
||||||
if (!this->TestsHaveSufficientHardware[test]) {
|
if (!this->TestsHaveSufficientResources[test]) {
|
||||||
testRun->StartFailure("Insufficient resources");
|
testRun->StartFailure("Insufficient resources");
|
||||||
this->FinishTestProcess(testRun, false);
|
this->FinishTestProcess(testRun, false);
|
||||||
return false;
|
return false;
|
||||||
@@ -218,26 +218,26 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestMultiProcessHandler::AllocateHardware(int index)
|
bool cmCTestMultiProcessHandler::AllocateResources(int index)
|
||||||
{
|
{
|
||||||
if (!this->TestHandler->UseHardwareSpec) {
|
if (!this->TestHandler->UseResourceSpec) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
|
std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
|
||||||
if (!this->TryAllocateHardware(index, allocations)) {
|
if (!this->TryAllocateResources(index, allocations)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& allocatedHardware = this->AllocatedHardware[index];
|
auto& allocatedResources = this->AllocatedResources[index];
|
||||||
allocatedHardware.resize(this->Properties[index]->ResourceGroups.size());
|
allocatedResources.resize(this->Properties[index]->ResourceGroups.size());
|
||||||
for (auto const& it : allocations) {
|
for (auto const& it : allocations) {
|
||||||
for (auto const& alloc : it.second) {
|
for (auto const& alloc : it.second) {
|
||||||
bool result = this->HardwareAllocator.AllocateResource(
|
bool result = this->ResourceAllocator.AllocateResource(
|
||||||
it.first, alloc.Id, alloc.SlotsNeeded);
|
it.first, alloc.Id, alloc.SlotsNeeded);
|
||||||
(void)result;
|
(void)result;
|
||||||
assert(result);
|
assert(result);
|
||||||
allocatedHardware[alloc.ProcessIndex][it.first].push_back(
|
allocatedResources[alloc.ProcessIndex][it.first].push_back(
|
||||||
{ alloc.Id, static_cast<unsigned int>(alloc.SlotsNeeded) });
|
{ alloc.Id, static_cast<unsigned int>(alloc.SlotsNeeded) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ bool cmCTestMultiProcessHandler::AllocateHardware(int index)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestMultiProcessHandler::TryAllocateHardware(
|
bool cmCTestMultiProcessHandler::TryAllocateResources(
|
||||||
int index,
|
int index,
|
||||||
std::map<std::string, std::vector<cmCTestBinPackerAllocation>>& allocations)
|
std::map<std::string, std::vector<cmCTestBinPackerAllocation>>& allocations)
|
||||||
{
|
{
|
||||||
@@ -262,13 +262,13 @@ bool cmCTestMultiProcessHandler::TryAllocateHardware(
|
|||||||
++processIndex;
|
++processIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const& availableHardware = this->HardwareAllocator.GetResources();
|
auto const& availableResources = this->ResourceAllocator.GetResources();
|
||||||
for (auto& it : allocations) {
|
for (auto& it : allocations) {
|
||||||
if (!availableHardware.count(it.first)) {
|
if (!availableResources.count(it.first)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!cmAllocateCTestHardwareRoundRobin(availableHardware.at(it.first),
|
if (!cmAllocateCTestResourcesRoundRobin(availableResources.at(it.first),
|
||||||
it.second)) {
|
it.second)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,19 +276,19 @@ bool cmCTestMultiProcessHandler::TryAllocateHardware(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTestMultiProcessHandler::DeallocateHardware(int index)
|
void cmCTestMultiProcessHandler::DeallocateResources(int index)
|
||||||
{
|
{
|
||||||
if (!this->TestHandler->UseHardwareSpec) {
|
if (!this->TestHandler->UseResourceSpec) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto& allocatedHardware = this->AllocatedHardware[index];
|
auto& allocatedResources = this->AllocatedResources[index];
|
||||||
for (auto const& processAlloc : allocatedHardware) {
|
for (auto const& processAlloc : allocatedResources) {
|
||||||
for (auto const& it : processAlloc) {
|
for (auto const& it : processAlloc) {
|
||||||
auto resourceType = it.first;
|
auto resourceType = it.first;
|
||||||
for (auto const& it2 : it.second) {
|
for (auto const& it2 : it.second) {
|
||||||
bool success = this->HardwareAllocator.DeallocateResource(
|
bool success = this->ResourceAllocator.DeallocateResource(
|
||||||
resourceType, it2.Id, it2.Slots);
|
resourceType, it2.Id, it2.Slots);
|
||||||
(void)success;
|
(void)success;
|
||||||
assert(success);
|
assert(success);
|
||||||
@@ -296,12 +296,12 @@ void cmCTestMultiProcessHandler::DeallocateHardware(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->AllocatedHardware.erase(index);
|
this->AllocatedResources.erase(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestMultiProcessHandler::AllHardwareAvailable()
|
bool cmCTestMultiProcessHandler::AllResourcesAvailable()
|
||||||
{
|
{
|
||||||
for (auto const& it : this->HardwareAllocator.GetResources()) {
|
for (auto const& it : this->ResourceAllocator.GetResources()) {
|
||||||
for (auto const& it2 : it.second) {
|
for (auto const& it2 : it.second) {
|
||||||
if (it2.second.Locked != 0) {
|
if (it2.second.Locked != 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -312,13 +312,13 @@ bool cmCTestMultiProcessHandler::AllHardwareAvailable()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTestMultiProcessHandler::CheckHardwareAvailable()
|
void cmCTestMultiProcessHandler::CheckResourcesAvailable()
|
||||||
{
|
{
|
||||||
for (auto test : this->SortedTests) {
|
for (auto test : this->SortedTests) {
|
||||||
std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
|
std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
|
||||||
this->TestsHaveSufficientHardware[test] =
|
this->TestsHaveSufficientResources[test] =
|
||||||
!this->TestHandler->UseHardwareSpec ||
|
!this->TestHandler->UseResourceSpec ||
|
||||||
this->TryAllocateHardware(test, allocations);
|
this->TryAllocateResources(test, allocations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,10 +404,10 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate hardware
|
// Allocate resources
|
||||||
if (this->TestsHaveSufficientHardware[test] &&
|
if (this->TestsHaveSufficientResources[test] &&
|
||||||
!this->AllocateHardware(test)) {
|
!this->AllocateResources(test)) {
|
||||||
this->DeallocateHardware(test);
|
this->DeallocateResources(test);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
|
|||||||
}
|
}
|
||||||
// This test was not able to start because it is waiting
|
// This test was not able to start because it is waiting
|
||||||
// on depends to run
|
// on depends to run
|
||||||
this->DeallocateHardware(test);
|
this->DeallocateResources(test);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,7 +602,7 @@ void cmCTestMultiProcessHandler::FinishTestProcess(cmCTestRunTest* runner,
|
|||||||
this->TestFinishMap[test] = true;
|
this->TestFinishMap[test] = true;
|
||||||
this->TestRunningMap[test] = false;
|
this->TestRunningMap[test] = false;
|
||||||
this->WriteCheckpoint(test);
|
this->WriteCheckpoint(test);
|
||||||
this->DeallocateHardware(test);
|
this->DeallocateResources(test);
|
||||||
this->UnlockResources(test);
|
this->UnlockResources(test);
|
||||||
this->RunningCount -= GetProcessorsUsed(test);
|
this->RunningCount -= GetProcessorsUsed(test);
|
||||||
|
|
||||||
|
@@ -14,13 +14,13 @@
|
|||||||
|
|
||||||
#include "cm_uv.h"
|
#include "cm_uv.h"
|
||||||
|
|
||||||
#include "cmCTestHardwareAllocator.h"
|
#include "cmCTestResourceAllocator.h"
|
||||||
#include "cmCTestTestHandler.h"
|
#include "cmCTestTestHandler.h"
|
||||||
#include "cmUVHandlePtr.h"
|
#include "cmUVHandlePtr.h"
|
||||||
|
|
||||||
class cmCTest;
|
class cmCTest;
|
||||||
struct cmCTestBinPackerAllocation;
|
struct cmCTestBinPackerAllocation;
|
||||||
class cmCTestHardwareSpec;
|
class cmCTestResourceSpec;
|
||||||
class cmCTestRunTest;
|
class cmCTestRunTest;
|
||||||
|
|
||||||
/** \class cmCTestMultiProcessHandler
|
/** \class cmCTestMultiProcessHandler
|
||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
: public std::map<int, cmCTestTestHandler::cmCTestTestProperties*>
|
: public std::map<int, cmCTestTestHandler::cmCTestTestProperties*>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
struct HardwareAllocation
|
struct ResourceAllocation
|
||||||
{
|
{
|
||||||
std::string Id;
|
std::string Id;
|
||||||
unsigned int Slots;
|
unsigned int Slots;
|
||||||
@@ -87,12 +87,12 @@ public:
|
|||||||
|
|
||||||
void SetQuiet(bool b) { this->Quiet = b; }
|
void SetQuiet(bool b) { this->Quiet = b; }
|
||||||
|
|
||||||
void InitHardwareAllocator(const cmCTestHardwareSpec& spec)
|
void InitResourceAllocator(const cmCTestResourceSpec& spec)
|
||||||
{
|
{
|
||||||
this->HardwareAllocator.InitializeFromHardwareSpec(spec);
|
this->ResourceAllocator.InitializeFromResourceSpec(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckHardwareAvailable();
|
void CheckResourcesAvailable();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Start the next test or tests as many as are allowed by
|
// Start the next test or tests as many as are allowed by
|
||||||
@@ -137,13 +137,13 @@ protected:
|
|||||||
void LockResources(int index);
|
void LockResources(int index);
|
||||||
void UnlockResources(int index);
|
void UnlockResources(int index);
|
||||||
|
|
||||||
bool AllocateHardware(int index);
|
bool AllocateResources(int index);
|
||||||
bool TryAllocateHardware(
|
bool TryAllocateResources(
|
||||||
int index,
|
int index,
|
||||||
std::map<std::string, std::vector<cmCTestBinPackerAllocation>>&
|
std::map<std::string, std::vector<cmCTestBinPackerAllocation>>&
|
||||||
allocations);
|
allocations);
|
||||||
void DeallocateHardware(int index);
|
void DeallocateResources(int index);
|
||||||
bool AllHardwareAvailable();
|
bool AllResourcesAvailable();
|
||||||
|
|
||||||
// map from test number to set of depend tests
|
// map from test number to set of depend tests
|
||||||
TestMap Tests;
|
TestMap Tests;
|
||||||
@@ -166,10 +166,10 @@ protected:
|
|||||||
std::vector<std::string> LastTestsFailed;
|
std::vector<std::string> LastTestsFailed;
|
||||||
std::set<std::string> LockedResources;
|
std::set<std::string> LockedResources;
|
||||||
std::map<int,
|
std::map<int,
|
||||||
std::vector<std::map<std::string, std::vector<HardwareAllocation>>>>
|
std::vector<std::map<std::string, std::vector<ResourceAllocation>>>>
|
||||||
AllocatedHardware;
|
AllocatedResources;
|
||||||
std::map<int, bool> TestsHaveSufficientHardware;
|
std::map<int, bool> TestsHaveSufficientResources;
|
||||||
cmCTestHardwareAllocator HardwareAllocator;
|
cmCTestResourceAllocator ResourceAllocator;
|
||||||
std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
|
std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
|
||||||
size_t ParallelLevel; // max number of process that can be run at once
|
size_t ParallelLevel; // max number of process that can be run at once
|
||||||
unsigned long TestLoad;
|
unsigned long TestLoad;
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
|
||||||
#include "cmCTestHardwareAllocator.h"
|
#include "cmCTestResourceAllocator.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cmCTestHardwareSpec.h"
|
#include "cmCTestResourceSpec.h"
|
||||||
|
|
||||||
void cmCTestHardwareAllocator::InitializeFromHardwareSpec(
|
void cmCTestResourceAllocator::InitializeFromResourceSpec(
|
||||||
const cmCTestHardwareSpec& spec)
|
const cmCTestResourceSpec& spec)
|
||||||
{
|
{
|
||||||
this->Resources.clear();
|
this->Resources.clear();
|
||||||
|
|
||||||
@@ -23,13 +23,13 @@ void cmCTestHardwareAllocator::InitializeFromHardwareSpec(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string,
|
const std::map<std::string,
|
||||||
std::map<std::string, cmCTestHardwareAllocator::Resource>>&
|
std::map<std::string, cmCTestResourceAllocator::Resource>>&
|
||||||
cmCTestHardwareAllocator::GetResources() const
|
cmCTestResourceAllocator::GetResources() const
|
||||||
{
|
{
|
||||||
return this->Resources;
|
return this->Resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareAllocator::AllocateResource(const std::string& name,
|
bool cmCTestResourceAllocator::AllocateResource(const std::string& name,
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
unsigned int slots)
|
unsigned int slots)
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,7 @@ bool cmCTestHardwareAllocator::AllocateResource(const std::string& name,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareAllocator::DeallocateResource(const std::string& name,
|
bool cmCTestResourceAllocator::DeallocateResource(const std::string& name,
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
unsigned int slots)
|
unsigned int slots)
|
||||||
{
|
{
|
||||||
@@ -73,13 +73,13 @@ bool cmCTestHardwareAllocator::DeallocateResource(const std::string& name,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareAllocator::Resource::operator==(
|
bool cmCTestResourceAllocator::Resource::operator==(
|
||||||
const Resource& other) const
|
const Resource& other) const
|
||||||
{
|
{
|
||||||
return this->Total == other.Total && this->Locked == other.Locked;
|
return this->Total == other.Total && this->Locked == other.Locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareAllocator::Resource::operator!=(
|
bool cmCTestResourceAllocator::Resource::operator!=(
|
||||||
const Resource& other) const
|
const Resource& other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
return !(*this == other);
|
@@ -1,14 +1,14 @@
|
|||||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#ifndef cmCTestHardwareAllocator_h
|
#ifndef cmCTestResourceAllocator_h
|
||||||
#define cmCTestHardwareAllocator_h
|
#define cmCTestResourceAllocator_h
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class cmCTestHardwareSpec;
|
class cmCTestResourceSpec;
|
||||||
|
|
||||||
class cmCTestHardwareAllocator
|
class cmCTestResourceAllocator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Resource
|
struct Resource
|
||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
bool operator!=(const Resource& other) const;
|
bool operator!=(const Resource& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
void InitializeFromHardwareSpec(const cmCTestHardwareSpec& spec);
|
void InitializeFromResourceSpec(const cmCTestResourceSpec& spec);
|
||||||
|
|
||||||
const std::map<std::string, std::map<std::string, Resource>>& GetResources()
|
const std::map<std::string, std::map<std::string, Resource>>& GetResources()
|
||||||
const;
|
const;
|
@@ -1,6 +1,6 @@
|
|||||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmCTestHardwareSpec.h"
|
#include "cmCTestResourceSpec.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
static const cmsys::RegularExpression IdentifierRegex{ "^[a-z_][a-z0-9_]*$" };
|
static const cmsys::RegularExpression IdentifierRegex{ "^[a-z_][a-z0-9_]*$" };
|
||||||
static const cmsys::RegularExpression IdRegex{ "^[a-z0-9_]+$" };
|
static const cmsys::RegularExpression IdRegex{ "^[a-z0-9_]+$" };
|
||||||
|
|
||||||
bool cmCTestHardwareSpec::ReadFromJSONFile(const std::string& filename)
|
bool cmCTestResourceSpec::ReadFromJSONFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
cmsys::ifstream fin(filename.c_str());
|
cmsys::ifstream fin(filename.c_str());
|
||||||
if (!fin) {
|
if (!fin) {
|
||||||
@@ -50,7 +50,7 @@ bool cmCTestHardwareSpec::ReadFromJSONFile(const std::string& filename)
|
|||||||
if (!localSocket.isObject()) {
|
if (!localSocket.isObject()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::map<std::string, std::vector<cmCTestHardwareSpec::Resource>> resources;
|
std::map<std::string, std::vector<cmCTestResourceSpec::Resource>> resources;
|
||||||
cmsys::RegularExpressionMatch match;
|
cmsys::RegularExpressionMatch match;
|
||||||
for (auto const& key : localSocket.getMemberNames()) {
|
for (auto const& key : localSocket.getMemberNames()) {
|
||||||
if (IdentifierRegex.find(key.c_str(), match)) {
|
if (IdentifierRegex.find(key.c_str(), match)) {
|
||||||
@@ -59,7 +59,7 @@ bool cmCTestHardwareSpec::ReadFromJSONFile(const std::string& filename)
|
|||||||
if (value.isArray()) {
|
if (value.isArray()) {
|
||||||
for (auto const& item : value) {
|
for (auto const& item : value) {
|
||||||
if (item.isObject()) {
|
if (item.isObject()) {
|
||||||
cmCTestHardwareSpec::Resource resource;
|
cmCTestResourceSpec::Resource resource;
|
||||||
|
|
||||||
if (!item.isMember("id")) {
|
if (!item.isMember("id")) {
|
||||||
return false;
|
return false;
|
||||||
@@ -98,36 +98,36 @@ bool cmCTestHardwareSpec::ReadFromJSONFile(const std::string& filename)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareSpec::operator==(const cmCTestHardwareSpec& other) const
|
bool cmCTestResourceSpec::operator==(const cmCTestResourceSpec& other) const
|
||||||
{
|
{
|
||||||
return this->LocalSocket == other.LocalSocket;
|
return this->LocalSocket == other.LocalSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareSpec::operator!=(const cmCTestHardwareSpec& other) const
|
bool cmCTestResourceSpec::operator!=(const cmCTestResourceSpec& other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareSpec::Socket::operator==(
|
bool cmCTestResourceSpec::Socket::operator==(
|
||||||
const cmCTestHardwareSpec::Socket& other) const
|
const cmCTestResourceSpec::Socket& other) const
|
||||||
{
|
{
|
||||||
return this->Resources == other.Resources;
|
return this->Resources == other.Resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareSpec::Socket::operator!=(
|
bool cmCTestResourceSpec::Socket::operator!=(
|
||||||
const cmCTestHardwareSpec::Socket& other) const
|
const cmCTestResourceSpec::Socket& other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareSpec::Resource::operator==(
|
bool cmCTestResourceSpec::Resource::operator==(
|
||||||
const cmCTestHardwareSpec::Resource& other) const
|
const cmCTestResourceSpec::Resource& other) const
|
||||||
{
|
{
|
||||||
return this->Id == other.Id && this->Capacity == other.Capacity;
|
return this->Id == other.Id && this->Capacity == other.Capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestHardwareSpec::Resource::operator!=(
|
bool cmCTestResourceSpec::Resource::operator!=(
|
||||||
const cmCTestHardwareSpec::Resource& other) const
|
const cmCTestResourceSpec::Resource& other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
@@ -1,13 +1,13 @@
|
|||||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#ifndef cmCTestHardwareSpec_h
|
#ifndef cmCTestResourceSpec_h
|
||||||
#define cmCTestHardwareSpec_h
|
#define cmCTestResourceSpec_h
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class cmCTestHardwareSpec
|
class cmCTestResourceSpec
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Resource
|
class Resource
|
||||||
@@ -33,8 +33,8 @@ public:
|
|||||||
|
|
||||||
bool ReadFromJSONFile(const std::string& filename);
|
bool ReadFromJSONFile(const std::string& filename);
|
||||||
|
|
||||||
bool operator==(const cmCTestHardwareSpec& other) const;
|
bool operator==(const cmCTestResourceSpec& other) const;
|
||||||
bool operator!=(const cmCTestHardwareSpec& other) const;
|
bool operator!=(const cmCTestResourceSpec& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@@ -690,8 +690,8 @@ bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
|
|||||||
cmSystemTools::AppendEnv(*environment);
|
cmSystemTools::AppendEnv(*environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->UseAllocatedHardware) {
|
if (this->UseAllocatedResources) {
|
||||||
this->SetupHardwareEnvironment();
|
this->SetupResourcesEnvironment();
|
||||||
} else {
|
} else {
|
||||||
cmSystemTools::UnsetEnv("CTEST_RESOURCE_GROUP_COUNT");
|
cmSystemTools::UnsetEnv("CTEST_RESOURCE_GROUP_COUNT");
|
||||||
}
|
}
|
||||||
@@ -700,14 +700,14 @@ bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
|
|||||||
affinity);
|
affinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTestRunTest::SetupHardwareEnvironment()
|
void cmCTestRunTest::SetupResourcesEnvironment()
|
||||||
{
|
{
|
||||||
std::string processCount = "CTEST_RESOURCE_GROUP_COUNT=";
|
std::string processCount = "CTEST_RESOURCE_GROUP_COUNT=";
|
||||||
processCount += std::to_string(this->AllocatedHardware.size());
|
processCount += std::to_string(this->AllocatedResources.size());
|
||||||
cmSystemTools::PutEnv(processCount);
|
cmSystemTools::PutEnv(processCount);
|
||||||
|
|
||||||
std::size_t i = 0;
|
std::size_t i = 0;
|
||||||
for (auto const& process : this->AllocatedHardware) {
|
for (auto const& process : this->AllocatedResources) {
|
||||||
std::string prefix = "CTEST_RESOURCE_GROUP_";
|
std::string prefix = "CTEST_RESOURCE_GROUP_";
|
||||||
prefix += std::to_string(i);
|
prefix += std::to_string(i);
|
||||||
std::string resourceList = prefix + '=';
|
std::string resourceList = prefix + '=';
|
||||||
|
@@ -84,14 +84,17 @@ public:
|
|||||||
|
|
||||||
bool TimedOutForStopTime() const { return this->TimeoutIsForStopTime; }
|
bool TimedOutForStopTime() const { return this->TimeoutIsForStopTime; }
|
||||||
|
|
||||||
void SetUseAllocatedHardware(bool use) { this->UseAllocatedHardware = use; }
|
void SetUseAllocatedResources(bool use)
|
||||||
void SetAllocatedHardware(
|
{
|
||||||
|
this->UseAllocatedResources = use;
|
||||||
|
}
|
||||||
|
void SetAllocatedResources(
|
||||||
const std::vector<
|
const std::vector<
|
||||||
std::map<std::string,
|
std::map<std::string,
|
||||||
std::vector<cmCTestMultiProcessHandler::HardwareAllocation>>>&
|
std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>>&
|
||||||
hardware)
|
resources)
|
||||||
{
|
{
|
||||||
this->AllocatedHardware = hardware;
|
this->AllocatedResources = resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -105,7 +108,7 @@ private:
|
|||||||
// Run post processing of the process output for MemCheck
|
// Run post processing of the process output for MemCheck
|
||||||
void MemCheckPostProcess();
|
void MemCheckPostProcess();
|
||||||
|
|
||||||
void SetupHardwareEnvironment();
|
void SetupResourcesEnvironment();
|
||||||
|
|
||||||
// Returns "completed/total Test #Index: "
|
// Returns "completed/total Test #Index: "
|
||||||
std::string GetTestPrefix(size_t completed, size_t total) const;
|
std::string GetTestPrefix(size_t completed, size_t total) const;
|
||||||
@@ -125,10 +128,10 @@ private:
|
|||||||
std::string StartTime;
|
std::string StartTime;
|
||||||
std::string ActualCommand;
|
std::string ActualCommand;
|
||||||
std::vector<std::string> Arguments;
|
std::vector<std::string> Arguments;
|
||||||
bool UseAllocatedHardware = false;
|
bool UseAllocatedResources = false;
|
||||||
std::vector<std::map<
|
std::vector<std::map<
|
||||||
std::string, std::vector<cmCTestMultiProcessHandler::HardwareAllocation>>>
|
std::string, std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>>
|
||||||
AllocatedHardware;
|
AllocatedResources;
|
||||||
bool RunUntilFail;
|
bool RunUntilFail;
|
||||||
int NumberOfRunsLeft;
|
int NumberOfRunsLeft;
|
||||||
bool RunAgain;
|
bool RunAgain;
|
||||||
|
@@ -32,7 +32,7 @@ void cmCTestTestCommand::BindArguments()
|
|||||||
this->Bind("SCHEDULE_RANDOM"_s, this->ScheduleRandom);
|
this->Bind("SCHEDULE_RANDOM"_s, this->ScheduleRandom);
|
||||||
this->Bind("STOP_TIME"_s, this->StopTime);
|
this->Bind("STOP_TIME"_s, this->StopTime);
|
||||||
this->Bind("TEST_LOAD"_s, this->TestLoad);
|
this->Bind("TEST_LOAD"_s, this->TestLoad);
|
||||||
this->Bind("RESOURCE_SPEC_FILE"_s, this->HardwareSpecFile);
|
this->Bind("RESOURCE_SPEC_FILE"_s, this->ResourceSpecFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
|
cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
|
||||||
@@ -88,8 +88,8 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
|
|||||||
if (!this->ScheduleRandom.empty()) {
|
if (!this->ScheduleRandom.empty()) {
|
||||||
handler->SetOption("ScheduleRandom", this->ScheduleRandom.c_str());
|
handler->SetOption("ScheduleRandom", this->ScheduleRandom.c_str());
|
||||||
}
|
}
|
||||||
if (!this->HardwareSpecFile.empty()) {
|
if (!this->ResourceSpecFile.empty()) {
|
||||||
handler->SetOption("ResourceSpecFile", this->HardwareSpecFile.c_str());
|
handler->SetOption("ResourceSpecFile", this->ResourceSpecFile.c_str());
|
||||||
}
|
}
|
||||||
if (!this->StopTime.empty()) {
|
if (!this->StopTime.empty()) {
|
||||||
this->CTest->SetStopTime(this->StopTime);
|
this->CTest->SetStopTime(this->StopTime);
|
||||||
|
@@ -58,7 +58,7 @@ protected:
|
|||||||
std::string ScheduleRandom;
|
std::string ScheduleRandom;
|
||||||
std::string StopTime;
|
std::string StopTime;
|
||||||
std::string TestLoad;
|
std::string TestLoad;
|
||||||
std::string HardwareSpecFile;
|
std::string ResourceSpecFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -289,7 +289,7 @@ cmCTestTestHandler::cmCTestTestHandler()
|
|||||||
this->UseIncludeRegExpFlag = false;
|
this->UseIncludeRegExpFlag = false;
|
||||||
this->UseExcludeRegExpFlag = false;
|
this->UseExcludeRegExpFlag = false;
|
||||||
this->UseExcludeRegExpFirst = false;
|
this->UseExcludeRegExpFirst = false;
|
||||||
this->UseHardwareSpec = false;
|
this->UseResourceSpec = false;
|
||||||
|
|
||||||
this->CustomMaximumPassedTestOutputSize = 1 * 1024;
|
this->CustomMaximumPassedTestOutputSize = 1 * 1024;
|
||||||
this->CustomMaximumFailedTestOutputSize = 300 * 1024;
|
this->CustomMaximumFailedTestOutputSize = 300 * 1024;
|
||||||
@@ -512,8 +512,8 @@ bool cmCTestTestHandler::ProcessOptions()
|
|||||||
|
|
||||||
val = this->GetOption("ResourceSpecFile");
|
val = this->GetOption("ResourceSpecFile");
|
||||||
if (val) {
|
if (val) {
|
||||||
this->UseHardwareSpec = true;
|
this->UseResourceSpec = true;
|
||||||
if (!this->HardwareSpec.ReadFromJSONFile(val)) {
|
if (!this->ResourceSpec.ReadFromJSONFile(val)) {
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
"Could not read resource spec file: " << val << std::endl);
|
"Could not read resource spec file: " << val << std::endl);
|
||||||
return false;
|
return false;
|
||||||
@@ -1237,8 +1237,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
|
|||||||
} else {
|
} else {
|
||||||
parallel->SetTestLoad(this->CTest->GetTestLoad());
|
parallel->SetTestLoad(this->CTest->GetTestLoad());
|
||||||
}
|
}
|
||||||
if (this->UseHardwareSpec) {
|
if (this->UseResourceSpec) {
|
||||||
parallel->InitHardwareAllocator(this->HardwareSpec);
|
parallel->InitResourceAllocator(this->ResourceSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
*this->LogFile
|
*this->LogFile
|
||||||
@@ -1283,7 +1283,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
|
|||||||
parallel->SetPassFailVectors(&passed, &failed);
|
parallel->SetPassFailVectors(&passed, &failed);
|
||||||
this->TestResults.clear();
|
this->TestResults.clear();
|
||||||
parallel->SetTestResults(&this->TestResults);
|
parallel->SetTestResults(&this->TestResults);
|
||||||
parallel->CheckHardwareAvailable();
|
parallel->CheckResourcesAvailable();
|
||||||
|
|
||||||
if (this->CTest->ShouldPrintLabels()) {
|
if (this->CTest->ShouldPrintLabels()) {
|
||||||
parallel->PrintLabels();
|
parallel->PrintLabels();
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#include "cmsys/RegularExpression.hxx"
|
#include "cmsys/RegularExpression.hxx"
|
||||||
|
|
||||||
#include "cmCTestGenericHandler.h"
|
#include "cmCTestGenericHandler.h"
|
||||||
#include "cmCTestHardwareSpec.h"
|
#include "cmCTestResourceSpec.h"
|
||||||
#include "cmDuration.h"
|
#include "cmDuration.h"
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
|
|
||||||
@@ -336,8 +336,8 @@ private:
|
|||||||
cmsys::RegularExpression IncludeTestsRegularExpression;
|
cmsys::RegularExpression IncludeTestsRegularExpression;
|
||||||
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
cmsys::RegularExpression ExcludeTestsRegularExpression;
|
||||||
|
|
||||||
bool UseHardwareSpec;
|
bool UseResourceSpec;
|
||||||
cmCTestHardwareSpec HardwareSpec;
|
cmCTestResourceSpec ResourceSpec;
|
||||||
|
|
||||||
void GenerateRegressionImages(cmXMLWriter& xml, const std::string& dart);
|
void GenerateRegressionImages(cmXMLWriter& xml, const std::string& dart);
|
||||||
cmsys::RegularExpression DartStuff1;
|
cmsys::RegularExpression DartStuff1;
|
||||||
|
@@ -8,8 +8,8 @@ include_directories(
|
|||||||
set(CMakeLib_TESTS
|
set(CMakeLib_TESTS
|
||||||
testArgumentParser.cxx
|
testArgumentParser.cxx
|
||||||
testCTestBinPacker.cxx
|
testCTestBinPacker.cxx
|
||||||
testCTestHardwareAllocator.cxx
|
testCTestResourceAllocator.cxx
|
||||||
testCTestHardwareSpec.cxx
|
testCTestResourceSpec.cxx
|
||||||
testCTestResourceGroups.cxx
|
testCTestResourceGroups.cxx
|
||||||
testGeneratedFileStream.cxx
|
testGeneratedFileStream.cxx
|
||||||
testRST.cxx
|
testRST.cxx
|
||||||
@@ -32,7 +32,7 @@ add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx)
|
|||||||
set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
|
set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>)
|
set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>)
|
||||||
set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>)
|
set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>)
|
||||||
set(testCTestHardwareSpec_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
|
set(testCTestResourceSpec_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND CMakeLib_TESTS
|
list(APPEND CMakeLib_TESTS
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cmCTestBinPacker.h"
|
#include "cmCTestBinPacker.h"
|
||||||
#include "cmCTestHardwareAllocator.h"
|
#include "cmCTestResourceAllocator.h"
|
||||||
|
|
||||||
struct ExpectedPackResult
|
struct ExpectedPackResult
|
||||||
{
|
{
|
||||||
std::vector<int> SlotsNeeded;
|
std::vector<int> SlotsNeeded;
|
||||||
std::map<std::string, cmCTestHardwareAllocator::Resource> Hardware;
|
std::map<std::string, cmCTestResourceAllocator::Resource> Resources;
|
||||||
bool ExpectedReturnValue;
|
bool ExpectedReturnValue;
|
||||||
std::vector<cmCTestBinPackerAllocation> ExpectedRoundRobinAllocations;
|
std::vector<cmCTestBinPackerAllocation> ExpectedRoundRobinAllocations;
|
||||||
std::vector<cmCTestBinPackerAllocation> ExpectedBlockAllocations;
|
std::vector<cmCTestBinPackerAllocation> ExpectedBlockAllocations;
|
||||||
@@ -233,18 +233,18 @@ bool TestExpectedPackResult(const ExpectedPackResult& expected)
|
|||||||
roundRobinAllocations.push_back({ index++, n, "" });
|
roundRobinAllocations.push_back({ index++, n, "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool roundRobinResult = cmAllocateCTestHardwareRoundRobin(
|
bool roundRobinResult = cmAllocateCTestResourcesRoundRobin(
|
||||||
expected.Hardware, roundRobinAllocations);
|
expected.Resources, roundRobinAllocations);
|
||||||
if (roundRobinResult != expected.ExpectedReturnValue) {
|
if (roundRobinResult != expected.ExpectedReturnValue) {
|
||||||
std::cout
|
std::cout
|
||||||
<< "cmAllocateCTestHardwareRoundRobin did not return expected value"
|
<< "cmAllocateCTestResourcesRoundRobin did not return expected value"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundRobinResult &&
|
if (roundRobinResult &&
|
||||||
roundRobinAllocations != expected.ExpectedRoundRobinAllocations) {
|
roundRobinAllocations != expected.ExpectedRoundRobinAllocations) {
|
||||||
std::cout << "cmAllocateCTestHardwareRoundRobin did not return expected "
|
std::cout << "cmAllocateCTestResourcesRoundRobin did not return expected "
|
||||||
"allocations"
|
"allocations"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
@@ -258,15 +258,15 @@ bool TestExpectedPackResult(const ExpectedPackResult& expected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool blockResult =
|
bool blockResult =
|
||||||
cmAllocateCTestHardwareBlock(expected.Hardware, blockAllocations);
|
cmAllocateCTestResourcesBlock(expected.Resources, blockAllocations);
|
||||||
if (blockResult != expected.ExpectedReturnValue) {
|
if (blockResult != expected.ExpectedReturnValue) {
|
||||||
std::cout << "cmAllocateCTestHardwareBlock did not return expected value"
|
std::cout << "cmAllocateCTestResourcesBlock did not return expected value"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockResult && blockAllocations != expected.ExpectedBlockAllocations) {
|
if (blockResult && blockAllocations != expected.ExpectedBlockAllocations) {
|
||||||
std::cout << "cmAllocateCTestHardwareBlock did not return expected"
|
std::cout << "cmAllocateCTestResourcesBlock did not return expected"
|
||||||
" allocations"
|
" allocations"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
@@ -3,24 +3,24 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cmCTestHardwareAllocator.h"
|
#include "cmCTestResourceAllocator.h"
|
||||||
#include "cmCTestHardwareSpec.h"
|
#include "cmCTestResourceSpec.h"
|
||||||
|
|
||||||
static const cmCTestHardwareSpec spec{ { {
|
static const cmCTestResourceSpec spec{ { {
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", { { "0", 4 }, { "1", 8 }, { "2", 0 }, { "3", 8 } } },
|
{ "gpus", { { "0", 4 }, { "1", 8 }, { "2", 0 }, { "3", 8 } } },
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
} } };
|
} } };
|
||||||
|
|
||||||
bool testInitializeFromHardwareSpec()
|
bool testInitializeFromResourceSpec()
|
||||||
{
|
{
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
|
|
||||||
cmCTestHardwareAllocator allocator;
|
cmCTestResourceAllocator allocator;
|
||||||
allocator.InitializeFromHardwareSpec(spec);
|
allocator.InitializeFromResourceSpec(spec);
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected{
|
expected{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -43,11 +43,11 @@ bool testAllocateResource()
|
|||||||
{
|
{
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
|
|
||||||
cmCTestHardwareAllocator allocator;
|
cmCTestResourceAllocator allocator;
|
||||||
allocator.InitializeFromHardwareSpec(spec);
|
allocator.InitializeFromResourceSpec(spec);
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected1{
|
expected1{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -70,7 +70,7 @@ bool testAllocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected2{
|
expected2{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -93,7 +93,7 @@ bool testAllocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected3{
|
expected3{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -116,7 +116,7 @@ bool testAllocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected4{
|
expected4{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -145,7 +145,7 @@ bool testAllocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected5{
|
expected5{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -168,7 +168,7 @@ bool testAllocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected6{
|
expected6{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -191,7 +191,7 @@ bool testAllocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected7{
|
expected7{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -220,11 +220,11 @@ bool testDeallocateResource()
|
|||||||
{
|
{
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
|
|
||||||
cmCTestHardwareAllocator allocator;
|
cmCTestResourceAllocator allocator;
|
||||||
allocator.InitializeFromHardwareSpec(spec);
|
allocator.InitializeFromResourceSpec(spec);
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected1{
|
expected1{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -253,7 +253,7 @@ bool testDeallocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected2{
|
expected2{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -276,7 +276,7 @@ bool testDeallocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected3{
|
expected3{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -299,7 +299,7 @@ bool testDeallocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected4{
|
expected4{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -322,7 +322,7 @@ bool testDeallocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected5{
|
expected5{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -345,7 +345,7 @@ bool testDeallocateResource()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::map<
|
static const std::map<
|
||||||
std::string, std::map<std::string, cmCTestHardwareAllocator::Resource>>
|
std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
|
||||||
expected6{
|
expected6{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{ "gpus", {
|
{ "gpus", {
|
||||||
@@ -374,23 +374,23 @@ bool testResourceFree()
|
|||||||
{
|
{
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
|
|
||||||
const cmCTestHardwareAllocator::Resource r1{ 5, 0 };
|
const cmCTestResourceAllocator::Resource r1{ 5, 0 };
|
||||||
if (r1.Free() != 5) {
|
if (r1.Free() != 5) {
|
||||||
std::cout << "cmCTestHardwareAllocator::Resource::Free() did not return "
|
std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
|
||||||
"expected value for { 5, 0 }\n";
|
"expected value for { 5, 0 }\n";
|
||||||
retval = false;
|
retval = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmCTestHardwareAllocator::Resource r2{ 3, 2 };
|
const cmCTestResourceAllocator::Resource r2{ 3, 2 };
|
||||||
if (r2.Free() != 1) {
|
if (r2.Free() != 1) {
|
||||||
std::cout << "cmCTestHardwareAllocator::Resource::Free() did not return "
|
std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
|
||||||
"expected value for { 3, 2 }\n";
|
"expected value for { 3, 2 }\n";
|
||||||
retval = false;
|
retval = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmCTestHardwareAllocator::Resource r3{ 4, 4 };
|
const cmCTestResourceAllocator::Resource r3{ 4, 4 };
|
||||||
if (r3.Free() != 0) {
|
if (r3.Free() != 0) {
|
||||||
std::cout << "cmCTestHardwareAllocator::Resource::Free() did not return "
|
std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
|
||||||
"expected value for { 4, 4 }\n";
|
"expected value for { 4, 4 }\n";
|
||||||
retval = false;
|
retval = false;
|
||||||
}
|
}
|
||||||
@@ -398,12 +398,12 @@ bool testResourceFree()
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testCTestHardwareAllocator(int, char** const)
|
int testCTestResourceAllocator(int, char** const)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if (!testInitializeFromHardwareSpec()) {
|
if (!testInitializeFromResourceSpec()) {
|
||||||
std::cout << "in testInitializeFromHardwareSpec()\n";
|
std::cout << "in testInitializeFromResourceSpec()\n";
|
||||||
retval = -1;
|
retval = -1;
|
||||||
}
|
}
|
||||||
|
|
@@ -2,16 +2,16 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cmCTestHardwareSpec.h"
|
#include "cmCTestResourceSpec.h"
|
||||||
|
|
||||||
struct ExpectedSpec
|
struct ExpectedSpec
|
||||||
{
|
{
|
||||||
std::string Path;
|
std::string Path;
|
||||||
bool ParseResult;
|
bool ParseResult;
|
||||||
cmCTestHardwareSpec Expected;
|
cmCTestResourceSpec Expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::vector<ExpectedSpec> expectedHardwareSpecs = {
|
static const std::vector<ExpectedSpec> expectedResourceSpecs = {
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
{"spec1.json", true, {{{
|
{"spec1.json", true, {{{
|
||||||
{"gpus", {
|
{"gpus", {
|
||||||
@@ -44,9 +44,9 @@ static const std::vector<ExpectedSpec> expectedHardwareSpecs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static bool testSpec(const std::string& path, bool expectedResult,
|
static bool testSpec(const std::string& path, bool expectedResult,
|
||||||
const cmCTestHardwareSpec& expected)
|
const cmCTestResourceSpec& expected)
|
||||||
{
|
{
|
||||||
cmCTestHardwareSpec actual;
|
cmCTestResourceSpec actual;
|
||||||
bool result = actual.ReadFromJSONFile(path);
|
bool result = actual.ReadFromJSONFile(path);
|
||||||
if (result != expectedResult) {
|
if (result != expectedResult) {
|
||||||
std::cout << "ReadFromJSONFile(\"" << path << "\") returned " << result
|
std::cout << "ReadFromJSONFile(\"" << path << "\") returned " << result
|
||||||
@@ -63,7 +63,7 @@ static bool testSpec(const std::string& path, bool expectedResult,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testCTestHardwareSpec(int argc, char** const argv)
|
int testCTestResourceSpec(int argc, char** const argv)
|
||||||
{
|
{
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
std::cout << "Invalid arguments.\n";
|
std::cout << "Invalid arguments.\n";
|
||||||
@@ -71,9 +71,9 @@ int testCTestHardwareSpec(int argc, char** const argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
for (auto const& spec : expectedHardwareSpecs) {
|
for (auto const& spec : expectedResourceSpecs) {
|
||||||
std::string path = argv[1];
|
std::string path = argv[1];
|
||||||
path += "/testCTestHardwareSpec_data/";
|
path += "/testCTestResourceSpec_data/";
|
||||||
path += spec.Path;
|
path += spec.Path;
|
||||||
if (!testSpec(path, spec.ParseResult, spec.Expected)) {
|
if (!testSpec(path, spec.ParseResult, spec.Expected)) {
|
||||||
retval = -1;
|
retval = -1;
|
@@ -13,9 +13,9 @@
|
|||||||
#include "cmsys/Encoding.hxx"
|
#include "cmsys/Encoding.hxx"
|
||||||
#include "cmsys/FStream.hxx"
|
#include "cmsys/FStream.hxx"
|
||||||
|
|
||||||
#include "cmCTestHardwareAllocator.h"
|
|
||||||
#include "cmCTestHardwareSpec.h"
|
|
||||||
#include "cmCTestMultiProcessHandler.h"
|
#include "cmCTestMultiProcessHandler.h"
|
||||||
|
#include "cmCTestResourceAllocator.h"
|
||||||
|
#include "cmCTestResourceSpec.h"
|
||||||
#include "cmCTestTestHandler.h"
|
#include "cmCTestTestHandler.h"
|
||||||
#include "cmFileLock.h"
|
#include "cmFileLock.h"
|
||||||
#include "cmFileLockResult.h"
|
#include "cmFileLockResult.h"
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This helper program is used to verify that the CTest hardware allocation
|
* This helper program is used to verify that the CTest resource allocation
|
||||||
* feature is working correctly. It consists of two stages:
|
* feature is working correctly. It consists of two stages:
|
||||||
*
|
*
|
||||||
* 1) write - This stage receives the RESOURCE_GROUPS property of the test and
|
* 1) write - This stage receives the RESOURCE_GROUPS property of the test and
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
* environment variables. If it received all of the resources it expected,
|
* environment variables. If it received all of the resources it expected,
|
||||||
* then it writes this information to a log file, which will be read in
|
* then it writes this information to a log file, which will be read in
|
||||||
* the verify stage.
|
* the verify stage.
|
||||||
* 2) verify - This stage compares the log file with the hardware spec file to
|
* 2) verify - This stage compares the log file with the resource spec file to
|
||||||
* make sure that no resources were over-subscribed, deallocated without
|
* make sure that no resources were over-subscribed, deallocated without
|
||||||
* being allocated, or allocated without being deallocated.
|
* being allocated, or allocated without being deallocated.
|
||||||
*/
|
*/
|
||||||
@@ -68,8 +68,8 @@ static int doWrite(int argc, char const* const* argv)
|
|||||||
std::string testName = argv[3];
|
std::string testName = argv[3];
|
||||||
unsigned int sleepTime = std::atoi(argv[4]);
|
unsigned int sleepTime = std::atoi(argv[4]);
|
||||||
std::vector<std::map<
|
std::vector<std::map<
|
||||||
std::string, std::vector<cmCTestMultiProcessHandler::HardwareAllocation>>>
|
std::string, std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>>
|
||||||
hardware;
|
resources;
|
||||||
if (argc == 6) {
|
if (argc == 6) {
|
||||||
// Parse RESOURCE_GROUPS property
|
// Parse RESOURCE_GROUPS property
|
||||||
std::string resourceGroupsProperty = argv[5];
|
std::string resourceGroupsProperty = argv[5];
|
||||||
@@ -146,8 +146,8 @@ static int doWrite(int argc, char const* const* argv)
|
|||||||
// Verify that we got what we asked for and write it to the log
|
// Verify that we got what we asked for and write it to the log
|
||||||
prefix += '_';
|
prefix += '_';
|
||||||
std::map<std::string,
|
std::map<std::string,
|
||||||
std::vector<cmCTestMultiProcessHandler::HardwareAllocation>>
|
std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>
|
||||||
hwEntry;
|
resEntry;
|
||||||
for (auto const& type : actualResources) {
|
for (auto const& type : actualResources) {
|
||||||
auto it = resourceGroup.begin();
|
auto it = resourceGroup.begin();
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ static int doWrite(int argc, char const* const* argv)
|
|||||||
|
|
||||||
fout << "alloc " << type << " " << id << " " << amount
|
fout << "alloc " << type << " " << id << " " << amount
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
hwEntry[type].push_back({ id, amount });
|
resEntry[type].push_back({ id, amount });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ended = false;
|
bool ended = false;
|
||||||
@@ -212,7 +212,7 @@ static int doWrite(int argc, char const* const* argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hardware.push_back(hwEntry);
|
resources.push_back(resEntry);
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@@ -249,7 +249,7 @@ static int doWrite(int argc, char const* const* argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
cmsys::ofstream fout(logFile.c_str(), std::ios::app);
|
cmsys::ofstream fout(logFile.c_str(), std::ios::app);
|
||||||
for (auto const& group : hardware) {
|
for (auto const& group : resources) {
|
||||||
for (auto const& it : group) {
|
for (auto const& it : group) {
|
||||||
for (auto const& it2 : it.second) {
|
for (auto const& it2 : it.second) {
|
||||||
fout << "dealloc " << it.first << " " << it2.Id << " " << it2.Slots
|
fout << "dealloc " << it.first << " " << it2.Id << " " << it2.Slots
|
||||||
@@ -276,7 +276,7 @@ static int doVerify(int argc, char const* const* argv)
|
|||||||
return usageVerify(argv[0]);
|
return usageVerify(argv[0]);
|
||||||
}
|
}
|
||||||
std::string logFile = argv[2];
|
std::string logFile = argv[2];
|
||||||
std::string hwFile = argv[3];
|
std::string resFile = argv[3];
|
||||||
std::string testNames;
|
std::string testNames;
|
||||||
if (argc == 5) {
|
if (argc == 5) {
|
||||||
testNames = argv[4];
|
testNames = argv[4];
|
||||||
@@ -284,14 +284,14 @@ static int doVerify(int argc, char const* const* argv)
|
|||||||
auto testNameList = cmExpandedList(testNames, false);
|
auto testNameList = cmExpandedList(testNames, false);
|
||||||
std::set<std::string> testNameSet(testNameList.begin(), testNameList.end());
|
std::set<std::string> testNameSet(testNameList.begin(), testNameList.end());
|
||||||
|
|
||||||
cmCTestHardwareSpec spec;
|
cmCTestResourceSpec spec;
|
||||||
if (!spec.ReadFromJSONFile(hwFile)) {
|
if (!spec.ReadFromJSONFile(resFile)) {
|
||||||
std::cout << "Could not read resource spec " << hwFile << std::endl;
|
std::cout << "Could not read resource spec " << resFile << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCTestHardwareAllocator allocator;
|
cmCTestResourceAllocator allocator;
|
||||||
allocator.InitializeFromHardwareSpec(spec);
|
allocator.InitializeFromResourceSpec(spec);
|
||||||
|
|
||||||
cmsys::ifstream fin(logFile.c_str(), std::ios::in);
|
cmsys::ifstream fin(logFile.c_str(), std::ios::in);
|
||||||
if (!fin) {
|
if (!fin) {
|
||||||
|
Reference in New Issue
Block a user