mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
ULT: Add sysman device ults to improve code coverage
Related-To: LOCI-2120 Signed-off-by: Pichika Uday Kiran <pichika.uday.kiran@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ed5771f132
commit
4cd7be6670
@@ -38,6 +38,7 @@ class PublicLinuxSysmanImp : public L0::LinuxSysmanImp {
|
||||
using LinuxSysmanImp::pPmuInterface;
|
||||
using LinuxSysmanImp::pProcfsAccess;
|
||||
using LinuxSysmanImp::pSysfsAccess;
|
||||
using LinuxSysmanImp::pXmlParser;
|
||||
};
|
||||
|
||||
class SysmanDeviceFixture : public DeviceFixture, public ::testing::Test {
|
||||
|
||||
@@ -20,6 +20,51 @@ inline static int mockAccessSuccess(const char *pathname, int mode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenValidDeviceHandleInSysmanImpCreationWhenAllSysmanInterfacesAreAssignedToNullThenExpectSysmanDeviceModuleContextsAreNull) {
|
||||
ze_device_handle_t hSysman = device->toHandle();
|
||||
SysmanDeviceImp *sysmanImp = new SysmanDeviceImp(hSysman);
|
||||
|
||||
delete (sysmanImp->pPowerHandleContext);
|
||||
delete (sysmanImp->pFrequencyHandleContext);
|
||||
delete (sysmanImp->pFabricPortHandleContext);
|
||||
delete (sysmanImp->pTempHandleContext);
|
||||
delete (sysmanImp->pPci);
|
||||
delete (sysmanImp->pStandbyHandleContext);
|
||||
delete (sysmanImp->pEngineHandleContext);
|
||||
delete (sysmanImp->pSchedulerHandleContext);
|
||||
delete (sysmanImp->pRasHandleContext);
|
||||
delete (sysmanImp->pMemoryHandleContext);
|
||||
delete (sysmanImp->pGlobalOperations);
|
||||
delete (sysmanImp->pEvents);
|
||||
delete (sysmanImp->pFanHandleContext);
|
||||
delete (sysmanImp->pFirmwareHandleContext);
|
||||
delete (sysmanImp->pDiagnosticsHandleContext);
|
||||
delete (sysmanImp->pPerformanceHandleContext);
|
||||
|
||||
sysmanImp->pPowerHandleContext = nullptr;
|
||||
sysmanImp->pFrequencyHandleContext = nullptr;
|
||||
sysmanImp->pFabricPortHandleContext = nullptr;
|
||||
sysmanImp->pTempHandleContext = nullptr;
|
||||
sysmanImp->pPci = nullptr;
|
||||
sysmanImp->pStandbyHandleContext = nullptr;
|
||||
sysmanImp->pEngineHandleContext = nullptr;
|
||||
sysmanImp->pSchedulerHandleContext = nullptr;
|
||||
sysmanImp->pRasHandleContext = nullptr;
|
||||
sysmanImp->pMemoryHandleContext = nullptr;
|
||||
sysmanImp->pGlobalOperations = nullptr;
|
||||
sysmanImp->pEvents = nullptr;
|
||||
sysmanImp->pFanHandleContext = nullptr;
|
||||
sysmanImp->pFirmwareHandleContext = nullptr;
|
||||
sysmanImp->pDiagnosticsHandleContext = nullptr;
|
||||
sysmanImp->pPerformanceHandleContext = nullptr;
|
||||
|
||||
sysmanImp->init();
|
||||
// all sysman module contexts are null. Validating PowerHandleContext instead of all contexts
|
||||
EXPECT_EQ(sysmanImp->pPowerHandleContext, nullptr);
|
||||
delete sysmanImp;
|
||||
sysmanImp = nullptr;
|
||||
}
|
||||
|
||||
using MockDeviceSysmanGetTest = Test<DeviceFixture>;
|
||||
TEST_F(MockDeviceSysmanGetTest, GivenValidSysmanHandleSetInDeviceStructWhenGetThisSysmanHandleThenHandlesShouldBeSimilar) {
|
||||
SysmanDeviceImp *sysman = new SysmanDeviceImp(device->toHandle());
|
||||
@@ -130,6 +175,26 @@ TEST_F(SysmanDeviceFixture, GivenPmuInterfaceHandleWhenCallinggetPmuInterfaceThe
|
||||
EXPECT_EQ(pLinuxSysmanImp->getPmuInterface(), pLinuxSysmanImp->pPmuInterface);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenXmlParserHandleWhenCallinggetXmlParserThenCreatedXmlParserHandleWillBeRetrieved) {
|
||||
if (pLinuxSysmanImp->pXmlParser != nullptr) {
|
||||
//delete previously allocated XmlParser
|
||||
delete pLinuxSysmanImp->pXmlParser;
|
||||
pLinuxSysmanImp->pXmlParser = nullptr;
|
||||
}
|
||||
pLinuxSysmanImp->pXmlParser = XmlParser::create();
|
||||
EXPECT_EQ(pLinuxSysmanImp->getXmlParser(), pLinuxSysmanImp->pXmlParser);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenFwUtilInterfaceHandleWhenCallinggetFwUtilInterfaceThenCreatedFwUtilInterfaceHandleWillBeRetrieved) {
|
||||
if (pLinuxSysmanImp->pFwUtilInterface != nullptr) {
|
||||
//delete previously allocated FwUtilInterface
|
||||
delete pLinuxSysmanImp->pFwUtilInterface;
|
||||
pLinuxSysmanImp->pFwUtilInterface = nullptr;
|
||||
}
|
||||
pLinuxSysmanImp->pFwUtilInterface = FirmwareUtil::create();
|
||||
EXPECT_EQ(pLinuxSysmanImp->getFwUtilInterface(), pLinuxSysmanImp->pFwUtilInterface);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingRootPciPortThenReturnedPathIs2LevelUpThenTheCurrentPath) {
|
||||
const std::string mockBdf = "0000:00:02.0";
|
||||
const std::string mockRealPath = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/" + mockBdf;
|
||||
|
||||
@@ -483,6 +483,11 @@ TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetStateThenV
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDevicePciGetState(device, &state));
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetStatsThenVerifyzetSysmanPciGetStatsCallReturnNotSupported) {
|
||||
zes_pci_stats_t stats;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDevicePciGetStats(device, &stats));
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, WhenConvertingLinkSpeedThenResultIsCorrect) {
|
||||
for (int32_t i = PciGenerations::PciGen1; i <= PciGenerations::PciGen5; i++) {
|
||||
double speed = convertPciGenToLinkSpeed(i);
|
||||
|
||||
Reference in New Issue
Block a user