mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
feature(sysman): enables uuid from zesDeviceGetProperties with zesInit
Related-To: NEO-9047 Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e91ce78ec8
commit
bf92d7824e
@@ -5,6 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_product_helper.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "level_zero/sysman/source/api/global_operations/windows/sysman_os_global_operations_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/global_operations/windows/mock_global_operations.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_fixture.h"
|
||||
@@ -80,6 +83,123 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceInUseWhenCallingzesDeviceResetE
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
|
||||
}
|
||||
|
||||
class SysmanGlobalOperationsUuidFixture : public SysmanDeviceFixture {
|
||||
public:
|
||||
L0::Sysman::GlobalOperationsImp *pGlobalOperationsImp;
|
||||
L0::Sysman::SysmanDeviceImp *device = nullptr;
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pGlobalOperationsImp = static_cast<L0::Sysman::GlobalOperationsImp *>(pSysmanDeviceImp->pGlobalOperations);
|
||||
device = pSysmanDeviceImp;
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
void initGlobalOps() {
|
||||
zes_device_state_t deviceState;
|
||||
zesDeviceGetState(device, &deviceState);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanGlobalOperationsUuidFixture, GivenValidDeviceHandleWhenCallingGenerateUuidFromPciBusInfoThenValidUuidIsReturned) {
|
||||
initGlobalOps();
|
||||
|
||||
auto pHwInfo = pWddmSysmanImp->getSysmanDeviceImp()->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
pHwInfo->platform.usDeviceID = 0x1234;
|
||||
pHwInfo->platform.usRevId = 0x1;
|
||||
|
||||
std::array<uint8_t, NEO::ProductHelper::uuidSize> uuid;
|
||||
NEO::PhysicalDevicePciBusInfo pciBusInfo = {};
|
||||
pciBusInfo.pciDomain = 0x5678;
|
||||
pciBusInfo.pciBus = 0x9;
|
||||
pciBusInfo.pciDevice = 0xA;
|
||||
pciBusInfo.pciFunction = 0xB;
|
||||
|
||||
bool result = pGlobalOperationsImp->pOsGlobalOperations->generateUuidFromPciBusInfo(pciBusInfo, uuid);
|
||||
EXPECT_EQ(true, result);
|
||||
uint8_t *pUuid = (uint8_t *)uuid.data();
|
||||
EXPECT_EQ(*((uint16_t *)pUuid), (uint16_t)0x8086);
|
||||
EXPECT_EQ(*((uint16_t *)(pUuid + 2)), (uint16_t)pHwInfo->platform.usDeviceID);
|
||||
EXPECT_EQ(*((uint16_t *)(pUuid + 4)), (uint16_t)pHwInfo->platform.usRevId);
|
||||
EXPECT_EQ(*((uint16_t *)(pUuid + 6)), (uint16_t)pciBusInfo.pciDomain);
|
||||
EXPECT_EQ((*(pUuid + 8)), (uint8_t)pciBusInfo.pciBus);
|
||||
EXPECT_EQ((*(pUuid + 9)), (uint8_t)pciBusInfo.pciDevice);
|
||||
EXPECT_EQ((*(pUuid + 10)), (uint8_t)pciBusInfo.pciFunction);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsUuidFixture, GivenValidDeviceHandleWhenCallingGetUuidMultipleTimesThenSameUuidIsReturned) {
|
||||
initGlobalOps();
|
||||
|
||||
auto pHwInfo = pWddmSysmanImp->getSysmanDeviceImp()->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
pHwInfo->platform.usDeviceID = 0x1234;
|
||||
pHwInfo->platform.usRevId = 0x1;
|
||||
|
||||
std::array<uint8_t, NEO::ProductHelper::uuidSize> uuid = {};
|
||||
|
||||
bool result = pGlobalOperationsImp->pOsGlobalOperations->getUuid(uuid);
|
||||
EXPECT_EQ(true, result);
|
||||
|
||||
uint8_t *pUuid = (uint8_t *)uuid.data();
|
||||
EXPECT_EQ(*((uint16_t *)pUuid), (uint16_t)0x8086);
|
||||
EXPECT_EQ(*((uint16_t *)(pUuid + 2)), (uint16_t)pHwInfo->platform.usDeviceID);
|
||||
EXPECT_EQ(*((uint16_t *)(pUuid + 4)), (uint16_t)pHwInfo->platform.usRevId);
|
||||
|
||||
uuid = {};
|
||||
result = pGlobalOperationsImp->pOsGlobalOperations->getUuid(uuid);
|
||||
EXPECT_EQ(true, result);
|
||||
|
||||
pUuid = (uint8_t *)uuid.data();
|
||||
EXPECT_EQ(*((uint16_t *)pUuid), (uint16_t)0x8086);
|
||||
EXPECT_EQ(*((uint16_t *)(pUuid + 2)), (uint16_t)pHwInfo->platform.usDeviceID);
|
||||
EXPECT_EQ(*((uint16_t *)(pUuid + 4)), (uint16_t)pHwInfo->platform.usRevId);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsUuidFixture, GivenValidDeviceHandleWithInvalidPciDomainWhenCallingGenerateUuidFromPciBusInfoThenFalseIsReturned) {
|
||||
initGlobalOps();
|
||||
|
||||
std::array<uint8_t, NEO::ProductHelper::uuidSize> uuid;
|
||||
NEO::PhysicalDevicePciBusInfo pciBusInfo = {};
|
||||
pciBusInfo.pciDomain = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
bool result = pGlobalOperationsImp->pOsGlobalOperations->generateUuidFromPciBusInfo(pciBusInfo, uuid);
|
||||
EXPECT_EQ(false, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsUuidFixture, GivenNullOsInterfaceObjectWhenRetrievingUuidThenFalseIsReturned) {
|
||||
initGlobalOps();
|
||||
|
||||
auto &rootDeviceEnvironment = (pWddmSysmanImp->getSysmanDeviceImp()->getRootDeviceEnvironmentRef());
|
||||
auto prevOsInterface = std::move(rootDeviceEnvironment.osInterface);
|
||||
rootDeviceEnvironment.osInterface = nullptr;
|
||||
|
||||
std::array<uint8_t, NEO::ProductHelper::uuidSize> uuid;
|
||||
bool result = pGlobalOperationsImp->pOsGlobalOperations->getUuid(uuid);
|
||||
EXPECT_EQ(false, result);
|
||||
rootDeviceEnvironment.osInterface = std::move(prevOsInterface);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsUuidFixture, GivenInvalidPciBusInfoWhenRetrievingUuidThenFalseIsReturned) {
|
||||
class SysmanMockWddm : public NEO::WddmMock {
|
||||
public:
|
||||
SysmanMockWddm(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {}
|
||||
PhysicalDevicePciBusInfo getPciBusInfo() const override {
|
||||
PhysicalDevicePciBusInfo pciBusInfo = {};
|
||||
pciBusInfo.pciDomain = std::numeric_limits<uint32_t>::max();
|
||||
return pciBusInfo;
|
||||
}
|
||||
};
|
||||
initGlobalOps();
|
||||
|
||||
auto &rootDeviceEnvironment = (pWddmSysmanImp->getSysmanDeviceImp()->getRootDeviceEnvironmentRef());
|
||||
|
||||
rootDeviceEnvironment.osInterface->setDriverModel(std::unique_ptr<DriverModel>(new SysmanMockWddm(rootDeviceEnvironment)));
|
||||
std::array<uint8_t, NEO::ProductHelper::uuidSize> uuid;
|
||||
bool result = pGlobalOperationsImp->pOsGlobalOperations->getUuid(uuid);
|
||||
EXPECT_EQ(false, result);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user