|
1 | 1 | /* |
2 | | - * Copyright (C) 2020-2021 Intel Corporation |
| 2 | + * Copyright (C) 2020-2022 Intel Corporation |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: MIT |
5 | 5 | * |
|
15 | 15 | #include "shared/test/common/helpers/debug_manager_state_restore.h" |
16 | 16 | #include "shared/test/common/mocks/mock_compilers.h" |
17 | 17 | #include "shared/test/common/mocks/mock_device.h" |
| 18 | +#include "shared/test/common/mocks/mock_driver_info.h" |
18 | 19 | #include "shared/test/common/mocks/mock_memory_manager.h" |
19 | 20 | #include "shared/test/common/mocks/mock_sip.h" |
20 | 21 | #include "shared/test/common/mocks/ult_device_factory.h" |
@@ -947,6 +948,54 @@ TEST_F(DeviceTest, givenCallToDevicePropertiesThenTimestampValidBitsAreCorrectly |
947 | 948 | EXPECT_EQ(32u, deviceProps.kernelTimestampValidBits); |
948 | 949 | } |
949 | 950 |
|
| 951 | +TEST_F(DeviceTest, givenNullDriverInfowhenPciPropertiesIsCalledThenUninitializedErrorIsReturned) { |
| 952 | + auto deviceImp = static_cast<L0::DeviceImp *>(device); |
| 953 | + ze_pci_ext_properties_t pciProperties = {}; |
| 954 | + |
| 955 | + deviceImp->driverInfo.reset(nullptr); |
| 956 | + ze_result_t res = device->getPciProperties(&pciProperties); |
| 957 | + |
| 958 | + EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res); |
| 959 | +} |
| 960 | + |
| 961 | +TEST_F(DeviceTest, givenValidPciExtPropertiesWhenPciPropertiesIsCalledThenSuccessIsReturned) { |
| 962 | + |
| 963 | + auto deviceImp = static_cast<L0::DeviceImp *>(device); |
| 964 | + const NEO::PhysicalDevicePciBusInfo pciBusInfo(0, 1, 2, 3); |
| 965 | + NEO::DriverInfoMock *driverInfo = new DriverInfoMock(); |
| 966 | + ze_pci_ext_properties_t pciProperties = {}; |
| 967 | + |
| 968 | + driverInfo->setPciBusInfo(pciBusInfo); |
| 969 | + deviceImp->driverInfo.reset(driverInfo); |
| 970 | + ze_result_t res = device->getPciProperties(&pciProperties); |
| 971 | + |
| 972 | + EXPECT_EQ(ZE_RESULT_SUCCESS, res); |
| 973 | + EXPECT_EQ(pciBusInfo.pciDomain, pciProperties.address.domain); |
| 974 | + EXPECT_EQ(pciBusInfo.pciBus, pciProperties.address.bus); |
| 975 | + EXPECT_EQ(pciBusInfo.pciDevice, pciProperties.address.device); |
| 976 | + EXPECT_EQ(pciBusInfo.pciFunction, pciProperties.address.function); |
| 977 | +} |
| 978 | + |
| 979 | +TEST_F(DeviceTest, givenInvalidPciBusInfoWhenPciPropertiesIsCalledThenUninitializedErrorIsReturned) { |
| 980 | + constexpr uint32_t INVALID = NEO::PhysicalDevicePciBusInfo::InvalidValue; |
| 981 | + auto deviceImp = static_cast<L0::DeviceImp *>(device); |
| 982 | + ze_pci_ext_properties_t pciProperties = {}; |
| 983 | + std::vector<NEO::PhysicalDevicePciBusInfo> pciBusInfos; |
| 984 | + |
| 985 | + pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(0, 1, 2, INVALID)); |
| 986 | + pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(0, 1, INVALID, 3)); |
| 987 | + pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(0, INVALID, 2, 3)); |
| 988 | + pciBusInfos.push_back(NEO::PhysicalDevicePciBusInfo(INVALID, 1, 2, 3)); |
| 989 | + |
| 990 | + for (auto pciBusInfo : pciBusInfos) { |
| 991 | + NEO::DriverInfoMock *driverInfo = new DriverInfoMock(); |
| 992 | + driverInfo->setPciBusInfo(pciBusInfo); |
| 993 | + deviceImp->driverInfo.reset(driverInfo); |
| 994 | + |
| 995 | + ze_result_t res = device->getPciProperties(&pciProperties); |
| 996 | + EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res); |
| 997 | + } |
| 998 | +} |
950 | 999 | TEST_F(DeviceTest, whenGetExternalMemoryPropertiesIsCalledThenSuccessIsReturnedAndNoPropertiesAreReturned) { |
951 | 1000 | ze_device_external_memory_properties_t externalMemoryProperties; |
952 | 1001 |
|
|
0 commit comments