fix: add missing nullptr check in adjustRootDeviceEnvironments method
Related-To: NEO-8166 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
a6a0b95344
commit
16dd1ebd9a
|
@ -14,7 +14,7 @@
|
|||
namespace NEO {
|
||||
|
||||
void ExecutionEnvironment::adjustRootDeviceEnvironments() {
|
||||
if (rootDeviceEnvironments[0]->osInterface->getDriverModel()->getDriverModelType() == DriverModelType::DRM) {
|
||||
if (!rootDeviceEnvironments.empty() && rootDeviceEnvironments[0]->osInterface->getDriverModel()->getDriverModelType() == DriverModelType::DRM) {
|
||||
for (auto rootDeviceIndex = 0u; rootDeviceIndex < rootDeviceEnvironments.size(); rootDeviceIndex++) {
|
||||
auto drmMemoryOperationsHandler = static_cast<DrmMemoryOperationsHandler *>(rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
drmMemoryOperationsHandler->setRootDeviceIndex(rootDeviceIndex);
|
||||
|
|
|
@ -81,6 +81,7 @@ TEST(SortAndFilterDevicesDrmTest, whenSortingAndFilteringDevicesThenMemoryOperat
|
|||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
DebugManager.flags.ZE_AFFINITY_MASK.set("1,2,3,4,5");
|
||||
|
||||
VariableBackup<uint32_t> osContextCountBackup(&MemoryManager::maxOsContextCount);
|
||||
VariableBackup<std::map<std::string, std::vector<std::string>>> directoryFilesMapBackup(&directoryFilesMap);
|
||||
VariableBackup<const char *> pciDevicesDirectoryBackup(&Os::pciDevicesDirectory);
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
|
@ -115,3 +116,17 @@ TEST(SortAndFilterDevicesDrmTest, whenSortingAndFilteringDevicesThenMemoryOperat
|
|||
EXPECT_EQ(rootDeviceIndex, static_cast<DrmMemoryOperationsHandlerBind &>(*executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface).getRootDeviceIndex());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DeviceFactoryAffinityMaskTest, whenAffinityMaskDoesNotSelectAnyDeviceThenEmptyEnvironmentIsReturned) {
|
||||
static const auto numRootDevices = 6;
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
DebugManager.flags.ZE_AFFINITY_MASK.set("100");
|
||||
|
||||
VariableBackup<uint32_t> osContextCountBackup(&MemoryManager::maxOsContextCount);
|
||||
ExecutionEnvironment executionEnvironment{};
|
||||
bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
|
||||
EXPECT_TRUE(success);
|
||||
|
||||
EXPECT_EQ(0u, executionEnvironment.rootDeviceEnvironments.size());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue