mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 16:48:45 +08:00
fix: Handle multiple device interface paths for windows PMT init
Related-To: NEO-15620 Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
aeb46dc785
commit
4011006a3a
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
* Copyright (C) 2024-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -163,7 +163,7 @@ ze_result_t PlatformMonitoringTech::init() {
|
||||
}
|
||||
|
||||
std::unique_ptr<PlatformMonitoringTech> PlatformMonitoringTech::create(SysmanProductHelper *pSysmanProductHelper) {
|
||||
std::vector<wchar_t> deviceInterface;
|
||||
std::wstring deviceInterface;
|
||||
if (enumeratePMTInterface(&PmtSysman::GuidIntefacePmtTelemetry, deviceInterface) == ZE_RESULT_SUCCESS) {
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt;
|
||||
pPmt = std::make_unique<PlatformMonitoringTech>(deviceInterface, pSysmanProductHelper);
|
||||
@@ -179,10 +179,11 @@ std::unique_ptr<PlatformMonitoringTech> PlatformMonitoringTech::create(SysmanPro
|
||||
PlatformMonitoringTech::~PlatformMonitoringTech() {
|
||||
}
|
||||
|
||||
ze_result_t PlatformMonitoringTech::enumeratePMTInterface(const GUID *guid, std::vector<wchar_t> &deviceInterface) {
|
||||
ze_result_t PlatformMonitoringTech::enumeratePMTInterface(const GUID *guid, std::wstring &deviceInterface) {
|
||||
|
||||
unsigned long cmListCharCount = 0;
|
||||
CONFIGRET status = CR_SUCCESS;
|
||||
std::vector<wchar_t> deviceInterfaceList;
|
||||
|
||||
do {
|
||||
// Get the total size of list of all instances
|
||||
@@ -193,21 +194,20 @@ ze_result_t PlatformMonitoringTech::enumeratePMTInterface(const GUID *guid, std:
|
||||
break;
|
||||
}
|
||||
// Free previous allocation if present.
|
||||
if (!deviceInterface.empty()) {
|
||||
deviceInterface.clear();
|
||||
if (!deviceInterfaceList.empty()) {
|
||||
deviceInterfaceList.clear();
|
||||
}
|
||||
// Allocate buffer
|
||||
deviceInterface.resize(cmListCharCount);
|
||||
deviceInterfaceList.resize(cmListCharCount);
|
||||
|
||||
if (deviceInterface.empty()) {
|
||||
if (deviceInterfaceList.empty()) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr,
|
||||
"Could not allocate memory to store the PMT device interface path.\n");
|
||||
DEBUG_BREAK_IF(true);
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
// N.B. cmListCharCount is length in characters
|
||||
status = NEO::SysCalls::cmGetDeviceInterfaceList((LPGUID)guid, NULL, &deviceInterface[0], cmListCharCount, CM_GET_DEVICE_INTERFACE_LIST_PRESENT);
|
||||
|
||||
status = NEO::SysCalls::cmGetDeviceInterfaceList((LPGUID)guid, NULL, deviceInterfaceList.data(), cmListCharCount, CM_GET_DEVICE_INTERFACE_LIST_PRESENT);
|
||||
} while (status == CR_BUFFER_SMALL);
|
||||
|
||||
if (status != CR_SUCCESS) {
|
||||
@@ -217,10 +217,23 @@ ze_result_t PlatformMonitoringTech::enumeratePMTInterface(const GUID *guid, std:
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
wchar_t *pDeviceInterface = deviceInterfaceList.data();
|
||||
|
||||
while (*pDeviceInterface) {
|
||||
std::wstring deviceInterfaceName(pDeviceInterface);
|
||||
std::wstring::size_type found = deviceInterfaceName.find(L"INTC_PMT");
|
||||
size_t interfaceCharCount = wcslen(pDeviceInterface);
|
||||
if (found != std::wstring::npos) {
|
||||
deviceInterface = std::move(deviceInterfaceName);
|
||||
break;
|
||||
}
|
||||
pDeviceInterface += interfaceCharCount + 1;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t PlatformMonitoringTech::ioctlReadWriteData(std::vector<wchar_t> &path, uint32_t ioctl, void *bufferIn, uint32_t inSize, void *bufferOut, uint32_t outSize, uint32_t *sizeReturned) {
|
||||
ze_result_t PlatformMonitoringTech::ioctlReadWriteData(std::wstring &path, uint32_t ioctl, void *bufferIn, uint32_t inSize, void *bufferOut, uint32_t outSize, uint32_t *sizeReturned) {
|
||||
void *handle;
|
||||
BOOL status = FALSE;
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@ class SysmanProductHelper;
|
||||
class PlatformMonitoringTech : NEO::NonCopyableAndNonMovableClass {
|
||||
public:
|
||||
PlatformMonitoringTech() = delete;
|
||||
PlatformMonitoringTech(std::vector<wchar_t> deviceInterface, SysmanProductHelper *pSysmanProductHelper) : deviceInterface(std::move(deviceInterface)), pSysmanProductHelper(pSysmanProductHelper) {}
|
||||
PlatformMonitoringTech(std::wstring deviceInterface, SysmanProductHelper *pSysmanProductHelper) : deviceInterface(std::move(deviceInterface)), pSysmanProductHelper(pSysmanProductHelper) {}
|
||||
virtual ~PlatformMonitoringTech();
|
||||
|
||||
virtual ze_result_t readValue(const std::string &key, uint32_t &value);
|
||||
virtual ze_result_t readValue(const std::string &key, uint64_t &value);
|
||||
ze_result_t getKeyOffsetMap(std::map<std::string, std::pair<uint32_t, uint32_t>> &keyOffsetMap);
|
||||
static std::unique_ptr<PlatformMonitoringTech> create(SysmanProductHelper *pSysmanProductHelper);
|
||||
static ze_result_t enumeratePMTInterface(const GUID *Guid, std::vector<wchar_t> &deviceInterface);
|
||||
static ze_result_t enumeratePMTInterface(const GUID *Guid, std::wstring &deviceInterface);
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::pair<uint32_t, uint32_t>> keyOffsetMap;
|
||||
unsigned long guidToIndexList[PmtSysman::PmtMaxInterfaces] = {0};
|
||||
ze_result_t ioctlReadWriteData(std::vector<wchar_t> &path, uint32_t ioctl, void *bufferIn, uint32_t inSize, void *bufferOut, uint32_t outSize, uint32_t *sizeReturned);
|
||||
ze_result_t ioctlReadWriteData(std::wstring &path, uint32_t ioctl, void *bufferIn, uint32_t inSize, void *bufferOut, uint32_t outSize, uint32_t *sizeReturned);
|
||||
virtual ze_result_t init();
|
||||
ze_result_t getGuid();
|
||||
decltype(&NEO::SysCalls::deviceIoControl) pdeviceIoControl = NEO::SysCalls::deviceIoControl;
|
||||
@@ -48,7 +48,7 @@ class PlatformMonitoringTech : NEO::NonCopyableAndNonMovableClass {
|
||||
decltype(&NEO::SysCalls::heapFree) heapFreeFunction = NEO::SysCalls::heapFree;
|
||||
|
||||
private:
|
||||
std::vector<wchar_t> deviceInterface;
|
||||
std::wstring deviceInterface;
|
||||
SysmanProductHelper *pSysmanProductHelper = nullptr;
|
||||
uint32_t baseOffset = 0;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,6 @@ ze_result_t WddmSysmanImp::init() {
|
||||
}
|
||||
|
||||
pPmt = PlatformMonitoringTech::create(pSysmanProductHelper.get());
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ class PublicWddmPowerImp : public L0::Sysman::WddmMemoryImp {
|
||||
|
||||
class PublicPlatformMonitoringTech : public L0::Sysman::PlatformMonitoringTech {
|
||||
public:
|
||||
PublicPlatformMonitoringTech(std::vector<wchar_t> deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
PublicPlatformMonitoringTech(std::wstring deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
* Copyright (C) 2023-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -127,7 +127,7 @@ struct PciKmdSysManager : public MockKmdSysManager {
|
||||
|
||||
class PublicPlatformMonitoringTech : public L0::Sysman::PlatformMonitoringTech {
|
||||
public:
|
||||
PublicPlatformMonitoringTech(std::vector<wchar_t> deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
PublicPlatformMonitoringTech(std::wstring deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ const std::map<std::string, std::pair<uint32_t, uint32_t>> dummyKeyOffsetMap = {
|
||||
{"GDDR_TELEM_CAPTURE_TIMESTAMP_UPPER", {92, 1}},
|
||||
{"GDDR_TELEM_CAPTURE_TIMESTAMP_LOWER", {93, 1}}}};
|
||||
|
||||
const std::wstring pmtInterfaceName = L"TEST\0";
|
||||
std::vector<wchar_t> deviceInterfacePci(pmtInterfaceName.begin(), pmtInterfaceName.end());
|
||||
const std::wstring deviceInterfacePci = L"TEST\0";
|
||||
|
||||
class SysmanDevicePciFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -228,7 +228,7 @@ struct PowerKmdSysManager : public MockKmdSysManager {
|
||||
|
||||
class PublicPlatformMonitoringTech : public L0::Sysman::PlatformMonitoringTech {
|
||||
public:
|
||||
PublicPlatformMonitoringTech(std::vector<wchar_t> deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
PublicPlatformMonitoringTech(std::wstring deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -63,8 +63,7 @@ const std::map<std::string, std::pair<uint32_t, uint32_t>> dummyKeyOffsetMap = {
|
||||
{"GDDR0_CH1_GT_64B_WR_REQ_UPPER", {120, 1}},
|
||||
{"GDDR0_CH1_GT_64B_WR_REQ_LOWER", {121, 1}}}};
|
||||
|
||||
const std::wstring pmtInterfaceName = L"TEST\0";
|
||||
std::vector<wchar_t> deviceInterfaceMemory(pmtInterfaceName.begin(), pmtInterfaceName.end());
|
||||
const std::wstring deviceInterfaceMemory = L"TEST\0";
|
||||
class SysmanDeviceMemoryHelperFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<MockMemoryKmdSysManager> pKmdSysManager;
|
||||
|
||||
@@ -18,8 +18,7 @@ namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
|
||||
const std::wstring pmtInterfaceName = L"TEST\0";
|
||||
std::vector<wchar_t> pmtInterfacePower(pmtInterfaceName.begin(), pmtInterfaceName.end());
|
||||
const std::wstring pmtInterfacePower = L"TEST\0";
|
||||
|
||||
const std::map<std::string, std::pair<uint32_t, uint32_t>> dummyKeyOffsetMap = {
|
||||
{{"XTAL_CLK_FREQUENCY", {1, 0}},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
* Copyright (C) 2024-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -17,7 +17,7 @@ namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
|
||||
std::vector<wchar_t> pmtInterface(pmtInterfaceName.begin(), pmtInterfaceName.end());
|
||||
std::wstring pmtInterface = std::move(pmtInterfaceName);
|
||||
const std::map<std::string, std::pair<uint32_t, uint32_t>> dummyKeyOffsetMap = {
|
||||
{{"SOC_THERMAL_SENSORS_TEMPERATURE_0_2_0_GTTMMADR[1]", {41, 1}},
|
||||
{"VRAM_TEMPERATURE_0_2_0_GTTMMADR", {42, 1}}}};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -101,7 +101,7 @@ struct TemperatureKmdSysManager : public MockKmdSysManager {
|
||||
|
||||
class PublicPlatformMonitoringTech : public L0::Sysman::PlatformMonitoringTech {
|
||||
public:
|
||||
PublicPlatformMonitoringTech(std::vector<wchar_t> deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
PublicPlatformMonitoringTech(std::wstring deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -20,7 +20,7 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture {
|
||||
L0::Sysman::KmdSysManager *pOriginalKmdSysManager = nullptr;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
void SetUp() override {
|
||||
std::vector<wchar_t> deviceInterfacePmt(pmtInterfaceName.begin(), pmtInterfaceName.end());
|
||||
std::wstring deviceInterfacePmt = std::move(pmtInterfaceName);
|
||||
SysmanDeviceFixture::SetUp();
|
||||
|
||||
pKmdSysManager.reset(new TemperatureKmdSysManager);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
* Copyright (C) 2024-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -17,7 +17,7 @@ namespace ult {
|
||||
|
||||
class PublicPlatformMonitoringTech : public L0::Sysman::PlatformMonitoringTech {
|
||||
public:
|
||||
PublicPlatformMonitoringTech(std::vector<wchar_t> deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
PublicPlatformMonitoringTech(std::wstring deviceInterfaceList, SysmanProductHelper *pSysmanProductHelper) : PlatformMonitoringTech(deviceInterfaceList, pSysmanProductHelper) {}
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
using PlatformMonitoringTech::pcreateFile;
|
||||
using PlatformMonitoringTech::pdeviceIoControl;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
* Copyright (C) 2024-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -16,8 +16,7 @@ namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
|
||||
const std::wstring interfaceName = L"TEST\0";
|
||||
std::vector<wchar_t> deviceInterface(interfaceName.begin(), interfaceName.end());
|
||||
const std::wstring deviceInterface = L"TEST_INTC_PMT\0";
|
||||
|
||||
const std::map<std::string, std::pair<uint32_t, uint32_t>> dummyKeyOffsetMap = {
|
||||
{"DUMMY_KEY", {0x0, 1}}};
|
||||
@@ -37,7 +36,7 @@ class SysmanDevicePmtFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<PublicPlatformMonitoringTech> pPmt;
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
std::vector<wchar_t> deviceInterface;
|
||||
std::wstring deviceInterface;
|
||||
pPmt = std::make_unique<PublicPlatformMonitoringTech>(deviceInterface, pWddmSysmanImp->getSysmanProductHelper());
|
||||
}
|
||||
|
||||
@@ -165,10 +164,11 @@ TEST_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWithUnsupportedGuidWhenCall
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
struct MockSysmanProductHelperPmt : L0::Sysman::SysmanProductHelperHw<IGFX_UNKNOWN> {
|
||||
@@ -195,16 +195,42 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateThenCal
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt = PublicPlatformMonitoringTech::create(pWddmSysmanImp->getSysmanProductHelper());
|
||||
EXPECT_NE(nullptr, pPmt);
|
||||
}
|
||||
|
||||
HWTEST2_F(SysmanDevicePmtFixture, GivenInValidPmtInterfaceNameWhenCallingCreateThenCallFails, IsBMG) {
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCreateFile)> psysCallsCreateFile(&NEO::SysCalls::sysCallsCreateFile, [](LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) -> HANDLE {
|
||||
return reinterpret_cast<HANDLE>(static_cast<uintptr_t>(0x7));
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsDeviceIoControl)> psysCallsDeviceIoControl(&NEO::SysCalls::sysCallsDeviceIoControl, [](HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) -> BOOL {
|
||||
if (static_cast<uint32_t>(dwIoControlCode) == PmtSysman::IoctlPmtGetTelemetryDiscoverySize) {
|
||||
*static_cast<unsigned long *>(lpOutBuffer) = 40;
|
||||
} else if (static_cast<uint32_t>(dwIoControlCode) == PmtSysman::IoctlPmtGetTelemetryDiscovery) {
|
||||
PmtSysman::PmtTelemetryDiscovery temp = {1, 2, {{1, 1, 0x5e2f8210, 10}}};
|
||||
*static_cast<PmtSysman::PmtTelemetryDiscovery *>(lpOutBuffer) = temp;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_WRONG_INTERFACE");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt = PublicPlatformMonitoringTech::create(pWddmSysmanImp->getSysmanProductHelper());
|
||||
EXPECT_EQ(nullptr, pPmt);
|
||||
}
|
||||
|
||||
HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateWithNoGuidsFoundThenCallFails, IsBMG) {
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCreateFile)> psysCallsCreateFile(&NEO::SysCalls::sysCallsCreateFile, [](LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) -> HANDLE {
|
||||
return reinterpret_cast<HANDLE>(static_cast<uintptr_t>(0x7));
|
||||
@@ -216,10 +242,11 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateWithNoG
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt = PublicPlatformMonitoringTech::create(pWddmSysmanImp->getSysmanProductHelper());
|
||||
@@ -237,10 +264,11 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateAndTele
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt = PublicPlatformMonitoringTech::create(pWddmSysmanImp->getSysmanProductHelper());
|
||||
@@ -260,10 +288,11 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateAndTele
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt = PublicPlatformMonitoringTech::create(pWddmSysmanImp->getSysmanProductHelper());
|
||||
@@ -275,10 +304,11 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateAndTele
|
||||
return reinterpret_cast<HANDLE>(static_cast<uintptr_t>(0x7));
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt = PublicPlatformMonitoringTech::create(pWddmSysmanImp->getSysmanProductHelper());
|
||||
@@ -299,12 +329,13 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateThenCal
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> psysCallsInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> psysCallsInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
static int sysCallsInterfaceListCounter = 0;
|
||||
if (sysCallsInterfaceListCounter) {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
sysCallsInterfaceListCounter++;
|
||||
@@ -351,10 +382,11 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateAndHeap
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> mockCmGetDeviceInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> mockCmGetDeviceInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsHeapAlloc)> mockHeapAlloc(&NEO::SysCalls::sysCallsHeapAlloc, [](HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) -> LPVOID {
|
||||
@@ -380,10 +412,11 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateAndTele
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> mockCmGetDeviceInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> mockCmGetDeviceInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
std::unique_ptr<PlatformMonitoringTech> pPmt = PublicPlatformMonitoringTech::create(pWddmSysmanImp->getSysmanProductHelper());
|
||||
@@ -404,10 +437,11 @@ HWTEST2_F(SysmanDevicePmtFixture, GivenValidPmtInterfaceWhenCallingCreateAndHeap
|
||||
return true;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize)> mockCmGetDeviceInterfaceListSize(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceListSize, [](PULONG pulLen, LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, ULONG ulFlags) -> CONFIGRET {
|
||||
*pulLen = 4;
|
||||
*pulLen = 40;
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsCmGetDeviceInterfaceList)> mockCmGetDeviceInterfaceList(&NEO::SysCalls::sysCallsCmGetDeviceInterfaceList, [](LPGUID interfaceClassGuid, DEVINSTID_W pDeviceID, PZZWSTR buffer, ULONG bufferLen, ULONG ulFlags) -> CONFIGRET {
|
||||
wcscpy(buffer, L"TEST_INTC_PMT");
|
||||
return CR_SUCCESS;
|
||||
});
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsHeapFree)> mocksHeapFree(&NEO::SysCalls::sysCallsHeapFree, [](HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) -> BOOL {
|
||||
|
||||
Reference in New Issue
Block a user