Remove GMock from MockAubCsr, GmockAubFileStream, AsyncEventsHandlerTests...

GMock Removed from:
- MockAubCsr
- GmockAubFileStream
- AsyncEventsHandlerTests
- AsyncEventsHandlerTests::MyEvent
- MockGmmPageTableMngr
- GmockWddm

Additionally:
- GmockAubFileStream body moved to MockAubFileStream class
- Deleted unused GmockAubFileStream class
- Deleted NiceMocks from AsyncEventsHandlerTests
- Renamed GmockWddm to MockWddm

Related-To: NEO-4914
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2021-12-28 13:04:55 +01:00
committed by Compute-Runtime-Automation
parent f8c1fe53db
commit 1d48e97649
16 changed files with 320 additions and 279 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -16,8 +16,7 @@
#include "shared/test/common/helpers/dispatch_flags_helper.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_allocation_properties.h"
#include "gmock/gmock.h"
#include "shared/test/common/test_macros/mock_method_macros.h"
#include <string>
@@ -170,7 +169,7 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
bool fileIsOpen = false;
std::string openFileName = "";
MOCK_METHOD(bool, addPatchInfoComments, (), (override));
ADDMETHOD_NOBASE(addPatchInfoComments, bool, true, ());
using CommandStreamReceiverHw<GfxFamily>::localMemoryEnabled;
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,9 +8,12 @@
#pragma once
#include "shared/source/command_stream/aub_command_stream_receiver.h"
#include "shared/test/common/test_macros/mock_method_macros.h"
#include "gmock/gmock.h"
#include <vector>
namespace NEO {
struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
@@ -53,23 +56,29 @@ struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
compareOperationFromExpectMemory = compareOperation;
}
bool addComment(const char *message) override {
receivedComment.assign(message);
addCommentCalled = true;
return true;
addCommentCalled++;
comments.push_back(std::string(message));
if (addCommentCalled <= addCommentResults.size()) {
return addCommentResults[addCommentCalled - 1];
}
return addCommentResult;
}
void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override {
registerPollCalled = true;
AUBCommandStreamReceiver::AubFileStream::registerPoll(registerOffset, mask, value, pollNotEqual, timeoutAction);
}
uint32_t addCommentCalled = 0u;
uint32_t openCalledCnt = 0;
std::string fileName = "";
bool addCommentResult = true;
std::vector<bool> addCommentResults = {};
bool closeCalled = false;
uint32_t initCalledCnt = 0;
mutable bool isOpenCalled = false;
mutable bool getFileNameCalled = false;
bool registerPollCalled = false;
bool addCommentCalled = false;
std::string receivedComment = "";
bool flushCalled = false;
bool lockStreamCalled = false;
uint32_t mmioRegisterFromExpectMMIO = 0;
@@ -79,9 +88,6 @@ struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
size_t sizeCapturedFromExpectMemory = 0;
uint32_t addressSpaceCapturedFromExpectMemory = 0;
uint32_t compareOperationFromExpectMemory = 0;
};
struct GmockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
MOCK_METHOD(bool, addComment, (const char *message), (override));
std::vector<std::string> comments;
};
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,12 +8,9 @@
#include "shared/test/common/mocks/mock_gmm_page_table_mngr.h"
namespace NEO {
using namespace ::testing;
GmmPageTableMngr *GmmPageTableMngr::create(GmmClientContext *clientContext, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) {
auto pageTableMngr = new ::testing::NiceMock<MockGmmPageTableMngr>(translationTableFlags, translationTableCb);
ON_CALL(*pageTableMngr, initContextAuxTableRegister(_, _)).WillByDefault(Return(GMM_SUCCESS));
ON_CALL(*pageTableMngr, updateAuxTable(_)).WillByDefault(Return(GMM_SUCCESS));
auto pageTableMngr = new MockGmmPageTableMngr(translationTableFlags, translationTableCb);
return pageTableMngr;
}
void MockGmmPageTableMngr::setCsrHandle(void *csrHandle) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,13 +8,14 @@
#pragma once
#include "shared/source/gmm_helper/page_table_mngr.h"
#include "gmock/gmock.h"
#include "shared/source/utilities/stackvec.h"
namespace NEO {
class MockGmmPageTableMngr : public GmmPageTableMngr {
public:
MockGmmPageTableMngr() = default;
MockGmmPageTableMngr() {
initContextAuxTableRegisterParamsPassed.clear();
};
MockGmmPageTableMngr(unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb)
: translationTableFlags(translationTableFlags) {
@@ -23,9 +24,34 @@ class MockGmmPageTableMngr : public GmmPageTableMngr {
}
};
MOCK_METHOD(GMM_STATUS, initContextAuxTableRegister, (HANDLE initialBBHandle, GMM_ENGINE_TYPE engineType), (override));
GMM_STATUS initContextAuxTableRegister(HANDLE initialBBHandle, GMM_ENGINE_TYPE engineType) override {
initContextAuxTableRegisterCalled++;
initContextAuxTableRegisterParamsPassed.push_back({initialBBHandle, engineType});
return initContextAuxTableRegisterResult;
}
MOCK_METHOD(GMM_STATUS, updateAuxTable, (const GMM_DDI_UPDATEAUXTABLE *ddiUpdateAuxTable), (override));
struct InitContextAuxTableRegisterParams {
HANDLE initialBBHandle = nullptr;
GMM_ENGINE_TYPE engineType = GMM_ENGINE_TYPE::ENGINE_TYPE_RCS;
};
StackVec<InitContextAuxTableRegisterParams, 2> initContextAuxTableRegisterParamsPassed{};
uint32_t initContextAuxTableRegisterCalled = 0u;
GMM_STATUS initContextAuxTableRegisterResult = GMM_STATUS::GMM_SUCCESS;
GMM_STATUS updateAuxTable(const GMM_DDI_UPDATEAUXTABLE *ddiUpdateAuxTable) override {
updateAuxTableCalled++;
updateAuxTableParamsPassed.push_back({*ddiUpdateAuxTable});
return updateAuxTableResult;
}
struct UpdateAuxTableParams {
GMM_DDI_UPDATEAUXTABLE ddiUpdateAuxTable = {};
};
StackVec<UpdateAuxTableParams, 1> updateAuxTableParamsPassed{};
uint32_t updateAuxTableCalled = 0u;
GMM_STATUS updateAuxTableResult = GMM_STATUS::GMM_SUCCESS;
void setCsrHandle(void *csrHandle) override;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -310,7 +310,7 @@ bool WddmMock::setAllocationPriority(const D3DKMT_HANDLE *handles, uint32_t allo
return setAllocationPriorityResult.success;
}
void *GmockWddm::virtualAllocWrapper(void *inPtr, size_t size, uint32_t flags, uint32_t type) {
void *MockWddm::virtualAllocWrapper(void *inPtr, size_t size, uint32_t flags, uint32_t type) {
void *tmp = reinterpret_cast<void *>(virtualAllocAddress);
size += MemoryConstants::pageSize;
size -= size % MemoryConstants::pageSize;
@@ -318,6 +318,6 @@ void *GmockWddm::virtualAllocWrapper(void *inPtr, size_t size, uint32_t flags, u
return tmp;
}
GmockWddm::GmockWddm(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {
MockWddm::MockWddm(RootDeviceEnvironment &rootDeviceEnvironment) : WddmMock(rootDeviceEnvironment) {
virtualAllocAddress = NEO::windowsMinAddress;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -14,11 +14,11 @@
#include "shared/source/os_interface/windows/wddm_residency_allocations_container.h"
#include "shared/source/os_interface/windows/windows_defs.h"
#include "shared/test/common/mocks/wddm_mock_helpers.h"
#include "shared/test/common/test_macros/mock_method_macros.h"
#include "gmock/gmock.h"
#include <limits>
#include <memory>
#include <set>
#include <vector>
namespace NEO {
class GraphicsAllocation;
@@ -168,18 +168,61 @@ class WddmMock : public Wddm {
bool callBaseSetAllocationPriority = true;
};
struct GmockWddm : WddmMock {
GmockWddm(RootDeviceEnvironment &rootDeviceEnvironment);
~GmockWddm() = default;
struct MockWddm : WddmMock {
MockWddm(RootDeviceEnvironment &rootDeviceEnvironment);
~MockWddm() = default;
bool virtualFreeWrapper(void *ptr, size_t size, uint32_t flags) {
return true;
}
void *virtualAllocWrapper(void *inPtr, size_t size, uint32_t flags, uint32_t type);
uintptr_t virtualAllocAddress;
MOCK_METHOD5(makeResident, bool(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t totalSize));
MOCK_METHOD3(evict, bool(const D3DKMT_HANDLE *handles, uint32_t num, uint64_t &sizeToTrim));
MOCK_METHOD1(createAllocationsAndMapGpuVa, NTSTATUS(OsHandleStorage &osHandles));
bool makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t totalSize) override {
makeResidentCalled++;
MakeResidentParams params{};
params.cantTrimFurther = cantTrimFurther;
params.totalSize = totalSize;
if (handles) {
for (size_t i = 0; i < count; i++) {
params.handles.push_back(handles[i]);
}
}
if (numberOfBytesToTrim != nullptr) {
*numberOfBytesToTrim = makeResidentNumberOfBytesToTrim;
}
makeResidentParamsPassed.push_back(params);
if (makeResidentCalled <= makeResidentResults.size()) {
return makeResidentResults[makeResidentCalled - 1];
}
return makeResidentResult;
}
struct MakeResidentParams {
StackVec<D3DKMT_HANDLE, 2> handles;
bool cantTrimFurther{};
size_t totalSize{};
};
StackVec<MakeResidentParams, 2> makeResidentParamsPassed{};
uint32_t makeResidentCalled = 0u;
bool makeResidentResult = true;
std::vector<bool> makeResidentResults = {};
uint64_t makeResidentNumberOfBytesToTrim = 0;
ADDMETHOD_NOBASE(evict, bool, true, (const D3DKMT_HANDLE *handles, uint32_t num, uint64_t &sizeToTrim));
NTSTATUS createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) override {
createAllocationsAndMapGpuVaCalled++;
if (callBaseCreateAllocationAndMapGpuVa) {
createAllocationsAndMapGpuVaResult = baseCreateAllocationAndMapGpuVa(osHandles);
}
return createAllocationsAndMapGpuVaResult;
}
uint32_t createAllocationsAndMapGpuVaCalled = 0u;
bool callBaseCreateAllocationAndMapGpuVa = false;
NTSTATUS createAllocationsAndMapGpuVaResult = STATUS_UNSUCCESSFUL;
NTSTATUS baseCreateAllocationAndMapGpuVa(OsHandleStorage &osHandles) {
return Wddm::createAllocationsAndMapGpuVa(osHandles);