Skip to content

Commit 37f16ac

Browse files
Remove gmock from mock command queue and mock sampler
Related-To: NEO-4914 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 60677e2 commit 37f16ac

File tree

3 files changed

+13
-63
lines changed

3 files changed

+13
-63
lines changed

level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
*/
77

88
#pragma once
9+
#include "shared/test/common/test_macros/mock_method_macros.h"
10+
911
#include "level_zero/core/source/cmdqueue/cmdqueue_hw.h"
1012
#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h"
1113
#include "level_zero/core/test/unit_tests/mock.h"
1214
#include "level_zero/core/test/unit_tests/white_box.h"
1315

14-
#include "gmock/gmock.h"
15-
1616
namespace L0 {
1717
namespace ult {
1818

@@ -45,41 +45,13 @@ struct Mock<CommandQueue> : public CommandQueue {
4545
Mock(L0::Device *device = nullptr, NEO::CommandStreamReceiver *csr = nullptr, const ze_command_queue_desc_t *desc = &default_cmd_queue_desc);
4646
~Mock() override;
4747

48-
MOCK_METHOD(ze_result_t,
49-
createFence,
50-
(const ze_fence_desc_t *desc,
51-
ze_fence_handle_t *phFence),
52-
(override));
53-
MOCK_METHOD(ze_result_t,
54-
destroy,
55-
(),
56-
(override));
57-
MOCK_METHOD(ze_result_t,
58-
executeCommandLists,
59-
(uint32_t numCommandLists,
60-
ze_command_list_handle_t *phCommandLists,
61-
ze_fence_handle_t hFence,
62-
bool performMigration),
63-
(override));
64-
MOCK_METHOD(ze_result_t,
65-
executeCommands,
66-
(uint32_t numCommands,
67-
void *phCommands,
68-
ze_fence_handle_t hFence),
69-
(override));
70-
MOCK_METHOD(ze_result_t,
71-
synchronize,
72-
(uint64_t timeout),
73-
(override));
74-
MOCK_METHOD(void,
75-
dispatchTaskCountWrite,
76-
(NEO::LinearStream & commandStream,
77-
bool flushDataCache),
78-
(override));
79-
MOCK_METHOD(bool,
80-
getPreemptionCmdProgramming,
81-
(),
82-
(override));
48+
ADDMETHOD_NOBASE(createFence, ze_result_t, ZE_RESULT_SUCCESS, (const ze_fence_desc_t *desc, ze_fence_handle_t *phFence));
49+
ADDMETHOD_NOBASE(destroy, ze_result_t, ZE_RESULT_SUCCESS, ());
50+
ADDMETHOD_NOBASE(executeCommandLists, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists, ze_fence_handle_t hFence, bool performMigration));
51+
ADDMETHOD_NOBASE(executeCommands, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t numCommands, void *phCommands, ze_fence_handle_t hFence));
52+
ADDMETHOD_NOBASE(synchronize, ze_result_t, ZE_RESULT_SUCCESS, (uint64_t timeout));
53+
ADDMETHOD_NOBASE_VOIDRETURN(dispatchTaskCountWrite, (NEO::LinearStream & commandStream, bool flushDataCache));
54+
ADDMETHOD_NOBASE(getPreemptionCmdProgramming, bool, false, ());
8355
};
8456

8557
template <GFXCORE_FAMILY gfxCoreFamily>
Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
9-
#include "level_zero/core/source/sampler/sampler.h"
109
#include "level_zero/core/source/sampler/sampler_hw.h"
11-
#include "level_zero/core/test/unit_tests/mock.h"
12-
#include "level_zero/core/test/unit_tests/white_box.h"
13-
14-
#if defined(__clang__)
15-
#pragma clang diagnostic push
16-
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
17-
#endif
1810

1911
namespace L0 {
2012
namespace ult {
2113

22-
using Sampler = WhiteBox<::L0::Sampler>;
23-
24-
template <>
25-
struct Mock<Sampler> : public Sampler {
26-
Mock() = default;
27-
28-
MOCK_METHOD0(destroy, ze_result_t());
29-
MOCK_METHOD2(create, ze_result_t(Device *, const ze_sampler_desc_t *));
30-
};
31-
3214
template <GFXCORE_FAMILY gfxCoreFamily>
3315
struct MockSamplerHw : public L0::SamplerCoreFamily<gfxCoreFamily> {
3416
using BaseClass = ::L0::SamplerCoreFamily<gfxCoreFamily>;
@@ -39,7 +21,3 @@ struct MockSamplerHw : public L0::SamplerCoreFamily<gfxCoreFamily> {
3921

4022
} // namespace ult
4123
} // namespace L0
42-
43-
#if defined(__clang__)
44-
#pragma clang diagnostic pop
45-
#endif

level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_memory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ HWTEST2_F(AppendMemoryCopy, givenImmediateCommandListWhenAppendingMemoryCopyThen
282282
commandList->cmdQImmediate = &cmdQueue;
283283
commandList->cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE;
284284

285-
EXPECT_CALL(cmdQueue, executeCommandLists).Times(1).WillRepeatedly(::testing::Return(ZE_RESULT_SUCCESS));
286-
EXPECT_CALL(cmdQueue, synchronize).Times(1).WillRepeatedly(::testing::Return(ZE_RESULT_SUCCESS));
287-
288285
auto result = commandList->appendMemoryCopy(dstPtr, srcPtr, 8, nullptr, 0, nullptr);
289286
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
290287

288+
EXPECT_EQ(1u, cmdQueue.executeCommandListsCalled);
289+
EXPECT_EQ(1u, cmdQueue.synchronizeCalled);
290+
291291
commandList->cmdQImmediate = nullptr;
292292
}
293293

0 commit comments

Comments
 (0)