Skip to content

Commit 010f1a8

Browse files
Source level debugger test improvements.
Change-Id: I88c0c5d7f49b9e8c27ed2c75c6e2eb63b22437bf
1 parent d63a1a7 commit 010f1a8

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -19,15 +19,36 @@
1919
#include "test.h"
2020
#include <memory>
2121

22-
typedef ::testing::Test CommandStreamReceiverWithActiveDebuggerTest;
22+
class CommandStreamReceiverWithActiveDebuggerTest : public ::testing::Test {
23+
protected:
24+
template <typename FamilyType>
25+
auto createCSR() {
26+
hwInfo = nullptr;
27+
executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
28+
hwInfo->capabilityTable = platformDevices[0]->capabilityTable;
29+
hwInfo->capabilityTable.sourceLevelDebuggerSupported = true;
30+
31+
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], *executionEnvironment);
32+
33+
executionEnvironment->commandStreamReceivers.resize(1);
34+
executionEnvironment->commandStreamReceivers[0][0].reset(mockCsr);
35+
auto mockMemoryManager = new MockMemoryManager(*executionEnvironment);
36+
executionEnvironment->memoryManager.reset(mockMemoryManager);
37+
38+
device.reset(Device::create<MockDevice>(&hwInfo[0], executionEnvironment, 0));
39+
device->setSourceLevelDebuggerActive(true);
40+
41+
return mockCsr;
42+
}
43+
44+
std::unique_ptr<MockDevice> device;
45+
ExecutionEnvironment *executionEnvironment = nullptr;
46+
HardwareInfo *hwInfo = nullptr;
47+
};
2348

2449
HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) {
25-
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
26-
device->setSourceLevelDebuggerActive(true);
27-
device->allocatePreemptionAllocationIfNotPresent();
28-
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], *device->executionEnvironment);
2950

30-
device->resetCommandStreamReceiver(mockCsr);
51+
auto mockCsr = createCSR<FamilyType>();
3152

3253
CommandQueueHw<FamilyType> commandQueue(nullptr, device.get(), 0);
3354
auto &commandStream = commandQueue.getCS(4096u);
@@ -50,7 +71,7 @@ HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebugger
5071
*device);
5172

5273
auto sipType = SipKernel::getSipKernelType(device->getHardwareInfo().pPlatform->eRenderCoreFamily, true);
53-
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *device.get()).getSipAllocation();
74+
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *device).getSipAllocation();
5475
bool found = false;
5576
for (auto allocation : mockCsr->copyOfAllocations) {
5677
if (allocation == sipAllocation) {
@@ -66,15 +87,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCs
6687
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
6788
using STATE_SIP = typename FamilyType::STATE_SIP;
6889

69-
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
90+
auto mockCsr = createCSR<FamilyType>();
7091

7192
if (device->getHardwareInfo().capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
72-
device->setSourceLevelDebuggerActive(true);
73-
device->allocatePreemptionAllocationIfNotPresent();
74-
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], *device->executionEnvironment);
75-
76-
device->resetCommandStreamReceiver(mockCsr);
77-
7893
CommandQueueHw<FamilyType> commandQueue(nullptr, device.get(), 0);
7994
auto &commandStream = commandQueue.getCS(4096u);
8095
auto &preambleStream = mockCsr->getCS(0);
@@ -97,7 +112,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCs
97112
*device);
98113

99114
auto sipType = SipKernel::getSipKernelType(device->getHardwareInfo().pPlatform->eRenderCoreFamily, true);
100-
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *device.get()).getSipAllocation();
115+
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *device).getSipAllocation();
101116

102117
HardwareParse hwParser;
103118
hwParser.parseCommands<FamilyType>(preambleStream);
@@ -122,23 +137,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCs
122137
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
123138
using STATE_SIP = typename FamilyType::STATE_SIP;
124139

125-
HardwareInfo *hwInfo = nullptr;
126-
auto executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
127-
hwInfo->capabilityTable = platformDevices[0]->capabilityTable;
128-
hwInfo->capabilityTable.sourceLevelDebuggerSupported = true;
129-
130-
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], *executionEnvironment);
131-
132-
executionEnvironment->commandStreamReceivers.resize(1);
133-
executionEnvironment->commandStreamReceivers[0][0].reset(mockCsr);
134-
auto mockMemoryManager = new MockMemoryManager(*executionEnvironment);
135-
executionEnvironment->memoryManager.reset(mockMemoryManager);
140+
auto mockCsr = createCSR<FamilyType>();
136141

137-
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(&hwInfo[0], executionEnvironment, 0));
138142
if (device->getHardwareInfo().capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
139-
device->setSourceLevelDebuggerActive(true);
140-
device->allocatePreemptionAllocationIfNotPresent();
141-
142143
mockCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
143144

144145
CommandQueueHw<FamilyType> commandQueue(nullptr, device.get(), 0);
@@ -174,7 +175,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCs
174175
*device);
175176

176177
auto sipType = SipKernel::getSipKernelType(device->getHardwareInfo().pPlatform->eRenderCoreFamily, true);
177-
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *device.get()).getSipAllocation();
178+
auto sipAllocation = device->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *device).getSipAllocation();
178179

179180
HardwareParse hwParser;
180181
hwParser.parseCommands<FamilyType>(preambleStream);

0 commit comments

Comments
 (0)