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:
parent
f8c1fe53db
commit
1d48e97649
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -1390,9 +1390,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenFlus
|
|||
MockGmmPageTableMngr *pageTableManager2 = new MockGmmPageTableMngr();
|
||||
csr2->pageTableManager.reset(pageTableManager2);
|
||||
|
||||
EXPECT_CALL(*pageTableManager, initContextAuxTableRegister(csr, ::testing::_)).Times(1);
|
||||
EXPECT_CALL(*pageTableManager, initContextAuxTableRegister(csr2, ::testing::_)).Times(0);
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
IndirectHeap cs(graphicsAllocation);
|
||||
|
@ -1409,12 +1406,18 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenFlus
|
|||
|
||||
csr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags, *pDevice);
|
||||
|
||||
EXPECT_CALL(*pageTableManager2, initContextAuxTableRegister(csr2, ::testing::_)).Times(1);
|
||||
EXPECT_EQ(1u, pageTableManager->initContextAuxTableRegisterCalled);
|
||||
EXPECT_EQ(1u, pageTableManager->initContextAuxTableRegisterParamsPassed.size());
|
||||
EXPECT_EQ(csr, pageTableManager->initContextAuxTableRegisterParamsPassed[0].initialBBHandle);
|
||||
|
||||
pDevice->resetCommandStreamReceiver(csr2);
|
||||
csr2->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags, *pDevice);
|
||||
EXPECT_TRUE(csr2->pageTableManagerInitialized);
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(1u, pageTableManager2->initContextAuxTableRegisterCalled);
|
||||
EXPECT_EQ(csr2, pageTableManager2->initContextAuxTableRegisterParamsPassed[0].initialBBHandle);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenPageTableManagerPointerWhenCallBlitBufferThenPageTableManagerInitializedForProperCsr) {
|
||||
|
@ -1427,9 +1430,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenPageTableManagerPointerWhenCa
|
|||
MockGmmPageTableMngr *pageTableManager2 = new MockGmmPageTableMngr();
|
||||
bcsCsr2->pageTableManager.reset(pageTableManager2);
|
||||
|
||||
EXPECT_CALL(*pageTableManager, initContextAuxTableRegister(bcsCsr, ::testing::_)).Times(1);
|
||||
EXPECT_CALL(*pageTableManager2, initContextAuxTableRegister(bcsCsr2, ::testing::_)).Times(0);
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
|
||||
|
@ -1455,13 +1455,18 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenPageTableManagerPointerWhenCa
|
|||
EXPECT_TRUE(bcsCsr->pageTableManagerInitialized);
|
||||
EXPECT_FALSE(bcsCsr2->pageTableManagerInitialized);
|
||||
|
||||
EXPECT_CALL(*pageTableManager2, initContextAuxTableRegister(bcsCsr2, ::testing::_)).Times(1);
|
||||
EXPECT_EQ(1u, pageTableManager->initContextAuxTableRegisterCalled);
|
||||
EXPECT_EQ(bcsCsr, pageTableManager->initContextAuxTableRegisterParamsPassed[0].initialBBHandle);
|
||||
|
||||
pDevice->resetCommandStreamReceiver(bcsCsr2);
|
||||
bcsCsr2->blitBuffer(container, true, false, *pDevice);
|
||||
|
||||
EXPECT_TRUE(bcsCsr2->pageTableManagerInitialized);
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(1u, pageTableManager2->initContextAuxTableRegisterCalled);
|
||||
EXPECT_EQ(bcsCsr2, pageTableManager2->initContextAuxTableRegisterParamsPassed[0].initialBBHandle);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenPageTableManagerPointerWhenCallBlitBufferAndPageTableManagerInitializedThenNotInitializeAgain) {
|
||||
|
@ -1471,8 +1476,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenPageTableManagerPointerWhenCa
|
|||
MockGmmPageTableMngr *pageTableManager = new MockGmmPageTableMngr();
|
||||
bcsCsr->pageTableManager.reset(pageTableManager);
|
||||
|
||||
EXPECT_CALL(*pageTableManager, initContextAuxTableRegister(bcsCsr, ::testing::_)).Times(1);
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
|
||||
|
@ -1496,10 +1499,13 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenPageTableManagerPointerWhenCa
|
|||
|
||||
EXPECT_TRUE(bcsCsr->pageTableManagerInitialized);
|
||||
|
||||
EXPECT_CALL(*pageTableManager, initContextAuxTableRegister(bcsCsr, ::testing::_)).Times(0);
|
||||
bcsCsr->blitBuffer(container, true, false, *pDevice);
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(1u, pageTableManager->initContextAuxTableRegisterCalled);
|
||||
EXPECT_EQ(1u, pageTableManager->initContextAuxTableRegisterParamsPassed.size());
|
||||
EXPECT_EQ(bcsCsr, pageTableManager->initContextAuxTableRegisterParamsPassed[0].initialBBHandle);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNullPageTableManagerWhenCallBlitBufferThenPageTableManagerIsNotInitialized) {
|
||||
|
@ -1553,7 +1559,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenInit
|
|||
MockGmmPageTableMngr *pageTableManager = new MockGmmPageTableMngr();
|
||||
csr->pageTableManager.reset(pageTableManager);
|
||||
|
||||
EXPECT_CALL(*pageTableManager, initContextAuxTableRegister(csr, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(GMM_ERROR));
|
||||
pageTableManager->initContextAuxTableRegisterResult = GMM_ERROR;
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
|
@ -1571,6 +1577,9 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenInit
|
|||
|
||||
EXPECT_FALSE(csr->pageTableManagerInitialized);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
EXPECT_EQ(2u, pageTableManager->initContextAuxTableRegisterCalled);
|
||||
EXPECT_EQ(csr, pageTableManager->initContextAuxTableRegisterParamsPassed[0].initialBBHandle);
|
||||
EXPECT_EQ(csr, pageTableManager->initContextAuxTableRegisterParamsPassed[1].initialBBHandle);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, WhenCsrIsMarkedWithNewResourceThenCallBatchedSubmission) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "shared/source/helpers/timestamp_packet.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
#include "shared/test/unit_test/utilities/base_object_utils.h"
|
||||
|
||||
|
@ -17,8 +18,6 @@
|
|||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace NEO;
|
||||
using namespace ::testing;
|
||||
|
||||
|
@ -27,7 +26,9 @@ class AsyncEventsHandlerTests : public ::testing::Test {
|
|||
class MyEvent : public Event {
|
||||
public:
|
||||
MyEvent(Context *ctx, CommandQueue *cmdQueue, cl_command_type cmdType, uint32_t taskLevel, uint32_t taskCount)
|
||||
: Event(ctx, cmdQueue, cmdType, taskLevel, taskCount) {}
|
||||
: Event(ctx, cmdQueue, cmdType, taskLevel, taskCount) {
|
||||
handler.reset(new MockHandler());
|
||||
}
|
||||
int getExecutionStatus() {
|
||||
//return execution status without updating
|
||||
return executionStatus.load();
|
||||
|
@ -37,7 +38,15 @@ class AsyncEventsHandlerTests : public ::testing::Test {
|
|||
this->updateTaskCount(taskCount, 0);
|
||||
}
|
||||
|
||||
MOCK_METHOD2(wait, bool(bool blocking, bool quickKmdSleep));
|
||||
bool wait(bool blocking, bool quickKmdSleep) override {
|
||||
waitCalled++;
|
||||
handler->allowAsyncProcess.store(false);
|
||||
return waitResult;
|
||||
}
|
||||
|
||||
uint32_t waitCalled = 0u;
|
||||
bool waitResult = true;
|
||||
std::unique_ptr<MockHandler> handler;
|
||||
};
|
||||
|
||||
static void CL_CALLBACK callbackFcn(cl_event e, cl_int status, void *data) {
|
||||
|
@ -48,26 +57,26 @@ class AsyncEventsHandlerTests : public ::testing::Test {
|
|||
dbgRestore.reset(new DebugManagerStateRestore());
|
||||
DebugManager.flags.EnableAsyncEventsHandler.set(false);
|
||||
handler.reset(new MockHandler());
|
||||
context = make_releaseable<NiceMock<MockContext>>();
|
||||
context = make_releaseable<MockContext>();
|
||||
|
||||
commandQueue = make_releaseable<MockCommandQueue>(context.get(), context->getDevice(0), nullptr, false);
|
||||
|
||||
*(commandQueue->getGpgpuCommandStreamReceiver().getTagAddress()) = 0;
|
||||
|
||||
event1 = make_releaseable<NiceMock<MyEvent>>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
event2 = make_releaseable<NiceMock<MyEvent>>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
event3 = make_releaseable<NiceMock<MyEvent>>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
event1 = make_releaseable<MyEvent>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
event2 = make_releaseable<MyEvent>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
event3 = make_releaseable<MyEvent>(context.get(), commandQueue.get(), CL_COMMAND_BARRIER, CompletionStamp::notReady, CompletionStamp::notReady);
|
||||
}
|
||||
|
||||
std::unique_ptr<DebugManagerStateRestore> dbgRestore;
|
||||
std::unique_ptr<MockHandler> handler;
|
||||
int counter = 0;
|
||||
|
||||
ReleaseableObjectPtr<NiceMock<MockContext>> context;
|
||||
ReleaseableObjectPtr<MockContext> context;
|
||||
ReleaseableObjectPtr<MockCommandQueue> commandQueue;
|
||||
ReleaseableObjectPtr<NiceMock<MyEvent>> event1;
|
||||
ReleaseableObjectPtr<NiceMock<MyEvent>> event2;
|
||||
ReleaseableObjectPtr<NiceMock<MyEvent>> event3;
|
||||
ReleaseableObjectPtr<MyEvent> event1;
|
||||
ReleaseableObjectPtr<MyEvent> event2;
|
||||
ReleaseableObjectPtr<MyEvent> event3;
|
||||
};
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, givenEventsWhenListIsProcessedThenUpdateExecutionStatus) {
|
||||
|
@ -340,20 +349,13 @@ TEST_F(AsyncEventsHandlerTests, givenEventWithoutCallbacksWhenProcessedThenDontR
|
|||
TEST_F(AsyncEventsHandlerTests, givenSleepCandidateWhenProcessedThenCallWaitWithQuickKmdSleepRequest) {
|
||||
event1->setTaskStamp(0, 1);
|
||||
event1->addCallback(&this->callbackFcn, CL_COMPLETE, &counter);
|
||||
handler->registerEvent(event1.get());
|
||||
handler->allowAsyncProcess.store(true);
|
||||
event1->handler->registerEvent(event1.get());
|
||||
event1->handler->allowAsyncProcess.store(true);
|
||||
|
||||
// break infinite loop after first iteartion
|
||||
auto unsetAsyncFlag = [&](bool blocking, bool quickKmdSleep) {
|
||||
handler->allowAsyncProcess.store(false);
|
||||
return true;
|
||||
};
|
||||
|
||||
EXPECT_CALL(*event1, wait(true, true)).Times(1).WillOnce(Invoke(unsetAsyncFlag));
|
||||
|
||||
MockHandler::asyncProcess(handler.get());
|
||||
MockHandler::asyncProcess(event1->handler.get());
|
||||
|
||||
event1->setStatus(CL_COMPLETE);
|
||||
EXPECT_EQ(1u, event1->waitCalled);
|
||||
}
|
||||
|
||||
TEST_F(AsyncEventsHandlerTests, WhenReturningThenAsyncProcessWillCallProcessList) {
|
||||
|
|
|
@ -2864,8 +2864,8 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenMapAuxGpuVaThenForAllEng
|
|||
memoryManager->createAndRegisterOsContext(csr2.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[1],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr2 = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
auto mockMngr2 = new MockGmmPageTableMngr();
|
||||
|
||||
memoryManager->getRegisteredEngines()[0].commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
memoryManager->getRegisteredEngines()[1].commandStreamReceiver->pageTableManager.reset(mockMngr2);
|
||||
|
@ -2874,22 +2874,21 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenMapAuxGpuVaThenForAllEng
|
|||
MockGmm gmm(executionEnvironment->rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmClientContext());
|
||||
gmm.isCompressionEnabled = true;
|
||||
allocation.setDefaultGmm(&gmm);
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {};
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable2 = {};
|
||||
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = allocation.getGpuAddress();
|
||||
expectedDdiUpdateAuxTable.BaseResInfo = allocation.getDefaultGmm()->gmmResourceInfo->peekGmmResourceInfo();
|
||||
expectedDdiUpdateAuxTable.DoNotWait = true;
|
||||
expectedDdiUpdateAuxTable.Map = true;
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(1).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
EXPECT_CALL(*mockMngr2, updateAuxTable(_)).Times(1).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg2) {givenDdiUpdateAuxTable2 = *arg2; return GMM_SUCCESS; }));
|
||||
|
||||
bool result = memoryManager->mapAuxGpuVA(&allocation);
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable2, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_EQ(1u, mockMngr->updateAuxTableCalled);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
|
||||
EXPECT_EQ(1u, mockMngr2->updateAuxTableCalled);
|
||||
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr2->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
}
|
||||
HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenUpdateAuxTableGmmErrorThenMapAuxGpuVaReturnFalse) {
|
||||
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
|
||||
|
@ -2910,7 +2909,8 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenUpdateAuxTableGmmErrorTh
|
|||
memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
mockMngr->updateAuxTableResult = GMM_ERROR;
|
||||
|
||||
memoryManager->getRegisteredEngines()[0].commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
|
||||
|
@ -2919,10 +2919,9 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenUpdateAuxTableGmmErrorTh
|
|||
gmm.isCompressionEnabled = true;
|
||||
allocation.setDefaultGmm(&gmm);
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(1).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) { return GMM_ERROR; }));
|
||||
|
||||
bool result = memoryManager->mapAuxGpuVA(&allocation);
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_EQ(1u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(PageTableManagerTest, givenNullPageTableManagerWhenMapAuxGpuVaThenNoThrow) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -960,15 +960,14 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPageTableManagerAndMapTrueWhenUpda
|
|||
csr->pageTableManager.reset(mockMngr);
|
||||
executionEnvironment.rootDeviceEnvironments[0]->initGmm();
|
||||
auto gmm = std::make_unique<MockGmm>(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext());
|
||||
GMM_DDI_UPDATEAUXTABLE ddiUpdateAuxTable = {};
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(::testing::_)).Times(1).WillOnce(::testing::Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {ddiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
auto result = csr->pageTableManager->updateAuxTable(0, gmm.get(), true);
|
||||
EXPECT_EQ(ddiUpdateAuxTable.BaseGpuVA, 0ull);
|
||||
EXPECT_EQ(ddiUpdateAuxTable.BaseResInfo, gmm->gmmResourceInfo->peekHandle());
|
||||
EXPECT_EQ(ddiUpdateAuxTable.DoNotWait, true);
|
||||
EXPECT_EQ(ddiUpdateAuxTable.Map, 1u);
|
||||
EXPECT_EQ(0ull, mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.BaseGpuVA);
|
||||
EXPECT_EQ(gmm->gmmResourceInfo->peekHandle(), mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.BaseResInfo);
|
||||
EXPECT_EQ(true, mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.DoNotWait);
|
||||
EXPECT_EQ(1u, mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.Map);
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(1u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPageTableManagerAndMapFalseWhenUpdateAuxTableIsCalledThenItReturnsTrue) {
|
||||
|
@ -976,13 +975,12 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPageTableManagerAndMapFalseWhenUpd
|
|||
csr->pageTableManager.reset(mockMngr);
|
||||
executionEnvironment.rootDeviceEnvironments[0]->initGmm();
|
||||
auto gmm = std::make_unique<MockGmm>(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext());
|
||||
GMM_DDI_UPDATEAUXTABLE ddiUpdateAuxTable = {};
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(::testing::_)).Times(1).WillOnce(::testing::Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {ddiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
auto result = csr->pageTableManager->updateAuxTable(0, gmm.get(), false);
|
||||
EXPECT_EQ(ddiUpdateAuxTable.BaseGpuVA, 0ull);
|
||||
EXPECT_EQ(ddiUpdateAuxTable.BaseResInfo, gmm->gmmResourceInfo->peekHandle());
|
||||
EXPECT_EQ(ddiUpdateAuxTable.DoNotWait, true);
|
||||
EXPECT_EQ(ddiUpdateAuxTable.Map, 0u);
|
||||
EXPECT_EQ(0ull, mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.BaseGpuVA);
|
||||
EXPECT_EQ(gmm->gmmResourceInfo->peekHandle(), mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.BaseResInfo);
|
||||
EXPECT_EQ(true, mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.DoNotWait);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable.Map);
|
||||
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(1u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -928,62 +928,71 @@ TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeReside
|
|||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x3;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(2u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x3;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(3u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(0u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(3u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResults = {false, true};
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Return(false)).WillOnce(::testing::Return(true));
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(2u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesThenStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(1u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingAllTemporaryResourcesThenEvictionIsNotApplied) {
|
||||
|
@ -999,37 +1008,38 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesThenAcqui
|
|||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenReturnSuccess) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
mockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(1u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
EXPECT_EQ(MemoryOperationsStatus::SUCCESS, mockTemporaryResources->evictAllResourcesResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesThenCallEvictForEachAllocationAndCleanList) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
constexpr uint32_t numAllocations = 3u;
|
||||
for (auto i = 0u; i < numAllocations; i++) {
|
||||
mockTemporaryResources->resourceHandles.push_back(i);
|
||||
}
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
mockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesAndOneOfThemFailsThenReturnFail) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
mockWddm.evictResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
constexpr uint32_t numAllocations = 3u;
|
||||
for (auto i = 0u; i < numAllocations; i++) {
|
||||
mockTemporaryResources->resourceHandles.push_back(i);
|
||||
}
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
mockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(MemoryOperationsStatus::FAILED, mockTemporaryResources->evictAllResourcesResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingTemporaryResourceThenEvictionIsNotApplied) {
|
||||
|
@ -1052,23 +1062,24 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingNonExistingTemporaryResourceTh
|
|||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictFailsThenReturnFail) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.evictResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
mockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(MemoryOperationsStatus::FAILED, mockTemporaryResources->evictResourceResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictSucceedThenReturnSuccess) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
mockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(MemoryOperationsStatus::SUCCESS, mockTemporaryResources->evictResourceResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheList) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -1841,14 +1841,13 @@ TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThen
|
|||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(AllocationProperties(1, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, mockDeviceBitfield));
|
||||
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {};
|
||||
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = allocation->getGpuAddress();
|
||||
expectedDdiUpdateAuxTable.BaseResInfo = allocation->getDefaultGmm()->gmmResourceInfo->peekGmmResourceInfo();
|
||||
|
@ -1856,12 +1855,12 @@ TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThen
|
|||
expectedDdiUpdateAuxTable.Map = true;
|
||||
|
||||
auto expectedCallCount = static_cast<int>(regularEngines.size());
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
|
||||
auto result = memoryManager.mapAuxGpuVA(allocation);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPageTableNotSupportedThenMapAuxVa) {
|
||||
|
@ -1882,19 +1881,18 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
|
|||
executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : executionEnvironment->memoryManager.get()->getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto hwInfoMock = hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily];
|
||||
ASSERT_NE(nullptr, hwInfoMock);
|
||||
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPageTableSupportedThenMapAuxVa) {
|
||||
|
@ -1915,12 +1913,11 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
|
|||
executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : executionEnvironment->memoryManager.get()->getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {};
|
||||
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = GmmHelper::canonize(wddm.getGfxPartition().Standard.Base);
|
||||
expectedDdiUpdateAuxTable.BaseResInfo = gmm->gmmResourceInfo->peekGmmResourceInfo();
|
||||
|
@ -1929,15 +1926,14 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
|
|||
|
||||
auto expectedCallCount = executionEnvironment->memoryManager.get()->getRegisteredEnginesCount();
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
|
||||
auto hwInfoMock = hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily];
|
||||
ASSERT_NE(nullptr, hwInfoMock);
|
||||
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupportedWhenReleaseingThenUnmapAuxVa) {
|
||||
|
@ -1956,7 +1952,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupported
|
|||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
@ -1965,7 +1961,6 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupported
|
|||
wddmAlloc->setGpuAddress(gpuVa);
|
||||
wddmAlloc->getDefaultGmm()->isCompressionEnabled = true;
|
||||
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {};
|
||||
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = gpuVa;
|
||||
expectedDdiUpdateAuxTable.BaseResInfo = wddmAlloc->getDefaultGmm()->gmmResourceInfo->peekGmmResourceInfo();
|
||||
|
@ -1974,10 +1969,10 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupported
|
|||
|
||||
auto expectedCallCount = memoryManager.getRegisteredEnginesCount();
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThenDontUnmapAuxVa) {
|
||||
|
@ -1992,7 +1987,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThen
|
|||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
@ -2000,9 +1995,8 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThen
|
|||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, MemoryConstants::pageSize}));
|
||||
wddmAlloc->getDefaultGmm()->isCompressionEnabled = false;
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenMappedGpuVaThenDontMapAuxVa) {
|
||||
|
@ -2021,15 +2015,14 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenMappedGpuVaThe
|
|||
executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : executionEnvironment->memoryManager.get()->getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
ASSERT_TRUE(result);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenReturnFalse) {
|
||||
|
@ -2057,7 +2050,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsUnsetThenD
|
|||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
|
@ -2071,11 +2064,10 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsUnsetThenD
|
|||
delete wddmAlloc->getDefaultGmm();
|
||||
wddmAlloc->setDefaultGmm(myGmm);
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto result = wddm->mapGpuVirtualAddress(myGmm, ALLOCATION_HANDLE, wddm->getGfxPartition().Standard.Base, wddm->getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
EXPECT_TRUE(result);
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenUpdateAuxTable) {
|
||||
|
@ -2094,7 +2086,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenUpd
|
|||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get();
|
||||
rootDeviceEnvironment->executionEnvironment.initializeMemoryManager();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
|
@ -2111,11 +2103,10 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenUpd
|
|||
|
||||
auto expectedCallCount = memoryManager.getRegisteredEnginesCount();
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount);
|
||||
|
||||
auto result = wddm->mapGpuVirtualAddress(myGmm, ALLOCATION_HANDLE, wddm->getGfxPartition().Standard.Base, wddm->getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
EXPECT_TRUE(result);
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryWhenCreateAllocationFailsThenPopulateOsHandlesReturnsInvalidPointer) {
|
||||
|
@ -2125,7 +2116,7 @@ TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryWhenCreateAllocationFailsThenP
|
|||
handleStorage.fragmentStorageData[0].fragmentSize = 0x1000;
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = false;
|
||||
|
||||
EXPECT_CALL(*wddm, createAllocationsAndMapGpuVa(::testing::_)).WillOnce(::testing::Return(STATUS_GRAPHICS_NO_VIDEO_MEMORY));
|
||||
wddm->createAllocationsAndMapGpuVaResult = STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
||||
|
||||
auto result = memoryManager->populateOsHandles(handleStorage, 0);
|
||||
|
||||
|
@ -2145,7 +2136,7 @@ TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryPassedToPopulateOsHandlesWhenC
|
|||
handleStorage.fragmentStorageData[1].cpuPtr = reinterpret_cast<void *>(0x2000);
|
||||
handleStorage.fragmentStorageData[1].fragmentSize = 0x6000;
|
||||
|
||||
EXPECT_CALL(*wddm, createAllocationsAndMapGpuVa(::testing::_)).WillOnce(::testing::Return(STATUS_GRAPHICS_NO_VIDEO_MEMORY));
|
||||
wddm->createAllocationsAndMapGpuVaResult = STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
||||
|
||||
auto result = memoryManager->populateOsHandles(handleStorage, mockRootDeviceIndex);
|
||||
auto hostPtrManager = static_cast<MockHostPtrManager *>(memoryManager->getHostPtrManager());
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
@ -108,7 +107,7 @@ class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture
|
|||
void SetUp() override {
|
||||
// wddm is deleted by memory manager
|
||||
|
||||
wddm = new NiceMock<GmockWddm>(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
wddm = new MockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
ASSERT_NE(nullptr, wddm);
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
||||
wddm->init();
|
||||
|
@ -122,17 +121,14 @@ class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture
|
|||
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
|
||||
preemptionMode));
|
||||
|
||||
osContext->incRefInternal();
|
||||
|
||||
ON_CALL(*wddm, createAllocationsAndMapGpuVa(::testing::_)).WillByDefault(::testing::Invoke(wddm, &GmockWddm::baseCreateAllocationAndMapGpuVa));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
osContext->decRefInternal();
|
||||
}
|
||||
|
||||
NiceMock<GmockWddm> *wddm = nullptr;
|
||||
MockWddm *wddm = nullptr;
|
||||
std::unique_ptr<CommandStreamReceiver> csr;
|
||||
OSInterface *osInterface;
|
||||
OsContext *osContext;
|
||||
|
|
|
@ -119,7 +119,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
|
|||
void SetUp() {
|
||||
executionEnvironment = platform()->peekExecutionEnvironment();
|
||||
|
||||
wddm = new ::testing::NiceMock<GmockWddm>(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
wddm = new MockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
wddm->resetGdi(new MockGdi());
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
||||
wddm->init();
|
||||
|
@ -147,7 +147,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
|
|||
ExecutionEnvironment *executionEnvironment;
|
||||
std::unique_ptr<MockWddmMemoryManager> memoryManager;
|
||||
std::unique_ptr<CommandStreamReceiver> csr;
|
||||
::testing::NiceMock<GmockWddm> *wddm = nullptr;
|
||||
MockWddm *wddm = nullptr;
|
||||
OsContext *osContext;
|
||||
WddmResidencyController *residencyController;
|
||||
GmmClientContext *gmmClientContext = nullptr;
|
||||
|
@ -1012,10 +1012,8 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
|||
MockWddmAllocation allocation3(gmmClientContext);
|
||||
MockWddmAllocation allocation4(gmmClientContext);
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
wddm->makeResidentNumberOfBytesToTrim = 4 * 4096;
|
||||
wddm->makeResidentResult = false;
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
|
@ -1026,19 +1024,19 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
|||
EXPECT_FALSE(allocation2.getResidencyData().resident[osContextId]);
|
||||
EXPECT_FALSE(allocation3.getResidencyData().resident[osContextId]);
|
||||
EXPECT_FALSE(allocation4.getResidencyData().resident[osContextId]);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenDontMarkTripleAllocationsAsResident) {
|
||||
MockWddmAllocation allocation1(gmmClientContext);
|
||||
MockWddmAllocation allocation2(gmmClientContext);
|
||||
wddm->callBaseCreateAllocationAndMapGpuVa = true;
|
||||
void *ptr = reinterpret_cast<void *>(wddm->getWddmMinAddress() + 0x1500);
|
||||
WddmAllocation *allocationTriple = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, 2 * MemoryConstants::pageSize}, ptr));
|
||||
ASSERT_NE(nullptr, allocationTriple);
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
wddm->makeResidentNumberOfBytesToTrim = 4 * 4096;
|
||||
wddm->makeResidentResult = false;
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
|
@ -1050,21 +1048,21 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
|||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocationTriple);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenCallItAgainWithCantTrimFurtherSetToTrue) {
|
||||
MockWddmAllocation allocation1(gmmClientContext);
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, false, ::testing::_, ::testing::_)).Times(1);
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, true, ::testing::_, ::testing::_)).Times(1);
|
||||
wddm->makeResidentNumberOfBytesToTrim = 4 * 4096;
|
||||
wddm->makeResidentResult = false;
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_NE(wddm->makeResidentParamsPassed[0].cantTrimFurther, wddm->makeResidentParamsPassed[1].cantTrimFurther);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenAllocationPackPassedWhenCallingMakeResidentResidencyAllocationsThenItIsUsed) {
|
||||
|
@ -1074,16 +1072,13 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenAllocationPackPassedWhenCal
|
|||
allocation2.handle = 2;
|
||||
ResidencyContainer residencyPack{&allocation1, &allocation2};
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool {
|
||||
EXPECT_EQ(1, handles[0 * EngineLimits::maxHandleCount]);
|
||||
EXPECT_EQ(2, handles[1 * EngineLimits::maxHandleCount]);
|
||||
return true;
|
||||
};
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, 2 * EngineLimits::maxHandleCount, false, ::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(2 * EngineLimits::maxHandleCount, wddm->makeResidentParamsPassed[0].handles.size());
|
||||
EXPECT_EQ(false, wddm->makeResidentParamsPassed[0].cantTrimFurther);
|
||||
EXPECT_EQ(1, wddm->makeResidentParamsPassed[0].handles[0 * EngineLimits::maxHandleCount]);
|
||||
EXPECT_EQ(2, wddm->makeResidentParamsPassed[0].handles[1 * EngineLimits::maxHandleCount]);
|
||||
EXPECT_EQ(1u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToBudgetSuceedsWhenCallingMakeResidentResidencyAllocationsThenSucceed) {
|
||||
|
@ -1094,9 +1089,8 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB
|
|||
|
||||
allocationToTrim.getResidencyData().updateCompletionData(residencyController->getMonitoredFence().lastSubmittedFence, osContext->getContextId());
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [allocationSize](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = allocationSize; return false; };
|
||||
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(makeResidentWithOutBytesToTrim)).WillOnce(::testing::Return(true));
|
||||
wddm->makeResidentNumberOfBytesToTrim = allocationSize;
|
||||
wddm->makeResidentResults = {false, true};
|
||||
|
||||
residencyController->addToTrimCandidateList(&allocationToTrim);
|
||||
|
||||
|
@ -1106,17 +1100,16 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB
|
|||
EXPECT_TRUE(result);
|
||||
|
||||
EXPECT_TRUE(allocation1.getResidencyData().resident[osContextId]);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenMemoryBudgetExhaustedIsSetToTrue) {
|
||||
MockWddmAllocation allocation1(gmmClientContext);
|
||||
ResidencyContainer residencyPack{&allocation1};
|
||||
|
||||
auto makeResidentThatFails = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { return false; };
|
||||
auto makeResidentThatSucceds = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { return true; };
|
||||
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(makeResidentThatFails)).WillOnce(::testing::Invoke(makeResidentThatSucceds));
|
||||
wddm->makeResidentResults = {false, true};
|
||||
|
||||
residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
EXPECT_TRUE(residencyController->isMemoryBudgetExhausted());
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -426,8 +426,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
|
|||
|
||||
ResidencyContainer allocationsForResidency;
|
||||
|
||||
EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(1);
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
EXPECT_EQ(1u, aubCsr->addPatchInfoCommentsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoCommentsIsNotCalled) {
|
||||
|
@ -439,9 +439,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
|
|||
|
||||
ResidencyContainer allocationsForResidency;
|
||||
|
||||
EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(0);
|
||||
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
EXPECT_EQ(0u, aubCsr->addPatchInfoCommentsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenGetIndirectPatchCommandsIsCalledForEmptyPatchInfoListThenIndirectPatchCommandBufferIsNotCreated) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -31,10 +31,6 @@
|
|||
|
||||
using namespace NEO;
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::Return;
|
||||
|
||||
using AubFileStreamTests = Test<AubCommandStreamReceiverFixture>;
|
||||
|
||||
struct AddPatchInfoCommentsAubTests : AubFileStreamTests {
|
||||
|
@ -303,8 +299,8 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenCallingAddAubComme
|
|||
aubCsr->addAubComment(comment);
|
||||
|
||||
EXPECT_TRUE(aubCsr->addAubCommentCalled);
|
||||
EXPECT_TRUE(aubFileStream->addCommentCalled);
|
||||
EXPECT_STREQ(comment, aubFileStream->receivedComment.c_str());
|
||||
EXPECT_LT(0u, aubFileStream->addCommentCalled);
|
||||
EXPECT_STREQ(comment, aubFileStream->comments[0].c_str());
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenCallingAddAubCommentThenCallAddCommentOnAubManager) {
|
||||
|
@ -733,22 +729,15 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenExpe
|
|||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitializeEngineIsCalledThenMemTraceCommentWithDriverVersionIsPutIntoAubStream) {
|
||||
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
|
||||
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
aubCsr->stream = mockAubFileStream.get();
|
||||
|
||||
std::vector<std::string> comments;
|
||||
|
||||
EXPECT_CALL(*mockAubFileStream, addComment(_)).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool {
|
||||
comments.push_back(std::string(str));
|
||||
return true;
|
||||
}));
|
||||
aubCsr->initializeEngine();
|
||||
|
||||
std::string commentWithDriverVersion = "driver version: " + std::string(driverVersion);
|
||||
EXPECT_EQ(commentWithDriverVersion, comments[0]);
|
||||
EXPECT_EQ(commentWithDriverVersion, mockAubFileStream->comments[0]);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenInitFileIsCalledThenMemTraceCommentWithDriverVersionIsPutIntoAubStream) {
|
||||
|
@ -766,7 +755,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenInit
|
|||
}
|
||||
|
||||
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenNoPatchInfoDataObjectsThenCommentsAreEmpty) {
|
||||
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
|
||||
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
|
@ -775,23 +764,18 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenNoPatc
|
|||
|
||||
aubCsr->stream = mockAubFileStream.get();
|
||||
|
||||
std::vector<std::string> comments;
|
||||
|
||||
EXPECT_CALL(*mockAubFileStream, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool {
|
||||
comments.push_back(std::string(str));
|
||||
return true;
|
||||
}));
|
||||
bool result = aubCsr->addPatchInfoComments();
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
ASSERT_EQ(2u, comments.size());
|
||||
ASSERT_EQ(2u, mockAubFileStream->comments.size());
|
||||
|
||||
EXPECT_EQ("PatchInfoData\n", comments[0]);
|
||||
EXPECT_EQ("AllocationsList\n", comments[1]);
|
||||
EXPECT_EQ("PatchInfoData\n", mockAubFileStream->comments[0]);
|
||||
EXPECT_EQ("AllocationsList\n", mockAubFileStream->comments[1]);
|
||||
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenFirstAddCommentsFailsThenFunctionReturnsFalse) {
|
||||
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
|
||||
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
|
@ -799,14 +783,15 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenFirstA
|
|||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
|
||||
|
||||
aubCsr->stream = mockAubFileStream.get();
|
||||
mockAubFileStream->addCommentResult = false;
|
||||
|
||||
EXPECT_CALL(*mockAubFileStream, addComment(_)).Times(1).WillOnce(Return(false));
|
||||
bool result = aubCsr->addPatchInfoComments();
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_EQ(1u, mockAubFileStream->addCommentCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenSecondAddCommentsFailsThenFunctionReturnsFalse) {
|
||||
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
|
||||
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
|
@ -815,13 +800,15 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenSecond
|
|||
|
||||
aubCsr->stream = mockAubFileStream.get();
|
||||
|
||||
EXPECT_CALL(*mockAubFileStream, addComment(_)).Times(2).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
mockAubFileStream->addCommentResults = {true, false};
|
||||
|
||||
bool result = aubCsr->addPatchInfoComments();
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenPatchInfoDataObjectsAddedThenCommentsAreNotEmpty) {
|
||||
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
|
||||
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
|
@ -836,23 +823,17 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenPatchI
|
|||
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData[0]));
|
||||
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData[1]));
|
||||
|
||||
std::vector<std::string> comments;
|
||||
|
||||
EXPECT_CALL(*mockAubFileStream, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool {
|
||||
comments.push_back(std::string(str));
|
||||
return true;
|
||||
}));
|
||||
bool result = aubCsr->addPatchInfoComments();
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
ASSERT_EQ(2u, comments.size());
|
||||
ASSERT_EQ(2u, mockAubFileStream->comments.size());
|
||||
|
||||
EXPECT_EQ("PatchInfoData", comments[0].substr(0, 13));
|
||||
EXPECT_EQ("AllocationsList", comments[1].substr(0, 15));
|
||||
EXPECT_EQ("PatchInfoData", mockAubFileStream->comments[0].substr(0, 13));
|
||||
EXPECT_EQ("AllocationsList", mockAubFileStream->comments[1].substr(0, 15));
|
||||
|
||||
std::string line;
|
||||
std::istringstream input1;
|
||||
input1.str(comments[0]);
|
||||
input1.str(mockAubFileStream->comments[0]);
|
||||
|
||||
uint32_t lineNo = 0;
|
||||
while (std::getline(input1, line)) {
|
||||
|
@ -871,7 +852,7 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenPatchI
|
|||
lineNo = 0;
|
||||
|
||||
std::istringstream input2;
|
||||
input2.str(comments[1]);
|
||||
input2.str(mockAubFileStream->comments[1]);
|
||||
while (std::getline(input2, line)) {
|
||||
if (line.substr(0, 15) == "AllocationsList") {
|
||||
continue;
|
||||
|
@ -888,10 +869,11 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenPatchI
|
|||
EXPECT_TRUE(line.size() > 9);
|
||||
lineNo++;
|
||||
}
|
||||
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenSourceAllocationIsNullThenDoNotAddToAllocationsList) {
|
||||
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
|
||||
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
|
@ -903,23 +885,17 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenSource
|
|||
PatchInfoData patchInfoData = {0x0, 0u, PatchInfoAllocationType::Default, 0xBBBBBBBB, 0u, PatchInfoAllocationType::Default};
|
||||
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData));
|
||||
|
||||
std::vector<std::string> comments;
|
||||
|
||||
EXPECT_CALL(*mockAubFileStream, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool {
|
||||
comments.push_back(std::string(str));
|
||||
return true;
|
||||
}));
|
||||
bool result = aubCsr->addPatchInfoComments();
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
ASSERT_EQ(2u, comments.size());
|
||||
ASSERT_EQ(2u, mockAubFileStream->comments.size());
|
||||
|
||||
ASSERT_EQ("PatchInfoData", comments[0].substr(0, 13));
|
||||
ASSERT_EQ("AllocationsList", comments[1].substr(0, 15));
|
||||
ASSERT_EQ("PatchInfoData", mockAubFileStream->comments[0].substr(0, 13));
|
||||
ASSERT_EQ("AllocationsList", mockAubFileStream->comments[1].substr(0, 15));
|
||||
|
||||
std::string line;
|
||||
std::istringstream input;
|
||||
input.str(comments[1]);
|
||||
input.str(mockAubFileStream->comments[1]);
|
||||
|
||||
uint32_t lineNo = 0;
|
||||
|
||||
|
@ -940,10 +916,11 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenSource
|
|||
EXPECT_TRUE(line.size() > 9);
|
||||
lineNo++;
|
||||
}
|
||||
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenTargetAllocationIsNullThenDoNotAddToAllocationsList) {
|
||||
auto mockAubFileStream = std::make_unique<GmockAubFileStream>();
|
||||
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
|
@ -955,23 +932,17 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenTarget
|
|||
PatchInfoData patchInfoData = {0xAAAAAAAA, 0u, PatchInfoAllocationType::Default, 0x0, 0u, PatchInfoAllocationType::Default};
|
||||
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData));
|
||||
|
||||
std::vector<std::string> comments;
|
||||
|
||||
EXPECT_CALL(*mockAubFileStream, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool {
|
||||
comments.push_back(std::string(str));
|
||||
return true;
|
||||
}));
|
||||
bool result = aubCsr->addPatchInfoComments();
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
ASSERT_EQ(2u, comments.size());
|
||||
ASSERT_EQ(2u, mockAubFileStream->comments.size());
|
||||
|
||||
ASSERT_EQ("PatchInfoData", comments[0].substr(0, 13));
|
||||
ASSERT_EQ("AllocationsList", comments[1].substr(0, 15));
|
||||
ASSERT_EQ("PatchInfoData", mockAubFileStream->comments[0].substr(0, 13));
|
||||
ASSERT_EQ("AllocationsList", mockAubFileStream->comments[1].substr(0, 15));
|
||||
|
||||
std::string line;
|
||||
std::istringstream input;
|
||||
input.str(comments[1]);
|
||||
input.str(mockAubFileStream->comments[1]);
|
||||
|
||||
uint32_t lineNo = 0;
|
||||
|
||||
|
@ -992,6 +963,7 @@ HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenTarget
|
|||
EXPECT_TRUE(line.size() > 9);
|
||||
lineNo++;
|
||||
}
|
||||
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenCreateFullFilePathIsCalledForMultipleDevicesThenFileNameIsExtendedWithSuffixToIndicateMultipleDevices) {
|
||||
|
|
Loading…
Reference in New Issue