Skip to content

Commit ab6af42

Browse files
Add missing tests for hw info config dg1
Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 78d75de commit ab6af42

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

shared/test/unit_test/gen12lp/dg1/linux/hw_info_config_tests_dg1.cpp

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
#include "shared/source/gen12lp/hw_cmds_dg1.h"
1010
#include "shared/source/os_interface/hw_info_config.h"
1111
#include "shared/source/os_interface/os_interface.h"
12-
#include "shared/test/common/helpers/hw_helper_tests.h"
12+
#include "shared/test/common/helpers/default_hw_info.h"
13+
#include "shared/test/common/helpers/gtest_helpers.h"
1314
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
1415
#include "shared/test/common/test_macros/test.h"
16+
#include "shared/test/unit_test/os_interface/linux/hw_info_config_linux_tests.h"
1517

16-
using HwHelperTestGen12Lp = HwHelperTest;
18+
using HwInfoConfigTestLinuxDg1 = ::testing::Test;
19+
using namespace NEO;
1720

18-
DG1TEST_F(HwHelperTestGen12Lp, GivenDG1WhenConfigureHardwareCustomThenMTPIsNotSet) {
21+
DG1TEST_F(HwInfoConfigTestLinuxDg1, GivenDG1WhenConfigureHardwareCustomThenMTPIsNotSet) {
22+
HardwareInfo hardwareInfo = *defaultHwInfo;
1923
HwInfoConfig *hwInfoConfig = HwInfoConfig::get(hardwareInfo.platform.eProductFamily);
2024

2125
OSInterface osIface;
@@ -26,11 +30,74 @@ DG1TEST_F(HwHelperTestGen12Lp, GivenDG1WhenConfigureHardwareCustomThenMTPIsNotSe
2630
EXPECT_FALSE(hardwareInfo.featureTable.flags.ftrGpGpuMidThreadLevelPreempt);
2731
}
2832

29-
DG1TEST_F(HwHelperTestGen12Lp, GivenDG1WhenConfigureHardwareCustomThenKmdNotifyIsEnabled) {
33+
DG1TEST_F(HwInfoConfigTestLinuxDg1, GivenDG1WhenConfigureHardwareCustomThenKmdNotifyIsEnabled) {
34+
HardwareInfo hardwareInfo = *defaultHwInfo;
3035
HwInfoConfig *hwInfoConfig = HwInfoConfig::get(hardwareInfo.platform.eProductFamily);
3136

3237
OSInterface osIface;
3338
hwInfoConfig->configureHardwareCustom(&hardwareInfo, &osIface);
3439
EXPECT_TRUE(hardwareInfo.capabilityTable.kmdNotifyProperties.enableKmdNotify);
3540
EXPECT_EQ(300ll, hardwareInfo.capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);
3641
}
42+
43+
struct HwInfoConfigTestsLinuxDg1 : HwInfoConfigTestLinux {
44+
void SetUp() override {
45+
HwInfoConfigTestLinux::SetUp();
46+
47+
drm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
48+
osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
49+
}
50+
};
51+
52+
DG1TEST_F(HwInfoConfigTestsLinuxDg1, WhenConfiguringHwInfoThenInfoIsSetCorrectly) {
53+
auto hwInfoConfig = HwInfoConfig::get(productFamily);
54+
int ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
55+
EXPECT_EQ(0, ret);
56+
EXPECT_EQ(static_cast<uint32_t>(drm->storedEUVal), outHwInfo.gtSystemInfo.EUCount);
57+
EXPECT_EQ(static_cast<uint32_t>(drm->storedSSVal), outHwInfo.gtSystemInfo.SubSliceCount);
58+
EXPECT_EQ(1u, outHwInfo.gtSystemInfo.SliceCount);
59+
60+
EXPECT_FALSE(outHwInfo.featureTable.flags.ftrTileY);
61+
}
62+
63+
DG1TEST_F(HwInfoConfigTestsLinuxDg1, GivenInvalidDeviceIdWhenConfiguringHwInfoThenErrorIsReturned) {
64+
auto hwInfoConfig = HwInfoConfig::get(productFamily);
65+
66+
drm->failRetTopology = true;
67+
drm->storedRetValForEUVal = -1;
68+
auto ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
69+
EXPECT_EQ(-1, ret);
70+
71+
drm->storedRetValForEUVal = 0;
72+
drm->storedRetValForSSVal = -1;
73+
ret = hwInfoConfig->configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
74+
EXPECT_EQ(-1, ret);
75+
}
76+
77+
template <typename T>
78+
class Dg1HwInfoTests : public ::testing::Test {};
79+
using dg1TestTypes = ::testing::Types<Dg1HwConfig>;
80+
TYPED_TEST_CASE(Dg1HwInfoTests, dg1TestTypes);
81+
TYPED_TEST(Dg1HwInfoTests, WhenGtIsSetupThenGtSystemInfoIsCorrect) {
82+
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
83+
executionEnvironment->prepareRootDeviceEnvironments(1);
84+
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
85+
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
86+
87+
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
88+
DeviceDescriptor device = {0, &TypeParam::hwInfo, &TypeParam::setupHardwareInfo};
89+
const auto &gtSystemInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo;
90+
91+
int ret = drm.setupHardwareInfo(&device, false);
92+
93+
EXPECT_EQ(ret, 0);
94+
EXPECT_GT(gtSystemInfo.EUCount, 0u);
95+
EXPECT_GT(gtSystemInfo.ThreadCount, 0u);
96+
EXPECT_GT(gtSystemInfo.SliceCount, 0u);
97+
EXPECT_GT(gtSystemInfo.SubSliceCount, 0u);
98+
EXPECT_GT_VAL(gtSystemInfo.L3CacheSizeInKb, 0u);
99+
EXPECT_EQ(gtSystemInfo.CsrSizeInMb, 8u);
100+
EXPECT_FALSE(gtSystemInfo.IsDynamicallyPopulated);
101+
EXPECT_GT(gtSystemInfo.DualSubSliceCount, 0u);
102+
EXPECT_GT(gtSystemInfo.MaxDualSubSlicesSupported, 0u);
103+
}

0 commit comments

Comments
 (0)