1313#include " shared/source/os_interface/os_interface.h"
1414#include " shared/test/common/helpers/debug_manager_state_restore.h"
1515#include " shared/test/common/helpers/engine_descriptor_helper.h"
16- #include " shared/test/common/libult/linux/drm_mock.h"
1716#include " shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
1817#include " shared/test/common/mocks/mock_execution_environment.h"
1918#include " shared/test/common/os_interface/linux/device_command_stream_fixture.h"
@@ -33,7 +32,7 @@ class DrmCommandStreamTest : public ::testing::Test {
3332 // make sure this is disabled, we don't want to test this now
3433 DebugManager.flags .EnableForcePin .set (false );
3534
36- mock = new DrmMock (mockFd, *executionEnvironment.rootDeviceEnvironments [0 ]);
35+ mock = new ::testing::NiceMock<DrmMockImpl> (mockFd, *executionEnvironment.rootDeviceEnvironments [0 ]);
3736 auto hwInfo = executionEnvironment.rootDeviceEnvironments [0 ]->getHardwareInfo ();
3837 mock->setupIoctlHelper (hwInfo->platform .eProductFamily );
3938
@@ -51,37 +50,34 @@ class DrmCommandStreamTest : public ::testing::Test {
5150 ASSERT_NE (nullptr , csr);
5251 csr->setupContext (*osContext);
5352
54- mock->ioctlCallsCount = 0u ;
53+ // Memory manager creates pinBB with ioctl, expect one call
54+ EXPECT_CALL (*mock, ioctl (::testing::_, ::testing::_))
55+ .Times (1 );
5556 memoryManager = new DrmMemoryManager (gemCloseWorkerMode::gemCloseWorkerActive,
5657 DebugManager.flags .EnableForcePin .get (),
5758 true ,
5859 executionEnvironment);
5960 executionEnvironment.memoryManager .reset (memoryManager);
60- // Memory manager creates pinBB with ioctl, expect one call
61- EXPECT_EQ (1u , mock->ioctlCallsCount );
61+ ::testing::Mock::VerifyAndClearExpectations (mock);
6262
6363 // assert we have memory manager
6464 ASSERT_NE (nullptr , memoryManager);
65- mock->ioctlRequestCallCount .clear ();
6665 }
6766
6867 template <typename GfxFamily>
6968 void TearDownT () {
7069 memoryManager->waitForDeletions ();
7170 memoryManager->peekGemCloseWorker ()->close (true );
7271 delete csr;
73- for (const auto &kv : mock->tearDownIoctlRequestExpects ) {
74- EXPECT_EQ (kv.first , mock->ioctlRequestCallCount [kv.second ]);
75- }
76- // Expect 1 call with DRM_IOCTL_I915_GEM_CONTEXT_DESTROY request on destroyDrmContext
77- // Expect 1 call with DRM_IOCTL_GEM_CLOSE request on BufferObject close
78- mock->expectedIoctlCallsOnDestruction = mock->ioctlCallsCount + 2 ;
79- mock->expectIoctlCallsOnDestruction = true ;
72+ ::testing::Mock::VerifyAndClearExpectations (mock);
73+ // Memory manager closes pinBB with ioctl, expect one call
74+ EXPECT_CALL (*mock, ioctl (::testing::_, ::testing::_))
75+ .Times (::testing::AtLeast (1 ));
8076 }
8177
8278 CommandStreamReceiver *csr = nullptr ;
8379 DrmMemoryManager *memoryManager = nullptr ;
84- DrmMock *mock = nullptr ;
80+ ::testing::NiceMock<DrmMockImpl> *mock;
8581 const int mockFd = 33 ;
8682 static const uint64_t alignment = MemoryConstants::allocationAlignment;
8783 DebugManagerStateRestore dbgState;
0 commit comments