Ensure that ioctl helper is initialized only once

Related-To: NEO-6999
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-06-08 15:12:31 +02:00
committed by Compute-Runtime-Automation
parent de75e51228
commit ffe77d06e3
8 changed files with 20 additions and 21 deletions

View File

@@ -20,6 +20,7 @@ class DrmTipMock : public DrmMock {
DrmTipMock(RootDeviceEnvironment &rootDeviceEnvironment) : DrmTipMock(rootDeviceEnvironment, defaultHwInfo.get()) {}
DrmTipMock(RootDeviceEnvironment &rootDeviceEnvironment, const HardwareInfo *inputHwInfo) : DrmMock(rootDeviceEnvironment) {
rootDeviceEnvironment.setHwInfo(inputHwInfo);
ioctlHelper.reset();
setupIoctlHelper(inputHwInfo->platform.eProductFamily);
}

View File

@@ -1148,7 +1148,7 @@ TEST(DrmTest, GivenBatchPendingGreaterThanZeroResetStatsWhenIsGpuHangIsCalledThe
EXPECT_TRUE(isGpuHangDetected);
}
TEST(DrmTest, givenSetupIoctlHelperThenIoctlHelperNotNull) {
TEST(DrmTest, givenSetupIoctlHelperWhenCalledTwiceThenIoctlHelperIsSetOnlyOnce) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
@@ -1159,6 +1159,9 @@ TEST(DrmTest, givenSetupIoctlHelperThenIoctlHelperNotNull) {
drm.setupIoctlHelper(productFamily);
EXPECT_NE(nullptr, drm.ioctlHelper.get());
auto ioctlHelper = drm.ioctlHelper.get();
drm.setupIoctlHelper(productFamily);
EXPECT_EQ(ioctlHelper, drm.ioctlHelper.get());
}
TEST(DrmWrapperTest, WhenGettingDrmIoctlGetparamValueThenIoctlHelperIsNotNeeded) {

View File

@@ -46,7 +46,7 @@ class IoctlHelperPrelimFixture : public ::testing::Test {
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
drm = std::make_unique<DrmPrelimMock>(*executionEnvironment->rootDeviceEnvironments[0]);
drm->setupIoctlHelper(executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.eProductFamily);
drm->ioctlHelper = std::make_unique<IoctlHelperPrelim20>();
}
std::unique_ptr<ExecutionEnvironment> executionEnvironment;

View File

@@ -106,6 +106,11 @@ TEST_F(IoctlPrelimHelperTests, givenPrelimsWhenTranslateToMemoryRegionsThenRetur
}
}
TEST_F(IoctlPrelimHelperTests, whenCloneIsCalledThenValidPtrIsReturned) {
std::unique_ptr<IoctlHelper> cloned(ioctlHelper.clone());
EXPECT_NE(nullptr, cloned);
}
TEST_F(IoctlPrelimHelperTests, givenEmptyRegionInstanceClassWhenCreatingVmControlRegionExtThenNullptrIsReturned) {
std::optional<MemoryClassInstance> regionInstanceClass{};