diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index 3225b2e22d..144c0da802 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -285,6 +285,55 @@ TEST_F(DeviceTest, givenCallToDevicePropertiesThenMaximumMemoryToBeAllocatedIsCo EXPECT_EQ(deviceProperties.maxMemAllocSize, this->neoDevice->getDeviceInfo().maxMemAllocSize); } +struct DeviceHwInfoTest : public ::testing::Test { + void SetUp() override { + executionEnvironment = new NEO::ExecutionEnvironment(); + executionEnvironment->prepareRootDeviceEnvironments(1U); + } + + void TearDown() override { + } + + void setDriverAndDevice() { + std::vector> devices; + neoDevice = NEO::MockDevice::create(executionEnvironment, 0); + EXPECT_NE(neoDevice, nullptr); + + devices.push_back(std::unique_ptr(neoDevice)); + driverHandle = std::make_unique>(); + ze_result_t res = driverHandle->initialize(std::move(devices)); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + device = driverHandle->devices[0]; + } + + NEO::ExecutionEnvironment *executionEnvironment = nullptr; + std::unique_ptr> driverHandle; + NEO::MockDevice *neoDevice = nullptr; + L0::Device *device = nullptr; +}; + +TEST_F(DeviceHwInfoTest, givenDeviceWithNoPageFaultSupportThenFlagIsNotSet) { + NEO::HardwareInfo hardwareInfo = *NEO::defaultHwInfo; + hardwareInfo.capabilityTable.supportsOnDemandPageFaults = false; + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hardwareInfo); + setDriverAndDevice(); + + ze_device_properties_t deviceProps; + device->getProperties(&deviceProps); + EXPECT_FALSE(deviceProps.flags & ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING); +} + +TEST_F(DeviceHwInfoTest, givenDeviceWithPageFaultSupportThenFlagIsSet) { + NEO::HardwareInfo hardwareInfo = *NEO::defaultHwInfo; + hardwareInfo.capabilityTable.supportsOnDemandPageFaults = true; + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hardwareInfo); + setDriverAndDevice(); + + ze_device_properties_t deviceProps; + device->getProperties(&deviceProps); + EXPECT_TRUE(deviceProps.flags & ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING); +} + TEST_F(DeviceTest, whenGetDevicePropertiesCalledThenCorrectDevicePropertyEccFlagSet) { ze_device_properties_t deviceProps;