mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Removal of Template Specializations and NiceMocks
Template Specializations and NiceMocks have been removed in Linux Common Code, ECC, Firmware, Frequency, Global Operations, Power, PCI, RAS and Standby ULTs. Related-To: LOCI-3391 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
2e1d20883b
commit
21a0a4af52
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -13,9 +13,7 @@
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class EccFwInterface : public FirmwareUtil {};
|
||||
template <>
|
||||
struct Mock<EccFwInterface> : public EccFwInterface {
|
||||
struct MockEccFwInterface : public FirmwareUtil {
|
||||
ze_result_t mockFwGetEccConfigResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockFwSetEccConfigResult = ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -58,8 +56,8 @@ struct Mock<EccFwInterface> : public EccFwInterface {
|
||||
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));
|
||||
|
||||
Mock<EccFwInterface>() = default;
|
||||
~Mock<EccFwInterface>() override = default;
|
||||
MockEccFwInterface() = default;
|
||||
~MockEccFwInterface() override = default;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,9 +8,6 @@
|
||||
#include "level_zero/tools/test/unit_tests/sources/sysman/ecc/linux/mock_ecc.h"
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::Matcher;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -19,7 +16,7 @@ static const uint8_t eccStateEnable = 0x1;
|
||||
|
||||
class ZesEccFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<EccFwInterface>> pMockFwInterface;
|
||||
std::unique_ptr<MockEccFwInterface> pMockFwInterface;
|
||||
FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
L0::EccImp *pEccImp;
|
||||
|
||||
@@ -29,7 +26,7 @@ class ZesEccFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pFwUtilInterfaceOld = pLinuxSysmanImp->pFwUtilInterface;
|
||||
pMockFwInterface = std::make_unique<NiceMock<Mock<EccFwInterface>>>();
|
||||
pMockFwInterface = std::make_unique<MockEccFwInterface>();
|
||||
pLinuxSysmanImp->pFwUtilInterface = pMockFwInterface.get();
|
||||
|
||||
pEccImp = static_cast<L0::EccImp *>(pSysmanDeviceImp->pEcc);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,14 +15,12 @@
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using ::testing::_;
|
||||
using namespace NEO;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class FwUtilInterface : public FirmwareUtil {};
|
||||
struct MockFwUtilInterface : public FwUtilInterface {
|
||||
struct MockFwUtilInterface : public FirmwareUtil {
|
||||
|
||||
MockFwUtilInterface() = default;
|
||||
|
||||
@@ -39,8 +37,7 @@ struct MockFwUtilInterface : public FwUtilInterface {
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));
|
||||
};
|
||||
|
||||
class OsLibraryUtil : public OsLibrary {};
|
||||
struct MockFwUtilOsLibrary : public OsLibraryUtil {
|
||||
struct MockFwUtilOsLibrary : public OsLibrary {
|
||||
public:
|
||||
static bool mockLoad;
|
||||
static bool getNonNullProcAddr;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -183,7 +183,7 @@ TEST(FwEccTest, GivenFwEccConfigCallFailsWhenCallingFirmwareUtilSetAndGetEccThen
|
||||
if (!sysmanUltsEnable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
struct IgscEccMockOsLibrary : public OsLibraryUtil {
|
||||
struct IgscEccMockOsLibrary : public OsLibrary {
|
||||
public:
|
||||
~IgscEccMockOsLibrary() override = default;
|
||||
void *getProcAddress(const std::string &procName) override {
|
||||
@@ -225,7 +225,7 @@ TEST(LinuxFwEccTest, GivenValidFwUtilMethodWhenCallingFirmwareUtilSetAndGetEccTh
|
||||
if (!sysmanUltsEnable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
struct IgscEccMockOsLibrary : public OsLibraryUtil {
|
||||
struct IgscEccMockOsLibrary : public OsLibrary {
|
||||
public:
|
||||
~IgscEccMockOsLibrary() override = default;
|
||||
void *getProcAddress(const std::string &procName) override {
|
||||
@@ -314,7 +314,7 @@ TEST(FwGetMemErrorCountTest, GivenValidFwUtilMethodWhenMemoryErrorCountIsRequest
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
struct IgscMemErrMockOsLibrary : public OsLibraryUtil {
|
||||
struct IgscMemErrMockOsLibrary : public OsLibrary {
|
||||
public:
|
||||
~IgscMemErrMockOsLibrary() override = default;
|
||||
void *getProcAddress(const std::string &procName) override {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -43,10 +43,7 @@ const std::string throttleReasonPL2FileLegacy("gt_throttle_reason_status_pl2");
|
||||
const std::string throttleReasonPL4FileLegacy("gt_throttle_reason_status_pl4");
|
||||
const std::string throttleReasonThermalFileLegacy("gt_throttle_reason_status_thermal");
|
||||
|
||||
class FrequencySysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<FrequencySysfsAccess> : public FrequencySysfsAccess {
|
||||
struct MockFrequencySysfsAccess : public SysfsAccess {
|
||||
double mockMin = 0;
|
||||
double mockMax = 0;
|
||||
double mockBoost = 0;
|
||||
@@ -323,8 +320,8 @@ struct Mock<FrequencySysfsAccess> : public FrequencySysfsAccess {
|
||||
return setVal(file, val);
|
||||
}
|
||||
|
||||
Mock() = default;
|
||||
~Mock() override = default;
|
||||
MockFrequencySysfsAccess() = default;
|
||||
~MockFrequencySysfsAccess() override = default;
|
||||
};
|
||||
|
||||
class PublicLinuxFrequencyImp : public L0::LinuxFrequencyImp {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -43,10 +43,7 @@ const std::string throttleReasonPL2FileLegacy("gt_throttle_reason_status_pl2");
|
||||
const std::string throttleReasonPL4FileLegacy("gt_throttle_reason_status_pl4");
|
||||
const std::string throttleReasonThermalFileLegacy("gt_throttle_reason_status_thermal");
|
||||
|
||||
class FrequencySysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<FrequencySysfsAccess> : public FrequencySysfsAccess {
|
||||
struct MockFrequencySysfsAccess : public SysfsAccess {
|
||||
double mockMin = 0;
|
||||
double mockMax = 0;
|
||||
double mockBoost = 0;
|
||||
@@ -338,8 +335,8 @@ struct Mock<FrequencySysfsAccess> : public FrequencySysfsAccess {
|
||||
return setVal(file, val);
|
||||
}
|
||||
|
||||
Mock() = default;
|
||||
~Mock() override = default;
|
||||
MockFrequencySysfsAccess() = default;
|
||||
~MockFrequencySysfsAccess() override = default;
|
||||
};
|
||||
|
||||
class PublicLinuxFrequencyImp : public L0::LinuxFrequencyImp {
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::DoDefault;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -36,7 +31,7 @@ constexpr uint32_t numClocks = static_cast<uint32_t>((maxFreq - minFreq) / step)
|
||||
constexpr uint32_t handleComponentCount = 1u;
|
||||
class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<FrequencySysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
|
||||
@@ -46,7 +41,7 @@ class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<FrequencySysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockFrequencySysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
|
||||
pSysfsAccess->setVal(minFreqFile, minFreq);
|
||||
@@ -872,7 +867,7 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingFrequencyProp
|
||||
class FreqMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
DebugManagerStateRestore restorer;
|
||||
std::unique_ptr<Mock<FrequencySysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
|
||||
@@ -883,7 +878,7 @@ class FreqMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
NEO::DebugManager.flags.ZE_AFFINITY_MASK.set("0.1");
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<FrequencySysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockFrequencySysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
// delete handles created in initial SysmanDeviceHandleContext::init() call
|
||||
for (auto handle : pSysmanDeviceImp->pFrequencyHandleContext->handleList) {
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::DoDefault;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -37,7 +32,7 @@ class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
||||
|
||||
protected:
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
std::unique_ptr<Mock<FrequencySysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
uint32_t numClocks = 0;
|
||||
double step = 0;
|
||||
@@ -55,7 +50,7 @@ class SysmanDeviceFrequencyFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
numClocks = static_cast<uint32_t>((maxFreq - minFreq) / step) + 1;
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<FrequencySysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockFrequencySysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
|
||||
pSysfsAccess->setVal(minFreqFile, minFreq);
|
||||
@@ -813,7 +808,7 @@ TEST_F(SysmanMultiDeviceFixture, GivenValidDevicePointerWhenGettingFrequencyProp
|
||||
class FreqMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
DebugManagerStateRestore restorer;
|
||||
std::unique_ptr<Mock<FrequencySysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockFrequencySysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
|
||||
@@ -824,7 +819,7 @@ class FreqMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
NEO::DebugManager.flags.ZE_AFFINITY_MASK.set("0.1");
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<FrequencySysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockFrequencySysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
// delete handles created in initial SysmanDeviceHandleContext::init() call
|
||||
for (auto handle : pSysmanDeviceImp->pFrequencyHandleContext->handleList) {
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::Matcher;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::Matcher;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -14,18 +14,13 @@
|
||||
|
||||
#include "sysman/linux/os_sysman_imp.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::NiceMock;
|
||||
using namespace NEO;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
const std::string mockedDeviceName("/MOCK_DEVICE_NAME");
|
||||
|
||||
class LinuxProcfsAccess : public ProcfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<LinuxProcfsAccess> : public LinuxProcfsAccess {
|
||||
struct MockLinuxProcfsAccess : public ProcfsAccess {
|
||||
::pid_t ourDevicePid = 0;
|
||||
int ourDeviceFd = 0;
|
||||
ze_result_t getFileName(const ::pid_t pid, const int fd, std::string &val) override {
|
||||
@@ -38,7 +33,7 @@ struct Mock<LinuxProcfsAccess> : public LinuxProcfsAccess {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
Mock<LinuxProcfsAccess>() = default;
|
||||
MockLinuxProcfsAccess() = default;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,23 +12,19 @@
|
||||
|
||||
#include "sysman/linux/os_sysman_imp.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::NiceMock;
|
||||
using namespace NEO;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class LinuxSysfsAccess : public SysfsAccess {};
|
||||
template <>
|
||||
struct Mock<LinuxSysfsAccess> : public LinuxSysfsAccess {
|
||||
struct MockLinuxSysfsAccess : public SysfsAccess {
|
||||
|
||||
ze_result_t getRealPath(const std::string file, std::string &val) override {
|
||||
val = "/random/path";
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
Mock<LinuxSysfsAccess>() = default;
|
||||
MockLinuxSysfsAccess() = default;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::NiceMock;
|
||||
using namespace NEO;
|
||||
|
||||
namespace L0 {
|
||||
@@ -51,8 +48,8 @@ class PublicLinuxSysmanImp : public L0::LinuxSysmanImp {
|
||||
|
||||
class SysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
|
||||
public:
|
||||
Mock<LinuxSysfsAccess> *pSysfsAccess = nullptr;
|
||||
Mock<LinuxProcfsAccess> *pProcfsAccess = nullptr;
|
||||
MockLinuxSysfsAccess *pSysfsAccess = nullptr;
|
||||
MockLinuxProcfsAccess *pProcfsAccess = nullptr;
|
||||
MockFwUtilInterface *pFwUtilInterface = nullptr;
|
||||
void SetUp() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
@@ -70,8 +67,8 @@ class SysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
|
||||
pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pOsSysman);
|
||||
|
||||
pFwUtilInterface = new MockFwUtilInterface();
|
||||
pSysfsAccess = new Mock<LinuxSysfsAccess>;
|
||||
pProcfsAccess = new Mock<LinuxProcfsAccess>;
|
||||
pSysfsAccess = new MockLinuxSysfsAccess;
|
||||
pProcfsAccess = new MockLinuxProcfsAccess;
|
||||
pLinuxSysmanImp->pFwUtilInterface = pFwUtilInterface;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pProcfsAccess;
|
||||
@@ -95,8 +92,8 @@ class SysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
|
||||
|
||||
class SysmanMultiDeviceFixture : public MultiDeviceFixture, public ::testing::Test {
|
||||
public:
|
||||
Mock<LinuxSysfsAccess> *pSysfsAccess = nullptr;
|
||||
Mock<LinuxProcfsAccess> *pProcfsAccess = nullptr;
|
||||
MockLinuxSysfsAccess *pSysfsAccess = nullptr;
|
||||
MockLinuxProcfsAccess *pProcfsAccess = nullptr;
|
||||
MockFwUtilInterface *pFwUtilInterface = nullptr;
|
||||
void SetUp() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
@@ -120,8 +117,8 @@ class SysmanMultiDeviceFixture : public MultiDeviceFixture, public ::testing::Te
|
||||
pLinuxSysmanImp = static_cast<PublicLinuxSysmanImp *>(pOsSysman);
|
||||
|
||||
pFwUtilInterface = new MockFwUtilInterface();
|
||||
pSysfsAccess = new Mock<LinuxSysfsAccess>;
|
||||
pProcfsAccess = new Mock<LinuxProcfsAccess>;
|
||||
pSysfsAccess = new MockLinuxSysfsAccess;
|
||||
pProcfsAccess = new MockLinuxProcfsAccess;
|
||||
pLinuxSysmanImp->pFwUtilInterface = pFwUtilInterface;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess;
|
||||
pLinuxSysmanImp->pProcfsAccess = pProcfsAccess;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,16 +15,6 @@
|
||||
#include <netlink/handlers.h>
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::ByRef;
|
||||
using ::testing::DoAll;
|
||||
using ::testing::Eq;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Return;
|
||||
using ::testing::SaveArg;
|
||||
using ::testing::StrEq;
|
||||
|
||||
struct nl_sock {
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,9 +9,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -29,10 +29,7 @@ const std::string sysfsPahTelem3 = "/sys/class/intel_pmt/telem3";
|
||||
const std::string sysfsPahTelem4 = "/sys/class/intel_pmt/telem4";
|
||||
const std::string sysfsPahTelem5 = "/sys/class/intel_pmt/telem5";
|
||||
|
||||
class PmtFsAccess : public FsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PmtFsAccess> : public PmtFsAccess {
|
||||
struct MockPmtFsAccess : public FsAccess {
|
||||
|
||||
ze_result_t listDirectoryResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t getRealPathResult = ZE_RESULT_SUCCESS;
|
||||
@@ -42,7 +39,7 @@ struct Mock<PmtFsAccess> : public PmtFsAccess {
|
||||
ze_bool_t returnInvalidRealPath = false;
|
||||
ze_bool_t readInvalidString = false;
|
||||
|
||||
Mock<PmtFsAccess>() {
|
||||
MockPmtFsAccess() {
|
||||
baseTelemSysFSNodeForSubdevice0 = baseTelemSysFS + "/" + telemNodeForSubdevice0;
|
||||
baseTelemSysFSNodeForSubdevice1 = baseTelemSysFS + "/" + telemNodeForSubdevice1;
|
||||
telemetryDeviceEntryForSubdevice0 = baseTelemSysFSNodeForSubdevice0 + "/" + telem;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -11,10 +11,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
static int fakeFileDescriptor = 123;
|
||||
@@ -25,7 +21,7 @@ const std::map<std::string, uint64_t> dummyKeyOffsetMap = {
|
||||
class ZesPmtFixtureMultiDevice : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
std::unique_ptr<Mock<PmtFsAccess>> pTestFsAccess;
|
||||
std::unique_ptr<MockPmtFsAccess> pTestFsAccess;
|
||||
std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject;
|
||||
void SetUp() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
@@ -40,7 +36,7 @@ class ZesPmtFixtureMultiDevice : public SysmanMultiDeviceFixture {
|
||||
deviceHandles.resize(subDeviceCount, nullptr);
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
|
||||
}
|
||||
pTestFsAccess = std::make_unique<Mock<PmtFsAccess>>();
|
||||
pTestFsAccess = std::make_unique<MockPmtFsAccess>();
|
||||
PlatformMonitoringTech::create(deviceHandles, pTestFsAccess.get(), gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject);
|
||||
}
|
||||
void TearDown() override {
|
||||
@@ -271,7 +267,7 @@ TEST_F(ZesPmtFixtureMultiDevice, GivenNoPMTHandleInmapOfSubDeviceIdToPmtObjectWh
|
||||
class ZesPmtFixtureNoSubDevice : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
std::unique_ptr<Mock<PmtFsAccess>> pTestFsAccess;
|
||||
std::unique_ptr<MockPmtFsAccess> pTestFsAccess;
|
||||
std::map<uint32_t, L0::PlatformMonitoringTech *> mapOfSubDeviceIdToPmtObject;
|
||||
void SetUp() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
@@ -286,7 +282,7 @@ class ZesPmtFixtureNoSubDevice : public SysmanDeviceFixture {
|
||||
deviceHandles.resize(subDeviceCount, nullptr);
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
|
||||
}
|
||||
pTestFsAccess = std::make_unique<Mock<PmtFsAccess>>();
|
||||
pTestFsAccess = std::make_unique<MockPmtFsAccess>();
|
||||
PlatformMonitoringTech::create(deviceHandles, pTestFsAccess.get(), gpuUpstreamPortPathInPmt, mapOfSubDeviceIdToPmtObject);
|
||||
}
|
||||
void TearDown() override {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -26,9 +26,9 @@ class MockPmuInterfaceImpForSysman : public PmuInterfaceImp {
|
||||
using PmuInterfaceImp::syscallFunction;
|
||||
MockPmuInterfaceImpForSysman(LinuxSysmanImp *pLinuxSysmanImp) : PmuInterfaceImp(pLinuxSysmanImp) {}
|
||||
};
|
||||
template <>
|
||||
struct Mock<MockPmuInterfaceImpForSysman> : public MockPmuInterfaceImpForSysman {
|
||||
Mock<MockPmuInterfaceImpForSysman>(LinuxSysmanImp *pLinuxSysmanImp) : MockPmuInterfaceImpForSysman(pLinuxSysmanImp) {}
|
||||
|
||||
struct MockPmuInterface : public MockPmuInterfaceImpForSysman {
|
||||
MockPmuInterface(LinuxSysmanImp *pLinuxSysmanImp) : MockPmuInterfaceImpForSysman(pLinuxSysmanImp) {}
|
||||
|
||||
int pmuRead(int fd, uint64_t *data, ssize_t sizeOfdata) override {
|
||||
data[0] = mockEventCount;
|
||||
@@ -42,10 +42,7 @@ struct Mock<MockPmuInterfaceImpForSysman> : public MockPmuInterfaceImpForSysman
|
||||
ADDMETHOD_NOBASE(getErrorNo, int, EINVAL, ());
|
||||
};
|
||||
|
||||
class PmuFsAccess : public FsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PmuFsAccess> : public PmuFsAccess {
|
||||
struct MockPmuFsAccess : public FsAccess {
|
||||
ze_result_t read(const std::string file, uint32_t &val) override {
|
||||
val = 18;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -10,15 +10,13 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::Matcher;
|
||||
using ::testing::Return;
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
struct SysmanPmuFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<MockPmuInterfaceImpForSysman>> pPmuInterface;
|
||||
std::unique_ptr<MockPmuInterface> pPmuInterface;
|
||||
PmuInterface *pOriginalPmuInterface = nullptr;
|
||||
std::unique_ptr<Mock<PmuFsAccess>> pFsAccess;
|
||||
std::unique_ptr<MockPmuFsAccess> pFsAccess;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
@@ -27,10 +25,10 @@ struct SysmanPmuFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<PmuFsAccess>>>();
|
||||
pFsAccess = std::make_unique<MockPmuFsAccess>();
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pOriginalPmuInterface = pLinuxSysmanImp->pPmuInterface;
|
||||
pPmuInterface = std::make_unique<NiceMock<Mock<MockPmuInterfaceImpForSysman>>>(pLinuxSysmanImp);
|
||||
pPmuInterface = std::make_unique<MockPmuInterface>(pLinuxSysmanImp);
|
||||
pLinuxSysmanImp->pPmuInterface = pPmuInterface.get();
|
||||
}
|
||||
void TearDown() override {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -39,10 +39,7 @@ const std::vector<std::string> mockReadBytes =
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
};
|
||||
|
||||
class PciSysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PciSysfsAccess> : public PciSysfsAccess {
|
||||
struct MockPciSysfsAccess : public SysfsAccess {
|
||||
|
||||
bool isStringSymLinkEmpty = false;
|
||||
|
||||
@@ -92,7 +89,7 @@ struct Mock<PciSysfsAccess> : public PciSysfsAccess {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
Mock<PciSysfsAccess>() = default;
|
||||
MockPciSysfsAccess() = default;
|
||||
};
|
||||
|
||||
class PublicLinuxPciImp : public L0::LinuxPciImp {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -14,11 +14,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::NiceMock;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
constexpr uint32_t expectedBus = 0u;
|
||||
@@ -227,7 +222,7 @@ struct MockMemoryManagerPci : public MemoryManagerMock {
|
||||
class ZesPciFixture : public SysmanDeviceFixture {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Mock<PciSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockPciSysfsAccess> pSysfsAccess;
|
||||
MockMemoryManagerPci *memoryManager = nullptr;
|
||||
SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
FsAccess *pOriginalFsAccess = nullptr;
|
||||
@@ -243,11 +238,11 @@ class ZesPciFixture : public SysmanDeviceFixture {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
|
||||
pMemoryManagerOld = device->getDriverHandle()->getMemoryManager();
|
||||
memoryManager = new ::testing::NiceMock<MockMemoryManagerPci>(*neoDevice->getExecutionEnvironment());
|
||||
memoryManager = new MockMemoryManagerPci(*neoDevice->getExecutionEnvironment());
|
||||
memoryManager->localMemorySupported[0] = false;
|
||||
device->getDriverHandle()->setMemoryManager(memoryManager);
|
||||
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<PciSysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockPciSysfsAccess>();
|
||||
pOriginalSysfsAccess = pLinuxSysmanImp->pSysfsAccess;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::DoDefault;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
constexpr uint64_t setEnergyCounter = (83456u * 1048576u);
|
||||
@@ -51,10 +47,7 @@ const std::map<std::string, uint64_t> deviceKeyOffsetMapPower = {
|
||||
{"SOC_TEMPERATURES", 0x60},
|
||||
{"CORE_TEMPERATURES", 0x6c}};
|
||||
|
||||
class PowerSysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PowerSysfsAccess> : public PowerSysfsAccess {
|
||||
struct MockPowerSysfsAccess : public SysfsAccess {
|
||||
|
||||
std::vector<ze_result_t> mockReadReturnStatus{};
|
||||
std::vector<ze_result_t> mockWriteReturnStatus{};
|
||||
@@ -286,27 +279,21 @@ struct Mock<PowerSysfsAccess> : public PowerSysfsAccess {
|
||||
return result;
|
||||
}
|
||||
|
||||
Mock<PowerSysfsAccess>() = default;
|
||||
MockPowerSysfsAccess() = default;
|
||||
};
|
||||
|
||||
class PowerPmt : public PlatformMonitoringTech {
|
||||
public:
|
||||
PowerPmt(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
struct MockPowerPmt : public PlatformMonitoringTech {
|
||||
using PlatformMonitoringTech::closeFunction;
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
using PlatformMonitoringTech::openFunction;
|
||||
using PlatformMonitoringTech::preadFunction;
|
||||
using PlatformMonitoringTech::telemetryDeviceEntry;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Mock<PowerPmt> : public PowerPmt {
|
||||
~Mock() override {
|
||||
MockPowerPmt(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
~MockPowerPmt() override {
|
||||
rootDeviceTelemNodeIndex = 0;
|
||||
}
|
||||
|
||||
Mock<PowerPmt>(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PowerPmt(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
|
||||
void mockedInit(FsAccess *pFsAccess) {
|
||||
std::string gpuUpstreamPortPath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0";
|
||||
if (ZE_RESULT_SUCCESS != PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPath)) {
|
||||
@@ -316,10 +303,7 @@ struct Mock<PowerPmt> : public PowerPmt {
|
||||
}
|
||||
};
|
||||
|
||||
class PowerFsAccess : public FsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PowerFsAccess> : public PowerFsAccess {
|
||||
struct MockPowerFsAccess : public FsAccess {
|
||||
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||
if (directory.compare(baseTelemSysFS) == 0) {
|
||||
@@ -358,7 +342,7 @@ struct Mock<PowerFsAccess> : public PowerFsAccess {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
Mock<PowerFsAccess>() = default;
|
||||
MockPowerFsAccess() = default;
|
||||
};
|
||||
|
||||
class PublicLinuxPowerImp : public L0::LinuxPowerImp {
|
||||
@@ -370,9 +354,9 @@ class PublicLinuxPowerImp : public L0::LinuxPowerImp {
|
||||
class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<PublicLinuxPowerImp> pPublicLinuxPowerImp;
|
||||
std::unique_ptr<Mock<PowerPmt>> pPmt;
|
||||
std::unique_ptr<Mock<PowerFsAccess>> pFsAccess;
|
||||
std::unique_ptr<Mock<PowerSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
OsPower *pOsPowerOriginal = nullptr;
|
||||
@@ -383,11 +367,11 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<PowerFsAccess>>>();
|
||||
pFsAccess = std::make_unique<MockPowerFsAccess>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<PowerSysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockPowerSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
|
||||
uint32_t subDeviceCount = 0;
|
||||
@@ -404,8 +388,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = new NiceMock<Mock<PowerPmt>>(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
auto pPmt = new MockPowerPmt(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
pPmt->mockedInit(pFsAccess.get());
|
||||
pPmt->keyOffsetMap = deviceKeyOffsetMapPower;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt);
|
||||
@@ -434,9 +418,9 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<PublicLinuxPowerImp> pPublicLinuxPowerImp;
|
||||
std::unique_ptr<Mock<PowerPmt>> pPmt;
|
||||
std::unique_ptr<Mock<PowerFsAccess>> pFsAccess;
|
||||
std::unique_ptr<Mock<PowerSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
OsPower *pOsPowerOriginal = nullptr;
|
||||
@@ -447,11 +431,11 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<PowerFsAccess>>>();
|
||||
pFsAccess = std::make_unique<MockPowerFsAccess>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<PowerSysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockPowerSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
|
||||
uint32_t subDeviceCount = 0;
|
||||
@@ -468,8 +452,8 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = new NiceMock<Mock<PowerPmt>>(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
auto pPmt = new MockPowerPmt(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
pPmt->mockedInit(pFsAccess.get());
|
||||
pPmt->keyOffsetMap = deviceKeyOffsetMapPower;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -17,10 +17,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::DoDefault;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
constexpr uint64_t setEnergyCounter = (83456u * 1048576u);
|
||||
@@ -50,10 +46,7 @@ const std::map<std::string, uint64_t> deviceKeyOffsetMapPower = {
|
||||
{"SOC_TEMPERATURES", 0x60},
|
||||
{"CORE_TEMPERATURES", 0x6c}};
|
||||
|
||||
class PowerSysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PowerSysfsAccess> : public PowerSysfsAccess {
|
||||
struct MockPowerSysfsAccess : public SysfsAccess {
|
||||
ze_result_t mockReadResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockReadValUnsignedLongResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockReadPeakResult = ZE_RESULT_SUCCESS;
|
||||
@@ -218,27 +211,21 @@ struct Mock<PowerSysfsAccess> : public PowerSysfsAccess {
|
||||
return getscanDirEntries(file, listOfEntries);
|
||||
}
|
||||
|
||||
Mock<PowerSysfsAccess>() = default;
|
||||
MockPowerSysfsAccess() = default;
|
||||
};
|
||||
|
||||
class PowerPmt : public PlatformMonitoringTech {
|
||||
public:
|
||||
PowerPmt(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
struct MockPowerPmt : public PlatformMonitoringTech {
|
||||
|
||||
MockPowerPmt(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
using PlatformMonitoringTech::closeFunction;
|
||||
using PlatformMonitoringTech::keyOffsetMap;
|
||||
using PlatformMonitoringTech::openFunction;
|
||||
using PlatformMonitoringTech::preadFunction;
|
||||
using PlatformMonitoringTech::telemetryDeviceEntry;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Mock<PowerPmt> : public PowerPmt {
|
||||
~Mock() override {
|
||||
~MockPowerPmt() override {
|
||||
rootDeviceTelemNodeIndex = 0;
|
||||
}
|
||||
|
||||
Mock<PowerPmt>(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : PowerPmt(pFsAccess, onSubdevice, subdeviceId) {}
|
||||
|
||||
void mockedInit(FsAccess *pFsAccess) {
|
||||
std::string gpuUpstreamPortPath = "/sys/devices/pci0000:89/0000:89:02.0/0000:8a:00.0";
|
||||
if (ZE_RESULT_SUCCESS != PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess, gpuUpstreamPortPath)) {
|
||||
@@ -249,10 +236,7 @@ struct Mock<PowerPmt> : public PowerPmt {
|
||||
}
|
||||
};
|
||||
|
||||
class PowerFsAccess : public FsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PowerFsAccess> : public PowerFsAccess {
|
||||
struct MockPowerFsAccess : public FsAccess {
|
||||
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||
if (directory.compare(baseTelemSysFS) == 0) {
|
||||
@@ -285,7 +269,7 @@ struct Mock<PowerFsAccess> : public PowerFsAccess {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
Mock<PowerFsAccess>() = default;
|
||||
MockPowerFsAccess() = default;
|
||||
};
|
||||
|
||||
class PublicLinuxPowerImp : public L0::LinuxPowerImp {
|
||||
@@ -297,9 +281,9 @@ class PublicLinuxPowerImp : public L0::LinuxPowerImp {
|
||||
class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<PublicLinuxPowerImp> pPublicLinuxPowerImp;
|
||||
std::unique_ptr<Mock<PowerPmt>> pPmt;
|
||||
std::unique_ptr<Mock<PowerFsAccess>> pFsAccess;
|
||||
std::unique_ptr<Mock<PowerSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
OsPower *pOsPowerOriginal = nullptr;
|
||||
@@ -310,11 +294,11 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<PowerFsAccess>>>();
|
||||
pFsAccess = std::make_unique<MockPowerFsAccess>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<PowerSysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockPowerSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
uint32_t subDeviceCount = 0;
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
@@ -329,8 +313,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = new NiceMock<Mock<PowerPmt>>(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
auto pPmt = new MockPowerPmt(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
pPmt->mockedInit(pFsAccess.get());
|
||||
pPmt->keyOffsetMap = deviceKeyOffsetMapPower;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt);
|
||||
@@ -357,9 +341,9 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<PublicLinuxPowerImp> pPublicLinuxPowerImp;
|
||||
std::unique_ptr<Mock<PowerPmt>> pPmt;
|
||||
std::unique_ptr<Mock<PowerFsAccess>> pFsAccess;
|
||||
std::unique_ptr<Mock<PowerSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
OsPower *pOsPowerOriginal = nullptr;
|
||||
@@ -370,11 +354,11 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<PowerFsAccess>>>();
|
||||
pFsAccess = std::make_unique<MockPowerFsAccess>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<PowerSysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockPowerSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
uint32_t subDeviceCount = 0;
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
@@ -391,8 +375,8 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = new NiceMock<Mock<PowerPmt>>(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
auto pPmt = new MockPowerPmt(pFsAccess.get(), deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE,
|
||||
deviceProperties.subdeviceId);
|
||||
pPmt->mockedInit(pFsAccess.get());
|
||||
pPmt->keyOffsetMap = deviceKeyOffsetMapPower;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(deviceProperties.subdeviceId, pPmt);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -183,7 +183,7 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCoun
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = static_cast<NiceMock<Mock<PowerPmt>> *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
pPmt->openFunction = openMockPower;
|
||||
pPmt->closeFunction = closeMockPower;
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
@@ -506,7 +506,7 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCoun
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = static_cast<NiceMock<Mock<PowerPmt>> *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
pPmt->openFunction = openMockPower;
|
||||
pPmt->closeFunction = closeMockPower;
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
@@ -656,7 +656,7 @@ TEST_F(SysmanDevicePowerMultiDeviceFixture, GivenValidPowerHandleWhenGettingPowe
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = static_cast<NiceMock<Mock<PowerPmt>> *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
pPmt->openFunction = openMockPower;
|
||||
pPmt->closeFunction = closeMockPower;
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -443,4 +443,4 @@ HWTEST2_F(SysmanDevicePowerMultiDeviceFixtureHelper, GivenValidPowerHandlesWhenC
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
} // namespace L0
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -190,7 +190,7 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCoun
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = static_cast<NiceMock<Mock<PowerPmt>> *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
pPmt->openFunction = openMockPower;
|
||||
pPmt->closeFunction = closeMockPower;
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
@@ -713,7 +713,7 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCoun
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = static_cast<NiceMock<Mock<PowerPmt>> *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
pPmt->openFunction = openMockPower;
|
||||
pPmt->closeFunction = closeMockPower;
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
@@ -823,7 +823,7 @@ TEST_F(SysmanDevicePowerMultiDeviceFixture, GivenValidPowerHandleWhenGettingPowe
|
||||
for (auto &deviceHandle : deviceHandles) {
|
||||
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
|
||||
auto pPmt = static_cast<NiceMock<Mock<PowerPmt>> *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(deviceProperties.subdeviceId));
|
||||
pPmt->openFunction = openMockPower;
|
||||
pPmt->closeFunction = closeMockPower;
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,9 +15,7 @@
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class RasFsAccess : public FsAccess {};
|
||||
|
||||
struct MockRasFsAccess : public RasFsAccess {
|
||||
struct MockRasFsAccess : public FsAccess {
|
||||
bool mockRootUser = true;
|
||||
bool isRootUser() override {
|
||||
return mockRootUser;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -72,13 +72,9 @@ struct MockMemoryManagerInRasSysman : public MemoryManagerMock {
|
||||
MockMemoryManagerInRasSysman(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
|
||||
};
|
||||
|
||||
class MockPmuInterfaceImpForRas : public PmuInterfaceImp {
|
||||
public:
|
||||
struct MockRasPmuInterfaceImp : public PmuInterfaceImp {
|
||||
using PmuInterfaceImp::perfEventOpen;
|
||||
MockPmuInterfaceImpForRas(LinuxSysmanImp *pLinuxSysmanImp) : PmuInterfaceImp(pLinuxSysmanImp) {}
|
||||
};
|
||||
template <>
|
||||
struct Mock<MockPmuInterfaceImpForRas> : public MockPmuInterfaceImpForRas {
|
||||
MockRasPmuInterfaceImp(LinuxSysmanImp *pLinuxSysmanImp) : PmuInterfaceImp(pLinuxSysmanImp) {}
|
||||
|
||||
int32_t mockPmuReadCount = 0;
|
||||
int32_t mockPmuReadCountAfterClear = 0;
|
||||
@@ -90,8 +86,6 @@ struct Mock<MockPmuInterfaceImpForRas> : public MockPmuInterfaceImpForRas {
|
||||
bool mockPerfEvent = false;
|
||||
bool mockPmuReadTile = false;
|
||||
|
||||
Mock<MockPmuInterfaceImpForRas>(LinuxSysmanImp *pLinuxSysmanImp) : MockPmuInterfaceImpForRas(pLinuxSysmanImp) {}
|
||||
|
||||
int64_t perfEventOpen(perf_event_attr *attr, pid_t pid, int cpu, int groupFd, uint64_t flags) override {
|
||||
|
||||
if (mockPerfEvent == true) {
|
||||
@@ -246,10 +240,7 @@ struct Mock<MockPmuInterfaceImpForRas> : public MockPmuInterfaceImpForRas {
|
||||
}
|
||||
};
|
||||
|
||||
class RasFsAccess : public FsAccess {};
|
||||
class RasSysfsAccess : public SysfsAccess {};
|
||||
template <>
|
||||
struct Mock<RasSysfsAccess> : public RasSysfsAccess {
|
||||
struct MockRasSysfsAccess : public SysfsAccess {
|
||||
|
||||
ze_result_t mockReadSymLinkStatus = ZE_RESULT_SUCCESS;
|
||||
bool mockReadSymLinkResult = false;
|
||||
@@ -347,8 +338,7 @@ struct Mock<RasSysfsAccess> : public RasSysfsAccess {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Mock<RasFsAccess> : public RasFsAccess {
|
||||
struct MockRasFsAccess : public FsAccess {
|
||||
|
||||
ze_result_t mockListDirectoryStatus = ZE_RESULT_SUCCESS;
|
||||
bool mockReadDirectoryFailure = false;
|
||||
@@ -488,13 +478,10 @@ struct Mock<RasFsAccess> : public RasFsAccess {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mock<RasFsAccess>() = default;
|
||||
MockRasFsAccess() = default;
|
||||
};
|
||||
|
||||
class RasFwInterface : public FirmwareUtil {};
|
||||
|
||||
template <>
|
||||
struct Mock<RasFwInterface> : public FirmwareUtil {
|
||||
struct MockRasFwInterface : public FirmwareUtil {
|
||||
|
||||
bool mockMemorySuccess = false;
|
||||
|
||||
@@ -517,7 +504,7 @@ struct Mock<RasFwInterface> : public FirmwareUtil {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
Mock<RasFwInterface>() = default;
|
||||
MockRasFwInterface() = default;
|
||||
|
||||
ADDMETHOD_NOBASE(fwDeviceInit, ze_result_t, ZE_RESULT_SUCCESS, ());
|
||||
ADDMETHOD_NOBASE(getFirstDevice, ze_result_t, ZE_RESULT_SUCCESS, (igsc_device_info * info));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Matcher;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -30,7 +30,7 @@ class TestRasFabricFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pMemoryManagerOriginal = device->getDriverHandle()->getMemoryManager();
|
||||
pMemoryManager = std::make_unique<::testing::NiceMock<MockMemoryManagerInRasSysman>>(*neoDevice->getExecutionEnvironment());
|
||||
pMemoryManager = std::make_unique<MockMemoryManagerInRasSysman>(*neoDevice->getExecutionEnvironment());
|
||||
pMemoryManager->localMemorySupported[0] = true;
|
||||
device->getDriverHandle()->setMemoryManager(pMemoryManager.get());
|
||||
pFsAccess = std::make_unique<MockRasFabricFsAccess>();
|
||||
@@ -403,7 +403,7 @@ class SysmanRasFabricMultiDeviceFixture : public MultiDeviceFixture, public ::te
|
||||
delete pLinuxSysmanImp->pProcfsAccess;
|
||||
delete pLinuxSysmanImp->pFsAccess;
|
||||
|
||||
auto pProcfsAccess = new NiceMock<Mock<LinuxProcfsAccess>>();
|
||||
auto pProcfsAccess = new MockLinuxProcfsAccess();
|
||||
auto pFsAccess = new MockRasFabricFsAccess();
|
||||
auto pSysfsAccess = new MockRasFabricSysFsAccess();
|
||||
|
||||
|
||||
@@ -10,11 +10,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::DoDefault;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
class OsRas;
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
@@ -22,10 +17,10 @@ constexpr uint32_t mockHandleCount = 2u;
|
||||
constexpr uint32_t mockHandleCountForSubDevice = 4u;
|
||||
struct SysmanRasFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<RasFsAccess>> pFsAccess;
|
||||
std::unique_ptr<Mock<RasSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<Mock<MockPmuInterfaceImpForRas>> pPmuInterface;
|
||||
std::unique_ptr<Mock<RasFwInterface>> pRasFwUtilInterface;
|
||||
std::unique_ptr<MockRasFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockRasSysfsAccess> pSysfsAccess;
|
||||
std::unique_ptr<MockRasPmuInterfaceImp> pPmuInterface;
|
||||
std::unique_ptr<MockRasFwInterface> pRasFwUtilInterface;
|
||||
MemoryManager *pMemoryManagerOriginal = nullptr;
|
||||
std::unique_ptr<MockMemoryManagerInRasSysman> pMemoryManager;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
@@ -40,12 +35,12 @@ struct SysmanRasFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pMemoryManagerOriginal = device->getDriverHandle()->getMemoryManager();
|
||||
pMemoryManager = std::make_unique<::testing::NiceMock<MockMemoryManagerInRasSysman>>(*neoDevice->getExecutionEnvironment());
|
||||
pMemoryManager = std::make_unique<MockMemoryManagerInRasSysman>(*neoDevice->getExecutionEnvironment());
|
||||
pMemoryManager->localMemorySupported[0] = true;
|
||||
device->getDriverHandle()->setMemoryManager(pMemoryManager.get());
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<RasFsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<RasSysfsAccess>>>();
|
||||
pRasFwUtilInterface = std::make_unique<NiceMock<Mock<RasFwInterface>>>();
|
||||
pFsAccess = std::make_unique<MockRasFsAccess>();
|
||||
pSysfsAccess = std::make_unique<MockRasSysfsAccess>();
|
||||
pRasFwUtilInterface = std::make_unique<MockRasFwInterface>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pSysfsAccessOriginal = pLinuxSysmanImp->pSysfsAccess;
|
||||
pOriginalPmuInterface = pLinuxSysmanImp->pPmuInterface;
|
||||
@@ -53,7 +48,7 @@ struct SysmanRasFixture : public SysmanDeviceFixture {
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
pLinuxSysmanImp->pFwUtilInterface = pRasFwUtilInterface.get();
|
||||
pPmuInterface = std::make_unique<NiceMock<Mock<MockPmuInterfaceImpForRas>>>(pLinuxSysmanImp);
|
||||
pPmuInterface = std::make_unique<MockRasPmuInterfaceImp>(pLinuxSysmanImp);
|
||||
pLinuxSysmanImp->pPmuInterface = pPmuInterface.get();
|
||||
|
||||
for (const auto &handle : pSysmanDeviceImp->pRasHandleContext->handleList) {
|
||||
@@ -527,12 +522,12 @@ TEST_F(SysmanRasFixture, GivenValidRasHandleAndHandleCountZeroWhenCallingReInitT
|
||||
|
||||
struct SysmanRasMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<RasFsAccess>> pFsAccess;
|
||||
std::unique_ptr<Mock<RasSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<Mock<MockPmuInterfaceImpForRas>> pPmuInterface;
|
||||
std::unique_ptr<MockRasFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockRasSysfsAccess> pSysfsAccess;
|
||||
std::unique_ptr<MockRasPmuInterfaceImp> pPmuInterface;
|
||||
MemoryManager *pMemoryManagerOriginal = nullptr;
|
||||
std::unique_ptr<MockMemoryManagerInRasSysman> pMemoryManager;
|
||||
std::unique_ptr<Mock<RasFwInterface>> pRasFwUtilInterface;
|
||||
std::unique_ptr<MockRasFwInterface> pRasFwUtilInterface;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
SysfsAccess *pSysfsAccessOriginal = nullptr;
|
||||
PmuInterface *pOriginalPmuInterface = nullptr;
|
||||
@@ -545,12 +540,12 @@ struct SysmanRasMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
}
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
pMemoryManagerOriginal = device->getDriverHandle()->getMemoryManager();
|
||||
pMemoryManager = std::make_unique<::testing::NiceMock<MockMemoryManagerInRasSysman>>(*neoDevice->getExecutionEnvironment());
|
||||
pMemoryManager = std::make_unique<MockMemoryManagerInRasSysman>(*neoDevice->getExecutionEnvironment());
|
||||
pMemoryManager->localMemorySupported[0] = true;
|
||||
device->getDriverHandle()->setMemoryManager(pMemoryManager.get());
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<RasFsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<RasSysfsAccess>>>();
|
||||
pRasFwUtilInterface = std::make_unique<NiceMock<Mock<RasFwInterface>>>();
|
||||
pFsAccess = std::make_unique<MockRasFsAccess>();
|
||||
pSysfsAccess = std::make_unique<MockRasSysfsAccess>();
|
||||
pRasFwUtilInterface = std::make_unique<MockRasFwInterface>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pSysfsAccessOriginal = pLinuxSysmanImp->pSysfsAccess;
|
||||
pOriginalPmuInterface = pLinuxSysmanImp->pPmuInterface;
|
||||
@@ -558,7 +553,7 @@ struct SysmanRasMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
pLinuxSysmanImp->pFwUtilInterface = pRasFwUtilInterface.get();
|
||||
pPmuInterface = std::make_unique<NiceMock<Mock<MockPmuInterfaceImpForRas>>>(pLinuxSysmanImp);
|
||||
pPmuInterface = std::make_unique<MockRasPmuInterfaceImp>(pLinuxSysmanImp);
|
||||
pLinuxSysmanImp->pPmuInterface = pPmuInterface.get();
|
||||
|
||||
pFsAccess->mockReadDirectoryForMultiDevice = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -18,10 +18,7 @@ const std::string standbyModeFile("gt/gt0/rc6_enable");
|
||||
const std::string standbyModeFile1("gt/gt1/rc6_enable");
|
||||
const std::string standbyModeFileLegacy("power/rc6_enable");
|
||||
|
||||
class StandbySysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<StandbySysfsAccess> : public StandbySysfsAccess {
|
||||
struct MockStandbySysfsAccess : public SysfsAccess {
|
||||
ze_result_t mockError = ZE_RESULT_SUCCESS;
|
||||
int mockStandbyMode = -1;
|
||||
bool isStandbyModeFileAvailable = true;
|
||||
@@ -90,8 +87,8 @@ struct Mock<StandbySysfsAccess> : public StandbySysfsAccess {
|
||||
mockError = error;
|
||||
}
|
||||
|
||||
Mock() = default;
|
||||
~Mock() override = default;
|
||||
MockStandbySysfsAccess() = default;
|
||||
~MockStandbySysfsAccess() override = default;
|
||||
|
||||
private:
|
||||
bool isFileAccessible(const std::string file) {
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Matcher;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -24,7 +21,7 @@ constexpr uint32_t mockHandleCount = 1u;
|
||||
uint32_t mockSubDeviceHandleCount = 0u;
|
||||
class ZesStandbyFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<StandbySysfsAccess>> ptestSysfsAccess;
|
||||
std::unique_ptr<MockStandbySysfsAccess> ptestSysfsAccess;
|
||||
zes_standby_handle_t hSysmanStandby = {};
|
||||
SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
@@ -34,7 +31,7 @@ class ZesStandbyFixture : public SysmanDeviceFixture {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
ptestSysfsAccess = std::make_unique<NiceMock<Mock<StandbySysfsAccess>>>();
|
||||
ptestSysfsAccess = std::make_unique<MockStandbySysfsAccess>();
|
||||
pOriginalSysfsAccess = pLinuxSysmanImp->pSysfsAccess;
|
||||
pLinuxSysmanImp->pSysfsAccess = ptestSysfsAccess.get();
|
||||
ptestSysfsAccess->setVal(standbyModeFile, standbyModeDefault);
|
||||
@@ -305,7 +302,7 @@ TEST_F(ZesStandbyFixture, GivenValidStandbyHandleWhenCallingzesStandbySetModeNev
|
||||
}
|
||||
|
||||
class ZesStandbyMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
std::unique_ptr<Mock<StandbySysfsAccess>> ptestSysfsAccess;
|
||||
std::unique_ptr<MockStandbySysfsAccess> ptestSysfsAccess;
|
||||
SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
|
||||
protected:
|
||||
@@ -315,7 +312,7 @@ class ZesStandbyMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
}
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
mockSubDeviceHandleCount = subDeviceCount;
|
||||
ptestSysfsAccess = std::make_unique<NiceMock<Mock<StandbySysfsAccess>>>();
|
||||
ptestSysfsAccess = std::make_unique<MockStandbySysfsAccess>();
|
||||
pOriginalSysfsAccess = pLinuxSysmanImp->pSysfsAccess;
|
||||
pLinuxSysmanImp->pSysfsAccess = ptestSysfsAccess.get();
|
||||
ptestSysfsAccess->setVal(standbyModeFile, standbyModeDefault);
|
||||
|
||||
Reference in New Issue
Block a user