From 6102f02080fc64f7275d0e232761ed6a197b9b37 Mon Sep 17 00:00:00 2001 From: Bellekallu Rajkiran Date: Wed, 21 Sep 2022 09:07:37 +0000 Subject: [PATCH] Refactor sysman ULTs Related-To: LOCI-3432 Signed-off-by: Bellekallu Rajkiran --- .../sysman/memory/linux/test_sysman_memory.cpp | 10 +++++----- .../sysman/memory/linux/test_sysman_memory_dg1.cpp | 12 ++++++------ .../sources/sysman/power/linux/mock_sysfs_power.h | 5 +++++ .../sysman/power/linux/mock_sysfs_power_prelim.h | 5 +++++ .../sysman/power/linux/test_zes_power_prelim.cpp | 5 ----- .../temperature/linux/test_zes_temperature.cpp | 5 +++++ 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory.cpp b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory.cpp index b1523f2f7a..a29ef4fe63 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory.cpp @@ -92,14 +92,14 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture { MemoryManager *pMemoryManagerOld; }; -TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) { setLocalSupportedAndReinit(false); uint32_t count = 0; EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS); EXPECT_EQ(count, 0u); } -TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) { setLocalSupportedAndReinit(false); uint32_t count = 0; EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS); @@ -110,14 +110,14 @@ TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemor EXPECT_EQ(count, 0u); } -TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenValidCountIsReturned) { setLocalSupportedAndReinit(true); uint32_t count = 0; EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS); EXPECT_EQ(count, memoryHandleComponentCount); } -TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenValidCountIsReturned) { setLocalSupportedAndReinit(true); uint32_t count = 0; EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS); @@ -128,7 +128,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemor EXPECT_EQ(count, memoryHandleComponentCount); } -TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesThenValidPowerHandlesIsReturned) { +TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesThenValidHandlesIsReturned) { setLocalSupportedAndReinit(true); uint32_t count = 0; EXPECT_EQ(zesDeviceEnumMemoryModules(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_dg1.cpp b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_dg1.cpp index ca032e9bf7..fe845de0ec 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_dg1.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_dg1.cpp @@ -109,7 +109,7 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture { MemoryManager *pMemoryManagerOld; }; -TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) { setLocalSupportedAndReinit(true); uint32_t count = 0; @@ -117,7 +117,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryMo EXPECT_EQ(count, memoryHandleComponentCount); } -TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) { setLocalSupportedAndReinit(true); uint32_t count = 0; @@ -129,7 +129,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemor EXPECT_EQ(count, memoryHandleComponentCount); } -TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidPowerHandlesIsReturned) { +TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidHandlesIsReturned) { setLocalSupportedAndReinit(true); uint32_t count = 0; @@ -143,7 +143,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryMo } } -TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenZeroCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenZeroCountIsReturned) { setLocalSupportedAndReinit(false); uint32_t count = 0; @@ -151,7 +151,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryMo EXPECT_EQ(count, 0u); } -TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenZeroCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { +TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenZeroCountIsReturned) { setLocalSupportedAndReinit(false); uint32_t count = 0; @@ -163,7 +163,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenInvalidComponentCountWhenEnumeratingMemor EXPECT_EQ(count, 0u); } -TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenValidPowerHandlesIsReturned) { +TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithNoLocalMemorySupportThenValidHandlesIsReturned) { setLocalSupportedAndReinit(false); uint32_t count = 0; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h index d5e9b3f315..73b922192e 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power.h @@ -344,6 +344,7 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture { SysfsAccess *pSysfsAccessOld = nullptr; FsAccess *pFsAccessOriginal = nullptr; OsPower *pOsPowerOriginal = nullptr; + std::map pmtMapOriginal; std::vector deviceHandles; void SetUp() override { if (!sysmanUltsEnable) { @@ -379,6 +380,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture { Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data()); } + pmtMapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject; + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear(); for (auto &deviceHandle : deviceHandles) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; Device::fromHandle(deviceHandle)->getProperties(&deviceProperties); @@ -395,6 +398,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture { if (!sysmanUltsEnable) { GTEST_SKIP(); } + pLinuxSysmanImp->releasePmtObject(); + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject = pmtMapOriginal; pLinuxSysmanImp->pFsAccess = pFsAccessOriginal; pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOld; SysmanDeviceFixture::TearDown(); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power_prelim.h b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power_prelim.h index 4dbb2c47eb..c40c6f237b 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power_prelim.h +++ b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/mock_sysfs_power_prelim.h @@ -304,6 +304,7 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture { FsAccess *pFsAccessOriginal = nullptr; OsPower *pOsPowerOriginal = nullptr; std::vector deviceHandles; + std::map pmtMapOriginal; void SetUp() override { if (!sysmanUltsEnable) { GTEST_SKIP(); @@ -323,6 +324,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture { deviceHandles.resize(subDeviceCount, nullptr); Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data()); } + pmtMapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject; + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear(); for (auto &deviceHandle : deviceHandles) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; Device::fromHandle(deviceHandle)->getProperties(&deviceProperties); @@ -338,6 +341,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture { if (!sysmanUltsEnable) { GTEST_SKIP(); } + pLinuxSysmanImp->releasePmtObject(); + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject = pmtMapOriginal; pLinuxSysmanImp->pFsAccess = pFsAccessOriginal; pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOld; SysmanDeviceFixture::TearDown(); diff --git a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/test_zes_power_prelim.cpp b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/test_zes_power_prelim.cpp index b003e65b59..84d8033ed0 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/power/linux/test_zes_power_prelim.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/power/linux/test_zes_power_prelim.cpp @@ -43,11 +43,6 @@ TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDoma EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS); EXPECT_EQ(count, powerHandleComponentCount); } -TEST_F(SysmanDeviceFixture, GivenComponentCountZeroWhenEnumeratingPowerDomainsWhenhwmonInterfaceDoesNotExistThenZeroCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { - uint32_t count = 0; - EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS); - EXPECT_EQ(count, 0u); -} TEST_F(SysmanDevicePowerFixture, GivenInvalidComponentCountWhenEnumeratingPowerDomainsWhenhwmonInterfaceExistsThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) { uint32_t count = 0; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp b/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp index 018b0a90ab..ecc1084a0f 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/temperature/linux/test_zes_temperature.cpp @@ -265,6 +265,7 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture { FsAccess *pFsAccessOriginal = nullptr; std::vector deviceHandles; PRODUCT_FAMILY productFamily; + std::map pmtMapOriginal; void SetUp() override { if (!sysmanUltsEnable) { GTEST_SKIP(); @@ -283,6 +284,8 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture { Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data()); } + pmtMapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject; + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear(); for (auto &deviceHandle : deviceHandles) { ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; Device::fromHandle(deviceHandle)->getProperties(&deviceProperties); @@ -302,6 +305,8 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture { if (!sysmanUltsEnable) { GTEST_SKIP(); } + pLinuxSysmanImp->releasePmtObject(); + pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject = pmtMapOriginal; pLinuxSysmanImp->pFsAccess = pFsAccessOriginal; SysmanDeviceFixture::TearDown(); }