mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Added Events ULT
Related-To: LOCI-3716 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
32bab85f7e
commit
63f7962162
@@ -6,12 +6,16 @@
|
||||
|
||||
set(L0_TESTS_TOOLS_SYSMAN_EVENTS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}test_zes_events.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}mock_events.h
|
||||
)
|
||||
|
||||
if(NEO_ENABLE_i915_PRELIM_DETECTION AND("${BRANCH_TYPE}" STREQUAL ""))
|
||||
list(REMOVE_ITEM L0_TESTS_TOOLS_SYSMAN_EVENTS_LINUX
|
||||
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||
list(APPEND L0_TESTS_TOOLS_SYSMAN_EVENTS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_events_prelim.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_events_prelim.h
|
||||
)
|
||||
|
||||
else()
|
||||
list(APPEND L0_TESTS_TOOLS_SYSMAN_EVENTS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_events.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_events.h
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -19,65 +19,43 @@ const std::string deviceDir("device");
|
||||
|
||||
class EventsFsAccess : public FsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<EventsFsAccess> : public EventsFsAccess {
|
||||
struct MockEventsFsAccess : public EventsFsAccess {
|
||||
std::vector<ze_result_t> mockReadStatus{ZE_RESULT_SUCCESS};
|
||||
uint32_t mockReadVal = 2;
|
||||
|
||||
ze_result_t getValReturnValAsOne(const std::string file, uint32_t &val) {
|
||||
if (file.compare(ueventWedgedFile) == 0) {
|
||||
val = 1;
|
||||
} else if (file.compare(ueventDetachFile) == 0) {
|
||||
val = 1;
|
||||
} else if (file.compare(ueventAttachFile) == 0) {
|
||||
val = 1;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
ze_result_t read(const std::string file, uint32_t &val) override {
|
||||
ze_result_t returnValue = ZE_RESULT_SUCCESS;
|
||||
|
||||
if (!mockReadStatus.empty()) {
|
||||
returnValue = mockReadStatus.front();
|
||||
if (returnValue != ZE_RESULT_SUCCESS) {
|
||||
return returnValue;
|
||||
}
|
||||
mockReadStatus.erase(mockReadStatus.begin());
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
val = mockReadVal;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
ze_result_t getValReturnValAsZero(const std::string file, uint32_t &val) {
|
||||
if (file.compare(ueventWedgedFile) == 0) {
|
||||
val = 0;
|
||||
} else if (file.compare(ueventDetachFile) == 0) {
|
||||
val = 0;
|
||||
} else if (file.compare(ueventAttachFile) == 0) {
|
||||
val = 0;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValFileNotFound(const std::string file, uint32_t &val) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t getValFileInsufficientPermissions(const std::string file, uint32_t &val) {
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
|
||||
Mock<EventsFsAccess>() = default;
|
||||
|
||||
MOCK_METHOD(ze_result_t, read, (const std::string file, uint32_t &val), (override));
|
||||
MOCK_METHOD(ze_result_t, canWrite, (const std::string file), (override));
|
||||
MockEventsFsAccess() = default;
|
||||
};
|
||||
|
||||
class EventsSysfsAccess : public SysfsAccess {};
|
||||
template <>
|
||||
struct Mock<EventsSysfsAccess> : public EventsSysfsAccess {
|
||||
MOCK_METHOD(ze_result_t, readSymLink, (const std::string file, std::string &buf), (override));
|
||||
ze_result_t getValStringSymLinkSuccess(const std::string file, std::string &val) {
|
||||
if (file.compare(deviceDir) == 0) {
|
||||
val = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0";
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
struct MockEventsSysfsAccess : public EventsSysfsAccess {
|
||||
ze_result_t mockReadSymLinkFailureError = ZE_RESULT_SUCCESS;
|
||||
|
||||
ze_result_t readSymLink(const std::string file, std::string &val) override {
|
||||
if (mockReadSymLinkFailureError != ZE_RESULT_SUCCESS) {
|
||||
return mockReadSymLinkFailureError;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
ze_result_t getValStringSymLinkFailure(const std::string file, std::string &val) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
|
||||
val = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0";
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
Mock<EventsSysfsAccess>() = default;
|
||||
MockEventsSysfsAccess() = default;
|
||||
};
|
||||
|
||||
class PublicLinuxEventsImp : public L0::LinuxEventsImp {
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/events/events_imp.h"
|
||||
#include "level_zero/tools/source/sysman/events/linux/os_events_imp_prelim.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
const std::string ueventWedgedFile("/var/lib/libze_intel_gpu/wedged_file");
|
||||
const std::string ueventDetachFile("/var/lib/libze_intel_gpu/remove-pci-0000_03_00_0");
|
||||
const std::string ueventAttachFile("/var/lib/libze_intel_gpu/add-pci-0000_03_00_0");
|
||||
const std::string ueventFabricFile("/var/lib/libze_intel_gpu/fabric-pci-0000_03_00_0");
|
||||
const std::string deviceDir("device");
|
||||
const std::string deviceMemoryHealth("device_memory_health");
|
||||
const std::string eventsDir("/sys/devices/i915_0000_03_00.0/events");
|
||||
constexpr int64_t mockPmuFd = 10;
|
||||
constexpr uint64_t errorCount = 10u;
|
||||
constexpr uint64_t mockTimeStamp = 1100u;
|
||||
|
||||
class MockPmuInterfaceImp : public PmuInterfaceImp {
|
||||
public:
|
||||
using PmuInterfaceImp::perfEventOpen;
|
||||
MockPmuInterfaceImp(LinuxSysmanImp *pLinuxSysmanImp) : PmuInterfaceImp(pLinuxSysmanImp) {}
|
||||
};
|
||||
|
||||
struct MockPmuInterfaceImpForEvents : public MockPmuInterfaceImp {
|
||||
MockPmuInterfaceImpForEvents(LinuxSysmanImp *pLinuxSysmanImp) : MockPmuInterfaceImp(pLinuxSysmanImp) {}
|
||||
bool mockPmuReadFail = false;
|
||||
|
||||
int64_t perfEventOpen(perf_event_attr *attr, pid_t pid, int cpu, int groupFd, uint64_t flags) override {
|
||||
return mockPmuFd;
|
||||
}
|
||||
|
||||
int pmuRead(int fd, uint64_t *data, ssize_t sizeOfdata) override {
|
||||
|
||||
if (mockPmuReadFail == true) {
|
||||
return mockedPmuReadAndFailureReturn(fd, data, sizeOfdata);
|
||||
}
|
||||
|
||||
data[0] = 0;
|
||||
data[1] = mockTimeStamp;
|
||||
data[2] = errorCount;
|
||||
return 0;
|
||||
}
|
||||
int mockedPmuReadAndFailureReturn(int fd, uint64_t *data, ssize_t sizeOfdata) {
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
class EventsFsAccess : public FsAccess {};
|
||||
|
||||
struct MockEventsFsAccess : public EventsFsAccess {
|
||||
|
||||
bool mockReadValSuccess = false;
|
||||
bool mockReadValOne = false;
|
||||
bool mockReadValZero = false;
|
||||
bool mockFileNotFoundError = false;
|
||||
|
||||
ze_result_t getValReturnValAsOne(const std::string file, uint32_t &val) {
|
||||
if (file.compare(ueventWedgedFile) == 0) {
|
||||
val = 1;
|
||||
} else if (file.compare(ueventDetachFile) == 0) {
|
||||
val = 1;
|
||||
} else if (file.compare(ueventAttachFile) == 0) {
|
||||
val = 1;
|
||||
} else if (file.compare(ueventFabricFile) == 0) {
|
||||
val = 1;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValReturnValAsZero(const std::string file, uint32_t &val) {
|
||||
if (file.compare(ueventWedgedFile) == 0) {
|
||||
val = 0;
|
||||
} else if (file.compare(ueventDetachFile) == 0) {
|
||||
val = 0;
|
||||
} else if (file.compare(ueventAttachFile) == 0) {
|
||||
val = 0;
|
||||
} else if (file.compare(ueventFabricFile) == 0) {
|
||||
val = 0;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t read(const std::string file, std::string &config) override {
|
||||
if (file.compare(eventsDir + "/" + "error--correctable-eu-grf") == 0) {
|
||||
config = "config=0x0000000000000001";
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else if (file.compare(eventsDir + "/" + "error--engine-reset") == 0) {
|
||||
config = "config=0x000000000000010";
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t getValFileNotFound(const std::string file, uint32_t &val) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t getValFileInsufficientPermissions(const std::string file, uint32_t &val) {
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &events) override {
|
||||
if (directory.compare(eventsDir) == 0) {
|
||||
events.push_back("error--correctable-eu-grf");
|
||||
events.push_back("error--engine-reset");
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t readValSuccess(const std::string file, uint32_t &val) {
|
||||
val = 23;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t read(const std::string file, uint32_t &val) override {
|
||||
|
||||
if (mockReadValOne == true) {
|
||||
return getValReturnValAsOne(file, val);
|
||||
}
|
||||
|
||||
else if (mockReadValZero == true) {
|
||||
return getValReturnValAsZero(file, val);
|
||||
}
|
||||
|
||||
else if (mockFileNotFoundError == true) {
|
||||
return getValFileNotFound(file, val);
|
||||
}
|
||||
|
||||
else if (mockReadValSuccess == true) {
|
||||
val = 23;
|
||||
return readValSuccess(file, val);
|
||||
}
|
||||
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
bool isRootUser() override {
|
||||
return true;
|
||||
}
|
||||
bool userIsNotRoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
MockEventsFsAccess() = default;
|
||||
};
|
||||
|
||||
class EventsSysfsAccess : public SysfsAccess {};
|
||||
struct MockEventsSysfsAccess : public EventsSysfsAccess {
|
||||
|
||||
bool mockSymLinkFailure = false;
|
||||
bool mockReadMemHealthDegraded = false;
|
||||
bool mockReadCurrMemHealth = false;
|
||||
|
||||
ze_result_t getRealPath(const std::string file, std::string &val) override {
|
||||
if (file.compare("device/") == 0) {
|
||||
val = "/sys/devices/pci0000:00/0000:00:02.0";
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t readSymLink(const std::string file, std::string &val) override {
|
||||
|
||||
if (mockSymLinkFailure == true) {
|
||||
return getValStringSymLinkFailure(file, val);
|
||||
}
|
||||
|
||||
if (file.compare(deviceDir) == 0) {
|
||||
val = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/0000:03:00.0";
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t getValStringSymLinkFailure(const std::string file, std::string &val) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t read(const std::string file, uint64_t &val) override {
|
||||
if (file.compare("gt/gt0/error_counter/correctable_eu_grf") == 0) {
|
||||
val = 5u;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else if (file.compare("gt/gt0/error_counter/engine_reset") == 0) {
|
||||
val = 8u;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
MockEventsSysfsAccess() = default;
|
||||
};
|
||||
|
||||
class UdevLibMock : public UdevLib {
|
||||
public:
|
||||
UdevLibMock() = default;
|
||||
|
||||
ADDMETHOD_NOBASE(registerEventsFromSubsystemAndGetFd, int, 5, (std::vector<std::string> & subsystemList));
|
||||
ADDMETHOD_NOBASE(getEventGenerationSourceDevice, dev_t, 0, (void *dev));
|
||||
ADDMETHOD_NOBASE(getEventType, const char *, "change", (void *dev));
|
||||
ADDMETHOD_NOBASE(getEventPropertyValue, const char *, "MOCK", (void *dev, const char *key));
|
||||
ADDMETHOD_NOBASE(allocateDeviceToReceiveData, void *, (void *)(0x12345678), ());
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(dropDeviceReference, (void *dev));
|
||||
};
|
||||
|
||||
class PublicLinuxEventsImp : public L0::LinuxEventsImp {
|
||||
public:
|
||||
PublicLinuxEventsImp(OsSysman *pOsSysman) : LinuxEventsImp(pOsSysman) {}
|
||||
using LinuxEventsImp::checkIfFabricPortStatusChanged;
|
||||
using LinuxEventsImp::listenSystemEvents;
|
||||
using LinuxEventsImp::pUdevLib;
|
||||
using LinuxEventsImp::readFabricDeviceStats;
|
||||
using LinuxEventsImp::registeredEvents;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -6,10 +6,9 @@
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/global_operations/global_operations_imp.h"
|
||||
#include "level_zero/tools/test/unit_tests/sources/sysman/events/linux/mock_events.h"
|
||||
#include "level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h"
|
||||
|
||||
#include "mock_events.h"
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::Matcher;
|
||||
@@ -19,13 +18,13 @@ namespace ult {
|
||||
|
||||
class SysmanEventsFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<EventsFsAccess>> pFsAccess;
|
||||
std::unique_ptr<MockEventsFsAccess> pFsAccess;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
OsEvents *pOsEventsPrev = nullptr;
|
||||
L0::EventsImp *pEventsImp;
|
||||
GlobalOperations *pGlobalOperationsOriginal = nullptr;
|
||||
std::unique_ptr<GlobalOperationsImp> pGlobalOperations;
|
||||
std::unique_ptr<Mock<EventsSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<MockEventsSysfsAccess> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOriginal = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
@@ -34,7 +33,7 @@ class SysmanEventsFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<EventsFsAccess>>>();
|
||||
pFsAccess = std::make_unique<MockEventsFsAccess>();
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
|
||||
pEventsImp = static_cast<L0::EventsImp *>(pSysmanDeviceImp->pEvents);
|
||||
@@ -46,10 +45,8 @@ class SysmanEventsFixture : public SysmanDeviceFixture {
|
||||
pSysmanDeviceImp->pGlobalOperations->init();
|
||||
|
||||
pSysfsAccessOriginal = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<EventsSysfsAccess>>>();
|
||||
pSysfsAccess = std::make_unique<MockEventsSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
ON_CALL(*pSysfsAccess.get(), readSymLink(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<EventsSysfsAccess>::getValStringSymLinkSuccess));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@@ -70,8 +67,7 @@ class SysmanEventsFixture : public SysmanDeviceFixture {
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredEventsThenEventListenAPIReturnsAfterReceivingEventWithinTimeout) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsOne));
|
||||
pFsAccess->mockReadVal = 1;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
@@ -85,17 +81,14 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredE
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredEventsThenEventListenAPIWaitForTimeoutIfEventNotReceived) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsZero));
|
||||
pFsAccess->mockReadVal = 0;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
zes_event_type_flags_t *pDeviceEvents = new zes_event_type_flags_t[1];
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValFileNotFound));
|
||||
pFsAccess->mockReadStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
|
||||
@@ -105,8 +98,7 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredE
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForCurrentlyUnsupportedEventsThenEventListenAPIWaitForTimeoutIfEventNotReceived) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_TEMP_THRESHOLD2));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsOne));
|
||||
pFsAccess->mockReadVal = 1;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
@@ -118,16 +110,14 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForCurrentlyUnsup
|
||||
}
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenReadSymLinkCallFailsWhenGettingPCIBDFThenEmptyPciIdPathTagReceived) {
|
||||
ON_CALL(*pSysfsAccess.get(), readSymLink(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<EventsSysfsAccess>::getValStringSymLinkFailure));
|
||||
pSysfsAccess->mockReadSymLinkFailureError = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
PublicLinuxEventsImp linuxEventImp(pOsSysman);
|
||||
EXPECT_TRUE(linuxEventImp.pciIdPathTag.empty());
|
||||
}
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceDetachEventsThenEventListenAPIReturnsAfterReceivingEventWithinTimeout) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_DETACH));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsOne));
|
||||
pFsAccess->mockReadVal = 1;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
@@ -141,8 +131,7 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceDetachEv
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceDetachEventsThenAfterReceivingEventRegisterEventAgainToReceiveEvent) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_DETACH));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsOne));
|
||||
pFsAccess->mockReadVal = 1;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
@@ -163,17 +152,14 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceDetachEv
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceDetachEventsThenEventListenAPIWaitForTimeoutIfEventNotReceived) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_DETACH));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsZero));
|
||||
pFsAccess->mockReadVal = 0;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
zes_event_type_flags_t *pDeviceEvents = new zes_event_type_flags_t[1];
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValFileNotFound));
|
||||
pFsAccess->mockReadStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
|
||||
@@ -183,8 +169,7 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceDetachEv
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceAttachEventsThenEventListenAPIReturnsAfterReceivingEventWithinTimeout) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_ATTACH));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsOne));
|
||||
pFsAccess->mockReadVal = 1;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
@@ -198,17 +183,14 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceAttachEv
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForDeviceAttachEventsThenEventListenAPIWaitForTimeoutIfEventNotReceived) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_ATTACH));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsZero));
|
||||
pFsAccess->mockReadVal = 0;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
zes_event_type_flags_t *pDeviceEvents = new zes_event_type_flags_t[1];
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValFileNotFound));
|
||||
pFsAccess->mockReadStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListen(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
|
||||
@@ -248,8 +230,7 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForAListOfEventsT
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredEventsThenEventListenExAPIReturnsAfterReceivingEventWithinTimeout) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsOne));
|
||||
pFsAccess->mockReadVal = 1;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
@@ -263,17 +244,15 @@ TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredE
|
||||
|
||||
TEST_F(SysmanEventsFixture, GivenValidDeviceHandleWhenListeningForResetRequiredEventsThenEventListenExAPIWaitForTimeoutIfEventNotReceived) {
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEventRegister(device->toHandle(), ZES_EVENT_TYPE_FLAG_DEVICE_RESET_REQUIRED));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValReturnValAsZero));
|
||||
pFsAccess->mockReadVal = 0;
|
||||
zes_device_handle_t *phDevices = new zes_device_handle_t[1];
|
||||
phDevices[0] = device->toHandle();
|
||||
uint32_t numDeviceEvents = 0;
|
||||
zes_event_type_flags_t *pDeviceEvents = new zes_event_type_flags_t[1];
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListenEx(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
pFsAccess->mockReadStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<EventsFsAccess>::getValFileNotFound));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverEventListenEx(driverHandle->toHandle(), 1u, 1u, phDevices, &numDeviceEvents, pDeviceEvents));
|
||||
EXPECT_EQ(0u, numDeviceEvents);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user