L0 Core Add Support For pci_speed_ext

This patch adds support for reading PCI bandwidth, generation
and linkwidth information from sysfs nodes for the linux
platform.

Related-To: LOCI-2969

Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
Joshua Santosh Ranjan
2022-02-28 13:31:18 +00:00
committed by Compute-Runtime-Automation
parent 061af9c284
commit 05a150f49f
29 changed files with 722 additions and 60 deletions

View File

@@ -17,6 +17,7 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_special_heap_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_uuid_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_pci_speed_info_tests.cpp
)
if(NEO_ENABLE_i915_PRELIM_DETECTION)

View File

@@ -0,0 +1,320 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/string.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
struct DrmPciSpeedInfoTest : public ::testing::Test {
void SetUp() override {
SysCalls::sysCallsReadlink = mockReadLink;
SysCalls::sysCallsOpen = mockOpenDiscrete;
SysCalls::sysCallsPread = mockPreadDiscrete;
}
void TearDown() override {
SysCalls::sysCallsReadlink = sysCallsReadlinkBackup;
SysCalls::sysCallsOpen = sysCallsOpenBackup;
SysCalls::sysCallsPread = sysCallsPreadBackup;
}
std::unique_ptr<DrmMock> getDrm(bool isTestIntegratedDevice) {
HardwareInfo hwInfo = *defaultHwInfo.get();
hwInfo.capabilityTable.isIntegratedDevice = isTestIntegratedDevice;
executionEnvironment = std::make_unique<MockExecutionEnvironment>(&hwInfo, false, 1);
return std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
}
decltype(SysCalls::sysCallsReadlink) mockReadLink = [](const char *path, char *buf, size_t bufsize) -> int {
std::string linkString("../../devices/pci0000:00/0000:00:02.0/0000:00:02.0/0000:00:02.0/drm/renderD128");
memcpy_s(buf, bufsize, linkString.c_str(), linkString.size());
return static_cast<int>(linkString.size());
};
decltype(SysCalls::sysCallsOpen) mockOpenDiscrete = [](const char *pathname, int flags) -> int {
std::vector<std::string> supportedFiles = {
"/sys/devices/pci0000:00/0000:00:02.0/max_link_width",
"/sys/devices/pci0000:00/0000:00:02.0/max_link_speed"};
auto itr = std::find(supportedFiles.begin(), supportedFiles.end(), std::string(pathname));
if (itr != supportedFiles.end()) {
// skipping "0"
return static_cast<int>(std::distance(supportedFiles.begin(), itr)) + 1;
}
return 0;
};
decltype(SysCalls::sysCallsPread) mockPreadDiscrete = [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_width", "64"},
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_speed", "32"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
return -1;
};
decltype(SysCalls::sysCallsReadlink) sysCallsReadlinkBackup = SysCalls::sysCallsReadlink;
decltype(SysCalls::sysCallsOpen) sysCallsOpenBackup = SysCalls::sysCallsOpen;
decltype(SysCalls::sysCallsPread) sysCallsPreadBackup = SysCalls::sysCallsPread;
std::unique_ptr<ExecutionEnvironment> executionEnvironment = nullptr;
};
TEST_F(DrmPciSpeedInfoTest, givenIntegratedDeviceWhenCorrectInputsAreGivenThenCorrectPciSpeedIsReturned) {
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpenIntegrated(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
std::vector<std::string> supportedFiles = {
"/sys/class/drm/../../devices/pci0000:00/0000:00:02.0/0000:00:02.0/0000:00:02.0/drm/renderD128/device//max_link_width",
"/sys/class/drm/../../devices/pci0000:00/0000:00:02.0/0000:00:02.0/0000:00:02.0/drm/renderD128/device//max_link_speed"};
auto itr = std::find(supportedFiles.begin(), supportedFiles.end(), std::string(pathname));
if (itr != supportedFiles.end()) {
// skipping "0"
return static_cast<int>(std::distance(supportedFiles.begin(), itr)) + 1;
}
return 0;
});
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPreadIntegrated(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/class/drm/../../devices/pci0000:00/0000:00:02.0/0000:00:02.0/0000:00:02.0/drm/renderD128/device//max_link_width", "64"},
{"/sys/class/drm/../../devices/pci0000:00/0000:00:02.0/0000:00:02.0/0000:00:02.0/drm/renderD128/device//max_link_speed", "16.0 GT/s PCIe \n test"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(true)->getPciSpeedInfo();
EXPECT_EQ(4, pciSpeedInfo.genVersion);
EXPECT_EQ(64, pciSpeedInfo.width);
EXPECT_EQ(126030769230, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenCorrectInputsAreGivenThenCorrectPciSpeedIsReturned) {
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(5, pciSpeedInfo.genVersion);
EXPECT_EQ(64, pciSpeedInfo.width);
EXPECT_EQ(252061538461, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenIntegratedDeviceWhenPciLinkPathFailsThenUnknownPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(true)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenPciRootPathFailsThenUnknownPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenPciRootPathFailsDueToMissingPciThenUnknownPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::string linkString("../../devices/");
memcpy_s(buf, bufsize, linkString.c_str(), linkString.size());
return static_cast<int>(linkString.size());
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenPciRootPathFailsDueToUnavailableDirectoryPathThenUnknownPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsReadlink)> mockReadLink(&NEO::SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::string linkString("../../devices/pci0000:00");
memcpy_s(buf, bufsize, linkString.c_str(), linkString.size());
return static_cast<int>(linkString.size());
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenPreadReturnsNegativeValueWhenAccessingSysfsNodesThenUnknownPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenPreadReturnsZeroWhenAccessingSysfsNodesThenUnknownPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
return 0;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenReadingLinkWidthStrtoulFailsWithNoValidConversionUnknownThenPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_width", "Unknown"},
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_speed", "32"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenReadingLinkWidthStrtoulFailsWithErrnoSetUnknownThenPciSpeedIsReturned) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_width", "64"},
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_speed", "32"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
errno = 22;
return supportedFiles[fd].second.size();
}
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(-1, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenReadingMaxLinkSpeedFailsThenUnknownPciSpeedIsReturnedForGenVersionAndMaxBandwidth) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_width", "64"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(64, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenReadingLinkSpeedStrtoulFailsWithNoValidConversionThenUnknownPciSpeedIsReturnedForGenVersionAndMaxBandwidth) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_width", "64"},
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_speed", "Unknown"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(64, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenReadingLinkSpeedStrtodFailsWithErrnoSetThenUnknownPciSpeedIsReturnedForGenVersionAndMaxBandwidth) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_width", "64"},
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_speed", "32"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
if (fd == 1) {
errno = 22;
}
return supportedFiles[fd].second.size();
}
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(64, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}
TEST_F(DrmPciSpeedInfoTest, givenDiscreteDeviceWhenUnSupportedLinkSpeedIsReadThenUnknownPciSpeedIsReturnedForGenVersionAndMaxBandwidth) {
VariableBackup<decltype(NEO::SysCalls::sysCallsPread)> mockPread(&NEO::SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
std::vector<std::pair<std::string, std::string>> supportedFiles = {
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_width", "64"},
{"/sys/devices/pci0000:00/0000:00:02.0/max_link_speed", "0 32"},
};
fd -= 1;
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy_s(buf, count, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
return -1;
});
PhyicalDevicePciSpeedInfo pciSpeedInfo = getDrm(false)->getPciSpeedInfo();
EXPECT_EQ(-1, pciSpeedInfo.genVersion);
EXPECT_EQ(64, pciSpeedInfo.width);
EXPECT_EQ(-1, pciSpeedInfo.maxBandwidth);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -64,7 +64,7 @@ using namespace NEO;
HWTEST2_F(MultipleDeviceUuidTest, whenRetrievingDeviceUuidThenCorrectUuidIsReceived, IsXEHP) {
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/crashlog1", "../../devices/pci0000:6a/0000:6a:03.1/intel-dvsec-4.4.auto/intel_pmt/crashlog1/"},
{"/sys/class/intel_pmt/crashlog2", "../../devices/pci0000:6a/0000:6a:03.1/intel-dvsec-4.4.auto/intel_pmt/crashlog2/"},
{"/sys/class/intel_pmt/crashlog3", "../../devices/pci0000:e8/0000:e8:03.1/intel-dvsec-4.8.auto/intel_pmt/crashlog3/"},
@@ -116,7 +116,7 @@ HWTEST2_F(MultipleDeviceUuidTest, whenRetrievingDeviceUuidThenCorrectUuidIsRecei
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
if (supportedFiles[fd].second == "dummy") {
uint64_t data = 0xFEEDBEADDEABDEEF;
memcpy(buf, &data, sizeof(data));
@@ -154,7 +154,7 @@ HWTEST2_F(MultipleDeviceUuidTest, whenRetrievingDeviceUuidThenCorrectUuidIsRecei
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/crashlog1", "../../devices/pci0000:6a/0000:6a:03.1/intel-dvsec-4.4.auto/intel_pmt/crashlog1/"},
{"/sys/class/intel_pmt/crashlog2", "../../devices/pci0000:6a/0000:6a:03.1/intel-dvsec-4.4.auto/intel_pmt/crashlog2/"},
{"/sys/class/intel_pmt/crashlog3", "../../devices/pci0000:e8/0000:e8:03.1/intel-dvsec-4.8.auto/intel_pmt/crashlog3/"},
@@ -208,7 +208,7 @@ HWTEST2_F(MultipleDeviceUuidTest, whenRetrievingDeviceUuidThenCorrectUuidIsRecei
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
if (supportedFiles[fd].second == "dummy") {
uint64_t data = 0xFEEDBEADDEABDEEF;
memcpy(buf, &data, sizeof(data));
@@ -260,7 +260,7 @@ HWTEST2_F(MultipleDeviceUuidTest, givenTelemDirectoriesAreLessThanExpectedWhenRe
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
};
@@ -294,7 +294,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenMissingGuidWhenRetrievingUuidForSubDevice
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
@@ -330,7 +330,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenMissingGuidWhenRetrievingUuidForSubDevice
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
if (supportedFiles[fd].second == "dummy") {
uint64_t data = 0xFEEDBEADDEABDEEF;
memcpy(buf, &data, sizeof(data));
@@ -356,7 +356,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenIncorrectGuidWhenRetrievingUuidForSubDevi
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
@@ -402,7 +402,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenMissingOffsetWhenRetrievingUuidForSubDevi
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
@@ -437,7 +437,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenMissingOffsetWhenRetrievingUuidForSubDevi
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy(buf, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
@@ -458,7 +458,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenIncorrectOffsetWhenRetrievingUuidForSubDe
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
@@ -493,7 +493,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenIncorrectOffsetWhenRetrievingUuidForSubDe
};
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy(buf, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
@@ -513,7 +513,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenMissingTelemNodeWhenRetrievingUuidThenFai
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
@@ -548,7 +548,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenMissingTelemNodeWhenRetrievingUuidThenFai
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy(buf, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
@@ -564,7 +564,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenIncorrectTelemNodeWhenRetrievingUuidThenF
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
@@ -600,7 +600,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenIncorrectTelemNodeWhenRetrievingUuidThenF
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy(buf, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}
@@ -616,7 +616,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenIncorrectGuidValueWhenRetrievingUuidThenF
VariableBackup<decltype(SysCalls::sysCallsReadlink)> mockReadLink(&SysCalls::sysCallsReadlink, [](const char *path, char *buf, size_t bufsize) -> int {
std::map<std::string, std::string> fileNameLinkMap = {
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/i915-spi.2.auto/mtd/mtd0/mtd3/"},
{"/sys/dev/char/226:128", "../../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:01.0/0000:3a:00.0/drm/renderD128"},
{"/sys/class/intel_pmt/telem3", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem3/"},
{"/sys/class/intel_pmt/telem1", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem1/"},
{"/sys/class/intel_pmt/telem2", "./../devices/pci0000:37/0000:37:01.0/0000:38:00.0/0000:39:02.0/0000:3c:00.1/intel-dvsec-2.1.auto/intel_pmt/telem2/"},
@@ -653,7 +653,7 @@ HWTEST2_F(MultipleDeviceUuidTest, GivenIncorrectGuidValueWhenRetrievingUuidThenF
fd -= 1;
if ((fd) < static_cast<int>(supportedFiles.size())) {
if ((fd >= 0) && (fd < static_cast<int>(supportedFiles.size()))) {
memcpy(buf, supportedFiles[fd].second.c_str(), supportedFiles[fd].second.size());
return supportedFiles[fd].second.size();
}