Enable ULTs for Sysman APIs ported to 1.0

Change-Id: I7ef425e6a076f8b26992a9a7cd4b2711e12f3a64
Signed-off-by: Matias A. Cabral <matias.a.cabral@intel.com>
This commit is contained in:
Matias A. Cabral
2020-08-03 15:15:20 -07:00
committed by sys_ocldev
parent 3b70bee38c
commit 990750d153
21 changed files with 27 additions and 841 deletions

View File

@@ -57,6 +57,7 @@ ze_result_t LinuxFabricPortImp::getThroughput(zes_fabric_port_throughput_t *pThr
}
void LinuxFabricPortImp::getModel(char *model) {
::snprintf(model, ZES_MAX_FABRIC_PORT_MODEL_SIZE, "%s", this->model.c_str());
}
void LinuxFabricPortImp::getPortId(zes_fabric_port_id_t &portId) {

View File

@@ -128,6 +128,13 @@ void FrequencyImp::init() {
zesFrequencyProperties.max = 0.0;
}
zesFrequencyProperties.isThrottleEventSupported = false;
double freqRange = zesFrequencyProperties.max - zesFrequencyProperties.min;
numClocks = static_cast<uint32_t>(round(freqRange / step)) + 1;
pClocks = new double[numClocks];
for (unsigned int i = 0; i < numClocks; i++) {
pClocks[i] = round(zesFrequencyProperties.min + (step * i));
}
}
FrequencyImp::FrequencyImp(OsSysman *pOsSysman) {

View File

@@ -63,9 +63,7 @@ endif()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${TARGET_NAME_L0})
# add_subdirectoriesL0(${CMAKE_CURRENT_SOURCE_DIR} "*")
add_subdirectory(sources/metrics)
add_subdirectory(gens)
add_subdirectoriesL0(${CMAKE_CURRENT_SOURCE_DIR} "*")
target_compile_definitions(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:${L0_MOCKABLE_LIB_NAME},INTERFACE_COMPILE_DEFINITIONS>)

View File

@@ -8,7 +8,6 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_engine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_engine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_engine.h
)

View File

@@ -1,127 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/tools/source/sysman/engine/linux/os_engine_imp.h"
#include "level_zero/tools/source/sysman/sysman_imp.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mock_sysfs_engine.h"
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::Matcher;
using ::testing::NiceMock;
using ::testing::Return;
namespace L0 {
namespace ult {
ACTION_P(SetUint64_t, value) {
arg0 = value;
}
ACTION_P(SetEngGroup_t, value) {
arg0 = value;
}
ACTION_P(SetString_t, value) {
arg1 = value;
}
class SysmanEngineFixture : public DeviceFixture, public ::testing::Test {
protected:
std::unique_ptr<SysmanImp> sysmanImp;
zet_sysman_handle_t hSysman;
zet_sysman_engine_handle_t hSysmanEngine;
Mock<EngineSysfsAccess> *pSysfsAccess = nullptr;
OsEngine *pOsEngine = nullptr;
PublicLinuxEngineImp linuxEngineImp;
EngineImp *pEngineImp = nullptr;
void SetUp() override {
DeviceFixture::SetUp();
sysmanImp = std::make_unique<SysmanImp>(device->toHandle());
pSysfsAccess = new NiceMock<Mock<EngineSysfsAccess>>;
linuxEngineImp.pSysfsAccess = pSysfsAccess;
pOsEngine = static_cast<OsEngine *>(&linuxEngineImp);
pEngineImp = new EngineImp();
pEngineImp->pOsEngine = pOsEngine;
ON_CALL(*pSysfsAccess, read(_, Matcher<std::string &>(_)))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<EngineSysfsAccess>::getVal));
pEngineImp->init(ZES_ENGINE_GROUP_COMPUTE_ALL);
sysmanImp->pEngineHandleContext->handleList.push_back(pEngineImp);
hSysman = sysmanImp->toHandle();
hSysmanEngine = pEngineImp->toZetHandle();
}
void TearDown() override {
//pOsEngine is static_cast of LinuxEngineImp class , hence in cleanup assign to nullptr
pEngineImp->pOsEngine = nullptr;
if (pSysfsAccess != nullptr) {
delete pSysfsAccess;
pSysfsAccess = nullptr;
}
DeviceFixture::TearDown();
}
};
TEST_F(SysmanEngineFixture, GivenComponentCountZeroWhenCallingZetSysmanEngineGetThenNonZeroCountIsReturnedAndVerifySysmanEngineGetCallSucceeds) {
zet_sysman_engine_handle_t engineHandle;
uint32_t count = 0;
ze_result_t result = zetSysmanEngineGet(hSysman, &count, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_GT(count, 0u);
uint32_t testcount = count + 1;
result = zetSysmanEngineGet(hSysman, &testcount, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(testcount, count);
result = zetSysmanEngineGet(hSysman, &count, &engineHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, engineHandle);
EXPECT_GT(count, 0u);
}
TEST_F(SysmanEngineFixture, GivenValidEngineHandleWhenCallingZetSysmanEngineGetPropertiesThenVerifySysmanEngineGetPropertiesCallSucceeds) {
zet_engine_properties_t properties;
ze_result_t result = zetSysmanEngineGetProperties(hSysmanEngine, &properties);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(ZES_ENGINE_GROUP_COMPUTE_ALL, properties.type);
EXPECT_FALSE(properties.onSubdevice);
}
TEST_F(SysmanEngineFixture, GivenValidEngineHandleWhenCallingZetSysmanGetActivityThenVerifySysmanEngineGetActivityCallReturnsUnsupportedErrorStatus) {
zet_engine_stats_t Stats;
ze_result_t result = zetSysmanEngineGetActivity(hSysmanEngine, &Stats);
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
}
TEST_F(SysmanEngineFixture, GivenEngineGroupEmptyWhenGettingEngineGroupAndIfRetrievedEngineGroupNotComputeThenErrorReturned) {
zes_engine_group_t engineGroup;
ON_CALL(*pSysfsAccess, read(_, Matcher<std::string &>(_)))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<EngineSysfsAccess>::getIncorrectVal));
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, pEngineImp->pOsEngine->getEngineGroup(engineGroup));
}
} // namespace ult
} // namespace L0

View File

@@ -8,7 +8,6 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_fabric_port.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_fabric_port.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_fabric_device.h
)

View File

@@ -1,245 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/core/test/unit_tests/mock.h"
#include "level_zero/tools/source/sysman/fabric_port/linux/os_fabric_port_imp.h"
#include "level_zero/tools/source/sysman/sysman_imp.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sysman/fabric_port/fabric_port_imp.h"
#include "sysman/linux/os_sysman_imp.h"
#include <limits>
using ::testing::_;
namespace L0 {
namespace ult {
class SysmanFabricPortFixture : public DeviceFixture, public ::testing::Test {
protected:
std::unique_ptr<SysmanImp> sysmanImp;
zet_sysman_handle_t hSysman;
static uint32_t numPorts;
void SetUp() override {
DeviceFixture::SetUp();
sysmanImp = std::make_unique<SysmanImp>(device->toHandle());
hSysman = sysmanImp->toHandle();
sysmanImp->pFabricPortHandleContext->init();
for (uint32_t portNum = 0U; portNum < numPorts; portNum++) {
FabricPort *pFabricPort = new FabricPortImp(sysmanImp->pFabricPortHandleContext->pFabricDevice, portNum);
EXPECT_NE(nullptr, pFabricPort);
sysmanImp->pFabricPortHandleContext->handleList.push_back(pFabricPort);
}
}
void TearDown() override {
// Don't free FabricPorts. The FabricPortHandleContext destructor will free them.
DeviceFixture::TearDown();
}
};
uint32_t SysmanFabricPortFixture::numPorts = 2U;
TEST_F(SysmanFabricPortFixture, GivenPortCountZeroWhenCallingZetSysmanFabricPortGetThenCountIsReturnedAndVerifySysmanFabricPortGetCallSucceeds) {
uint32_t count = 0U;
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, SysmanFabricPortFixture::numPorts);
}
TEST_F(SysmanFabricPortFixture, GivenPortCountZeroAndValidHandlePtrWhenCallingZetSysmanFabricPortGetThenCountIsReturnedAndNoHandlesReturnedAndVerifyFabricPortGetCallSucceeds) {
uint32_t count = 0U;
zes_fabric_port_handle_t handle = static_cast<zes_fabric_port_handle_t>(0UL);
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, &handle);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, SysmanFabricPortFixture::numPorts);
EXPECT_EQ(handle, static_cast<zes_fabric_port_handle_t>(0UL));
}
TEST_F(SysmanFabricPortFixture, GivenPortCountCorrectWhenCallingZetSysmanFabricPortGetThenCountHandlesAreReturnedAndAndVerifySysmanFabricPortGetCallSucceeds) {
uint32_t count = SysmanFabricPortFixture::numPorts;
zes_fabric_port_handle_t hPorts[SysmanFabricPortFixture::numPorts];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, SysmanFabricPortFixture::numPorts);
}
TEST_F(SysmanFabricPortFixture, GivenPortCountGreaterThanPortsWhenCallingZetSysmanFabricPortGetThenCorrectCountisReturnedAndAndVerifySysmanFabricPortGetCallSucceeds) {
uint32_t count = SysmanFabricPortFixture::numPorts + 1U;
zes_fabric_port_handle_t hPorts[SysmanFabricPortFixture::numPorts + 1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, SysmanFabricPortFixture::numPorts);
}
TEST_F(SysmanFabricPortFixture, GivenPortCounLessThanPortsWhenCallingZetSysmanFabricPortGetThenCountLessTanPortsHandlesAreReturned) {
uint32_t count = SysmanFabricPortFixture::numPorts - 1U;
zes_fabric_port_handle_t hPorts[SysmanFabricPortFixture::numPorts - 1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, SysmanFabricPortFixture::numPorts - 1U);
}
TEST_F(SysmanFabricPortFixture, GivenValidFabricPortHandleWhenCallingZetSysmanFabricPortGetPropertiesThenZetSysmanFabricPortGetPropertiesCallSucceeds) {
uint32_t count = 1U;
zes_fabric_port_handle_t hPorts[1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 1U);
zet_fabric_port_properties_t properties;
// Initialize values
properties.onSubdevice = true;
properties.subdeviceId = std::numeric_limits<uint32_t>::max();
std::memset(properties.model, std::numeric_limits<int8_t>::max(), ZES_MAX_FABRIC_PORT_MODEL_SIZE);
std::memset(properties.portUuid.id, std::numeric_limits<uint8_t>::max(), ZES_MAX_FABRIC_PORT_UUID_SIZE);
properties.maxRxSpeed.bitRate = std::numeric_limits<uint64_t>::max();
properties.maxRxSpeed.width = std::numeric_limits<uint32_t>::max();
properties.maxRxSpeed.maxBandwidth = std::numeric_limits<uint64_t>::max();
properties.maxTxSpeed.bitRate = std::numeric_limits<uint64_t>::max();
properties.maxTxSpeed.width = std::numeric_limits<uint32_t>::max();
properties.maxTxSpeed.maxBandwidth = std::numeric_limits<uint64_t>::max();
result = zetSysmanFabricPortGetProperties(hPorts[0], &properties);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_FALSE(properties.onSubdevice);
EXPECT_EQ(0L, properties.subdeviceId);
EXPECT_STREQ("EXAMPLE", reinterpret_cast<char *>(properties.model));
zet_fabric_port_uuid_t expectedUuid = {};
EXPECT_TRUE(0 == std::memcmp(&expectedUuid, properties.portUuid.id, ZES_MAX_FABRIC_PORT_UUID_SIZE));
EXPECT_EQ(0LU, properties.maxRxSpeed.bitRate);
EXPECT_EQ(0U, properties.maxRxSpeed.width);
EXPECT_EQ(0LU, properties.maxRxSpeed.maxBandwidth);
EXPECT_EQ(0LU, properties.maxTxSpeed.bitRate);
EXPECT_EQ(0U, properties.maxTxSpeed.width);
EXPECT_EQ(0LU, properties.maxTxSpeed.maxBandwidth);
}
TEST_F(SysmanFabricPortFixture, GivenValidFabricPortHandleWhenCallingZetSysmanFabricPortGetLinkTypeThenZetSysmanFabricPortGetLinkTypeCallSucceeds) {
uint32_t count = 1U;
zes_fabric_port_handle_t hPorts[1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 1U);
zet_fabric_link_type_t linkType;
bool verbose = true;
result = zetSysmanFabricPortGetLinkType(hPorts[0U], verbose, &linkType);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
verbose = false;
result = zetSysmanFabricPortGetLinkType(hPorts[0U], verbose, &linkType);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_STREQ("SAMPLE LINK", reinterpret_cast<char *>(linkType.desc));
}
TEST_F(SysmanFabricPortFixture, GivenValidFabricPortHandleWhenCallingZetSysmanFabricPortGetConfigThenZetSysmanFabricPortGetConfigCallSucceeds) {
uint32_t count = 1U;
zes_fabric_port_handle_t hPorts[1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 1U);
zet_fabric_port_config_t getConfig = {.enabled = true, .beaconing = true};
result = zetSysmanFabricPortGetConfig(hPorts[0U], &getConfig);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_FALSE(getConfig.enabled);
EXPECT_FALSE(getConfig.beaconing);
}
TEST_F(SysmanFabricPortFixture, GivenValidFabricPortHandleWhenCallingZetSysmanFabricPortSetConfigThenZetSysmanFabricPortGetConfigCallSucceeds) {
uint32_t count = 1U;
zes_fabric_port_handle_t hPorts[1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 1U);
zet_fabric_port_config_t setConfig = {.enabled = true, .beaconing = false};
result = zetSysmanFabricPortSetConfig(hPorts[0U], &setConfig);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
zet_fabric_port_config_t getConfig = {.enabled = false, .beaconing = true};
result = zetSysmanFabricPortGetConfig(hPorts[0U], &getConfig);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_TRUE(getConfig.enabled);
EXPECT_FALSE(getConfig.beaconing);
}
TEST_F(SysmanFabricPortFixture, GivenValidFabricPortHandleWhenCallingZetSysmanFabricPortGetStateThenZetSysmanFabricPortGetStateCallSucceeds) {
uint32_t count = 1U;
zes_fabric_port_handle_t hPorts[1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 1U);
zet_fabric_port_state_t state;
result = zetSysmanFabricPortGetState(hPorts[0U], &state);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(ZET_FABRIC_PORT_STATUS_BLACK, state.status);
EXPECT_EQ(ZET_FABRIC_PORT_QUAL_ISSUES_NONE, state.qualityIssues);
EXPECT_EQ(ZET_FABRIC_PORT_STAB_ISSUES_NONE, state.stabilityIssues);
EXPECT_EQ(0LU, state.rxSpeed.bitRate);
EXPECT_EQ(0U, state.rxSpeed.width);
EXPECT_EQ(0LU, state.rxSpeed.maxBandwidth);
EXPECT_EQ(0LU, state.txSpeed.bitRate);
EXPECT_EQ(0U, state.txSpeed.width);
EXPECT_EQ(0LU, state.txSpeed.maxBandwidth);
}
TEST_F(SysmanFabricPortFixture, GivenValidFabricPortHandleWhenCallingZetSysmanFabricPortGetThroughputThenZetSysmanFabricPortGetThroughputCallSucceeds) {
uint32_t count = 1U;
zes_fabric_port_handle_t hPorts[1U];
ze_result_t result = zetSysmanFabricPortGet(hSysman, &count, hPorts);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 1U);
zet_fabric_port_throughput_t throughput;
// Initialize values
throughput.timestamp = 0LU;
throughput.rxCounter = std::numeric_limits<uint64_t>::max();
throughput.txCounter = std::numeric_limits<uint64_t>::max();
throughput.rxMaxBandwidth = std::numeric_limits<uint64_t>::max();
throughput.txMaxBandwidth = std::numeric_limits<uint64_t>::max();
result = zetSysmanFabricPortGetThroughput(hPorts[0U], &throughput);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(0LU, throughput.timestamp);
EXPECT_EQ(0LU, throughput.rxCounter);
EXPECT_EQ(0LU, throughput.txCounter);
EXPECT_EQ(0LU, throughput.rxMaxBandwidth);
EXPECT_EQ(0LU, throughput.txMaxBandwidth);
}
} // namespace ult
} // namespace L0

View File

@@ -8,7 +8,7 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_frequency.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_frequency.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_frequency.h
)
endif()

View File

@@ -334,240 +334,5 @@ TEST_F(SysmanDeviceFrequencyFixture, GivenThrottleTimeStructPointerWhenCallingfr
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pFrequencyImp->frequencyGetThrottleTime(&throttleTime));
}
class SysmanFrequencyFixture : public DeviceFixture, public ::testing::Test {
protected:
std::unique_ptr<SysmanImp> sysmanImp;
zet_sysman_handle_t hSysman;
zet_sysman_freq_handle_t hSysmanFrequency;
Mock<FrequencySysfsAccess> *pSysfsAccess = nullptr;
OsFrequency *pOsFrequency = nullptr;
FrequencyImp *pFrequencyImp = nullptr;
PublicLinuxFrequencyImp linuxFrequencyImp;
double clockValue(const double calculatedClock) {
// i915 specific. frequency step is a fraction
// However, the i915 represents all clock
// rates as integer values. So clocks are
// rounded to the nearest integer.
uint32_t actualClock = static_cast<uint32_t>(calculatedClock + 0.5);
return static_cast<double>(actualClock);
}
void SetUp() override {
DeviceFixture::SetUp();
sysmanImp = std::make_unique<SysmanImp>(device->toHandle());
pSysfsAccess = new NiceMock<Mock<FrequencySysfsAccess>>;
linuxFrequencyImp.pSysfsAccess = pSysfsAccess;
pOsFrequency = static_cast<OsFrequency *>(&linuxFrequencyImp);
pFrequencyImp = new FrequencyImp();
pFrequencyImp->pOsFrequency = pOsFrequency;
pSysfsAccess->setVal(minFreqFile, minFreq);
pSysfsAccess->setVal(maxFreqFile, maxFreq);
pSysfsAccess->setVal(requestFreqFile, request);
pSysfsAccess->setVal(tdpFreqFile, tdp);
pSysfsAccess->setVal(actualFreqFile, actual);
pSysfsAccess->setVal(efficientFreqFile, efficient);
pSysfsAccess->setVal(maxValFreqFile, maxVal);
pSysfsAccess->setVal(minValFreqFile, minVal);
ON_CALL(*pSysfsAccess, read(_, _))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<FrequencySysfsAccess>::getVal));
ON_CALL(*pSysfsAccess, write(_, _))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<FrequencySysfsAccess>::setVal));
pFrequencyImp->init();
sysmanImp->pFrequencyHandleContext->handleList.push_back(pFrequencyImp);
hSysman = sysmanImp->toHandle();
hSysmanFrequency = pFrequencyImp->toHandle();
}
void TearDown() override {
pFrequencyImp->pOsFrequency = nullptr;
if (pSysfsAccess != nullptr) {
delete pSysfsAccess;
pSysfsAccess = nullptr;
}
DeviceFixture::TearDown();
}
};
TEST_F(SysmanFrequencyFixture, GivenComponentCountZeroWhenCallingzetSysmanFrequencyGetThenNonZeroCountIsReturnedAndVerifyzetSysmanFrequencyGetCallSucceds) {
zet_sysman_freq_handle_t freqHandle;
uint32_t count;
ze_result_t result = zetSysmanFrequencyGet(hSysman, &count, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_GT(count, 0u);
uint32_t testCount = count + 1;
result = zetSysmanFrequencyGet(hSysman, &testCount, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(testCount, count);
result = zetSysmanFrequencyGet(hSysman, &count, &freqHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(freqHandle, nullptr);
EXPECT_GT(count, 0u);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencyGetPropertiesThenVerifyzetSysmanFrequencyGetPropertiesCallSucceeds) {
zet_freq_properties_t properties;
ze_result_t result = zetSysmanFrequencyGetProperties(hSysmanFrequency, &properties);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(ZET_FREQ_DOMAIN_GPU, properties.type);
EXPECT_FALSE(properties.onSubdevice);
EXPECT_DOUBLE_EQ(maxFreq, properties.max);
EXPECT_DOUBLE_EQ(minFreq, properties.min);
EXPECT_TRUE(properties.canControl);
EXPECT_DOUBLE_EQ(step, properties.step);
ASSERT_NE(0.0, properties.step);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleAndZeroCountWhenCallingzetSysmanFrequencyGetAvailableClocksCallSucceeds) {
uint32_t count = 0;
ze_result_t result = zesSysmanFrequencyGetAvailableClocks(hSysmanFrequency, &count, nullptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(numClocks, count);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleAndCorrectCountWhenCallingzetSysmanFrequencyGetAvailableClocksCallSucceeds) {
uint32_t count = 0;
ze_result_t result = zetSysmanFrequencyGetAvailableClocks(hSysmanFrequency, &count, nullptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(numClocks, count);
double *clocks = new double[count];
result = zetSysmanFrequencyGetAvailableClocks(hSysmanFrequency, &count, clocks);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(numClocks, count);
for (uint32_t i = 0; i < count; i++) {
EXPECT_DOUBLE_EQ(clockValue(minFreq + (step * i)), clocks[i]);
}
delete[] clocks;
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencyGetRangeThenVerifyzetSysmanFrequencyGetRangeTestCallSucceeds) {
zet_freq_range_t limits;
ze_result_t result = zetSysmanFrequencyGetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_DOUBLE_EQ(minFreq, limits.min);
EXPECT_DOUBLE_EQ(maxFreq, limits.max);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencySetRangeThenVerifyzetSysmanFrequencySetRangeTest1CallSucceeds) {
const double startingMin = 900.0;
const double newMax = 600.0;
zet_freq_range_t limits;
pSysfsAccess->setVal(minFreqFile, startingMin);
// If the new Max value is less than the old Min
// value, the new Min must be set before the new Max
limits.min = minFreq;
limits.max = newMax;
ze_result_t result = zetSysmanFrequencySetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
result = zetSysmanFrequencyGetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_DOUBLE_EQ(minFreq, limits.min);
EXPECT_DOUBLE_EQ(newMax, limits.max);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencySetRangeThenVerifyzetSysmanFrequencySetRangeTest2CallSucceeds) {
const double startingMax = 600.0;
const double newMin = 900.0;
zet_freq_range_t limits;
pSysfsAccess->setVal(maxFreqFile, startingMax);
// If the new Min value is greater than the old Max
// value, the new Max must be set before the new Min
limits.min = newMin;
limits.max = maxFreq;
ze_result_t result = zetSysmanFrequencySetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
result = zetSysmanFrequencyGetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_DOUBLE_EQ(newMin, limits.min);
EXPECT_DOUBLE_EQ(maxFreq, limits.max);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencySetRangeThenVerifyzetSysmanFrequencySetRangeTest3CallSucceeds) {
zet_freq_range_t limits;
// Verify that Max must be within range.
limits.min = minFreq;
limits.max = clockValue(maxFreq + step);
ze_result_t result = zetSysmanFrequencySetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencySetRangeThenVerifyzetSysmanFrequencySetRangeTest4CallSucceeds) {
zet_freq_range_t limits;
// Verify that Min must be within range.
limits.min = clockValue(minFreq - step);
limits.max = maxFreq;
ze_result_t result = zetSysmanFrequencySetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencySetRangeThenVerifyzetSysmanFrequencySetRangeTest5CallSucceeds) {
zet_freq_range_t limits;
// Verify that values must be multiples of step.
limits.min = clockValue(minFreq + (step * 0.5));
limits.max = maxFreq;
ze_result_t result = zetSysmanFrequencySetRange(hSysmanFrequency, &limits);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
}
TEST_F(SysmanFrequencyFixture, GivenValidFrequencyHandleWhenCallingzetSysmanFrequencyGetStateThenVerifyzetSysmanFrequencyGetStateTestCallSucceeds) {
const double testRequestValue = 450.0;
const double testTdpValue = 1200.0;
const double testEfficientValue = 400.0;
const double testActualValue = 550.0;
zet_freq_state_t state;
pSysfsAccess->setVal(requestFreqFile, testRequestValue);
pSysfsAccess->setVal(tdpFreqFile, testTdpValue);
pSysfsAccess->setVal(actualFreqFile, testActualValue);
pSysfsAccess->setVal(efficientFreqFile, testEfficientValue);
ze_result_t result = zetSysmanFrequencyGetState(hSysmanFrequency, &state);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_DOUBLE_EQ(testRequestValue, state.request);
EXPECT_DOUBLE_EQ(testTdpValue, state.tdp);
EXPECT_DOUBLE_EQ(testEfficientValue, state.efficient);
EXPECT_DOUBLE_EQ(testActualValue, state.actual);
EXPECT_EQ(0u, state.throttleReasons);
}
} // namespace ult
} // namespace L0

View File

@@ -7,8 +7,8 @@
if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_global_operations.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_global_operations.h
# ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
# ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_global_operations.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_global_operations.h
)
endif()

View File

@@ -6,13 +6,13 @@
if(SUPPORT_DG1)
set(L0_TESTS_TOOLS_SYSMAN_MEMORY_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/dg1/test_sysman_memory.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
# ${CMAKE_CURRENT_SOURCE_DIR}/dg1/test_sysman_memory.cpp
)
else()
set(L0_TESTS_TOOLS_SYSMAN_MEMORY_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_memory.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
# ${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_memory.cpp
)
endif()

View File

@@ -7,8 +7,8 @@
if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_pci.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_pci.h
# ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
# ${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_pci.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_pci.h
)
endif()

View File

@@ -8,7 +8,7 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_power.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_power.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_power.h
)
endif()

View File

@@ -97,80 +97,5 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerEnergyThre
}
}
class SysmanPowerFixture : public DeviceFixture, public ::testing::Test {
protected:
std::unique_ptr<SysmanDeviceImp> sysmanImp;
zet_sysman_handle_t hSysman;
zes_pwr_handle_t hSysmanPowerHandle;
Mock<PowerPmt> *pPmt = nullptr;
PowerImp *pPowerImp = nullptr;
PublicLinuxPowerImp linuxPowerImp;
void SetUp() override {
DeviceFixture::SetUp();
sysmanImp = std::make_unique<SysmanDeviceImp>(device->toHandle());
pPmt = new NiceMock<Mock<PowerPmt>>;
OsPower *pOsPower = nullptr;
pPmt->init(deviceName, pFsAccess);
linuxPowerImp.pPmt = pPmt;
pOsPower = static_cast<OsPower *>(&linuxPowerImp);
pPowerImp = new PowerImp();
pPowerImp->pOsPower = pOsPower;
pPowerImp->init();
sysmanImp->pPowerHandleContext->handleList.push_back(pPowerImp);
hSysman = sysmanImp->toHandle();
hSysmanPowerHandle = pPowerImp->toHandle();
}
void TearDown() override {
// pOsPower is static_cast of LinuxPowerImp class , hence in cleanup assign to nullptr
pPowerImp->pOsPower = nullptr;
if (pPmt != nullptr) {
delete pPmt;
pPmt = nullptr;
}
DeviceFixture::TearDown();
}
};
TEST_F(SysmanPowerFixture, GivenComponentCountZeroWhenCallingZetSysmanPowerGetThenZeroCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) {
uint32_t count = 0;
ze_result_t result = zetSysmanPowerGet(hSysman, &count, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(count, 1u);
uint32_t testcount = count + 1;
result = zetSysmanPowerGet(hSysman, &testcount, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(testcount, count);
}
TEST_F(SysmanPowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCounterThenValidPowerReadingsRetrieved) {
zes_power_energy_counter_t energyCounter;
uint64_t expectedEnergyCounter = convertJouleToMicroJoule * setEnergyCounter;
ASSERT_EQ(ZE_RESULT_SUCCESS, zetSysmanPowerGetEnergyCounter(hSysmanPowerHandle, &energyCounter));
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
}
TEST_F(SysmanPowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyThresholdThenUnsupportedFeatureErrorIsReturned) {
zes_energy_threshold_t threshold;
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zetSysmanPowerGetEnergyThreshold(hSysmanPowerHandle, &threshold));
}
TEST_F(SysmanPowerFixture, GivenValidPowerHandleWhenSettingPowerEnergyThresholdThenUnsupportedFeatureErrorIsReturned) {
double threshold = 0;
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zetSysmanPowerSetEnergyThreshold(hSysmanPowerHandle, threshold));
}
} // namespace ult
} // namespace L0

View File

@@ -7,8 +7,8 @@
if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_ras.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_fs_ras.h
# ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
# ${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_ras.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/mock_fs_ras.h
)
endif()

View File

@@ -7,8 +7,8 @@
if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_scheduler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_scheduler.h
# ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
# ${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_scheduler.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_scheduler.h
)
endif()

View File

@@ -8,7 +8,6 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_standby.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_standby.h
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_sysman_standby.cpp

View File

@@ -1,123 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/tools/source/sysman/standby/linux/os_standby_imp.h"
#include "level_zero/tools/source/sysman/sysman_imp.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mock_sysfs_standby.h"
#include "sysman/standby/os_standby.h"
#include <cmath>
using ::testing::_;
using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::Matcher;
using ::testing::NiceMock;
using ::testing::Return;
namespace L0 {
namespace ult {
constexpr int standbyModeDefault = 1;
class SysmanStandbyFixture : public DeviceFixture, public ::testing::Test {
protected:
std::unique_ptr<SysmanDeviceImp> sysmanImp;
zet_sysman_handle_t hSysman;
zet_sysman_standby_handle_t hSysmanStandby;
Mock<StandbySysfsAccess> *pSysfsAccess = nullptr;
OsStandby *pOsStandby = nullptr;
PublicLinuxStandbyImp linuxStandbyImp;
StandbyImp *pStandbyImp = nullptr;
void SetUp() override {
DeviceFixture::SetUp();
sysmanImp = std::make_unique<SysmanDeviceImp>(device->toHandle());
pSysfsAccess = new NiceMock<Mock<StandbySysfsAccess>>;
linuxStandbyImp.pSysfsAccess = pSysfsAccess;
pOsStandby = static_cast<OsStandby *>(&linuxStandbyImp);
pStandbyImp = new StandbyImp();
pStandbyImp->pOsStandby = pOsStandby;
pSysfsAccess->setVal(standbyModeFile, standbyModeDefault);
ON_CALL(*pSysfsAccess, read(_, Matcher<int &>(_)))
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<StandbySysfsAccess>::getVal));
pStandbyImp->init();
sysmanImp->pStandbyHandleContext->handleList.push_back(pStandbyImp);
hSysman = sysmanImp->toHandle();
hSysmanStandby = pStandbyImp->toHandle();
}
void TearDown() override {
pStandbyImp->pOsStandby = nullptr;
if (pSysfsAccess != nullptr) {
delete pSysfsAccess;
pSysfsAccess = nullptr;
}
DeviceFixture::TearDown();
}
};
TEST_F(SysmanStandbyFixture, GivenComponentCountZeroWhenCallingzetSysmanStandbyGetThenNonZeroCountIsReturnedAndVerifyzetSysmanStandbyGetCallSucceeds) {
zet_sysman_standby_handle_t standbyHandle;
uint32_t count;
ze_result_t result = zetSysmanStandbyGet(hSysman, &count, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_GT(count, 0u);
uint32_t testCount = count + 1;
result = zetSysmanStandbyGet(hSysman, &testCount, NULL);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(testCount, count);
result = zetSysmanStandbyGet(hSysman, &count, &standbyHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, standbyHandle);
EXPECT_GT(count, 0u);
}
TEST_F(SysmanStandbyFixture, GivenValidStandbyHandleWhenCallingzetSysmanStandbyGetPropertiesThenVerifyzetSysmanStandbyGetPropertiesCallSucceeds) {
zet_standby_properties_t properties;
ze_result_t result = zetSysmanStandbyGetProperties(hSysmanStandby, &properties);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(ZES_STANDBY_TYPE_GLOBAL, properties.type);
EXPECT_FALSE(properties.onSubdevice);
}
TEST_F(SysmanStandbyFixture, GivenValidStandbyHandleWhenCallingzetSysmanStandbyGetModeThenVerifyzetSysmanStandbyGetModeCallSucceeds) {
zes_standby_promo_mode_t mode;
ze_result_t result = zetSysmanStandbyGetMode(hSysmanStandby, &mode);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(ZES_STANDBY_PROMO_MODE_DEFAULT, mode);
}
TEST_F(SysmanStandbyFixture, GivenValidStandbyHandleWhenCallingzetSysmanStandbySetModeThenVerifySysmanzetStandbySetModeCallSucceeds) {
ze_result_t result = zetSysmanStandbySetMode(hSysmanStandby, ZES_STANDBY_PROMO_MODE_NEVER);
EXPECT_EQ(result, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
} // namespace ult
} // namespace L0

View File

@@ -8,7 +8,6 @@ if(UNIX)
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_temperature.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_temperature.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_temperature.h
)

View File

@@ -12,15 +12,6 @@
namespace L0 {
namespace ult {
using SysmanGetTest = Test<DeviceFixture>;
TEST_F(SysmanGetTest, whenCallingZetSysmanGetWithoutCallingZetInitThenUnitializedIsReturned) {
zet_sysman_handle_t hSysman;
ze_result_t res = zetSysmanGet(device->toHandle(), &hSysman);
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, res);
}
using MockDeviceSysmanGetTest = Test<DeviceFixture>;
TEST_F(MockDeviceSysmanGetTest, GivenValidSysmanHandleSetInDeviceStructWhenGetThisSysmanHandleThenHandlesShouldBeSimilar) {
SysmanDeviceImp *sysman = new SysmanDeviceImp(device->toHandle());

View File

@@ -26,8 +26,6 @@ namespace ult {
class SysmanKmdManagerFixture : public ::testing::Test {
protected:
std::unique_ptr<SysmanImp> sysmanImp;
zet_sysman_handle_t hSysman;
Mock<MockKmdSysManager> *pKmdSysManager = nullptr;
OsSysman *pOsSysman = nullptr;
PublicWddmSysmanImp wddmSysmanImp;