|
18 | 18 | #include "test.h" |
19 | 19 | #include "unit_tests/fixtures/device_fixture.h" |
20 | 20 | #include "unit_tests/helpers/debug_manager_state_restore.h" |
| 21 | +#include "unit_tests/mocks/mock_aub_file_stream.h" |
21 | 22 | #include "unit_tests/mocks/mock_aub_subcapture_manager.h" |
22 | 23 | #include "unit_tests/mocks/mock_csr.h" |
23 | 24 | #include "unit_tests/mocks/mock_gmm.h" |
@@ -98,33 +99,6 @@ struct MockAubCsrToTestDumpAubNonWritable : public AUBCommandStreamReceiverHw<Gf |
98 | 99 | } |
99 | 100 | }; |
100 | 101 |
|
101 | | -struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream { |
102 | | - bool init(uint32_t stepping, uint32_t device) override { |
103 | | - initCalledCnt++; |
104 | | - return true; |
105 | | - } |
106 | | - void flush() override { |
107 | | - flushCalled = true; |
108 | | - } |
109 | | - std::unique_lock<std::mutex> lockStream() override { |
110 | | - lockStreamCalled = true; |
111 | | - return AUBCommandStreamReceiver::AubFileStream::lockStream(); |
112 | | - } |
113 | | - void expectMemory(uint64_t physAddress, const void *memory, size_t size, uint32_t addressSpace) override { |
114 | | - physAddressCapturedFromExpectMemory = physAddress; |
115 | | - memoryCapturedFromExpectMemory = reinterpret_cast<uintptr_t>(memory); |
116 | | - sizeCapturedFromExpectMemory = size; |
117 | | - addressSpaceCapturedFromExpectMemory = addressSpace; |
118 | | - } |
119 | | - uint32_t initCalledCnt = 0; |
120 | | - bool flushCalled = false; |
121 | | - bool lockStreamCalled = false; |
122 | | - uint64_t physAddressCapturedFromExpectMemory = 0; |
123 | | - uintptr_t memoryCapturedFromExpectMemory = 0; |
124 | | - size_t sizeCapturedFromExpectMemory = 0; |
125 | | - uint32_t addressSpaceCapturedFromExpectMemory = 0; |
126 | | -}; |
127 | | - |
128 | 102 | struct GmockAubFileStream : public AUBCommandStreamReceiver::AubFileStream { |
129 | 103 | MOCK_METHOD1(addComment, bool(const char *message)); |
130 | 104 | }; |
@@ -229,6 +203,28 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipl |
229 | 203 | EXPECT_EQ(aubCsr1->stream, aubCsr2->stream); |
230 | 204 | } |
231 | 205 |
|
| 206 | +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameFileStream) { |
| 207 | + ExecutionEnvironment executionEnvironment; |
| 208 | + auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment); |
| 209 | + auto streamProvider1 = executionEnvironment.aubCenter->getStreamProvider(); |
| 210 | + EXPECT_NE(nullptr, streamProvider1); |
| 211 | + auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment); |
| 212 | + auto streamProvider2 = executionEnvironment.aubCenter->getStreamProvider(); |
| 213 | + EXPECT_NE(nullptr, streamProvider2); |
| 214 | + EXPECT_EQ(streamProvider1, streamProvider2); |
| 215 | +} |
| 216 | + |
| 217 | +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSamePhysicalAddressAllocator) { |
| 218 | + ExecutionEnvironment executionEnvironment; |
| 219 | + auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment); |
| 220 | + auto physicalAddressAlocator1 = executionEnvironment.aubCenter->getPhysicalAddressAllocator(); |
| 221 | + EXPECT_NE(nullptr, physicalAddressAlocator1); |
| 222 | + auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment); |
| 223 | + auto physicalAddressAlocator2 = executionEnvironment.aubCenter->getPhysicalAddressAllocator(); |
| 224 | + EXPECT_NE(nullptr, physicalAddressAlocator2); |
| 225 | + EXPECT_EQ(physicalAddressAlocator1, physicalAddressAlocator2); |
| 226 | +} |
| 227 | + |
232 | 228 | HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenItIsCreatedThenFileIsNotCreated) { |
233 | 229 | DebugManagerStateRestore stateRestore; |
234 | 230 | DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Filter)); |
@@ -260,84 +256,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrInSubCaptureModeWhenItIsCreat |
260 | 256 | EXPECT_STREQ(DebugManager.flags.AUBDumpFilterKernelName.get().c_str(), aubCsr->subCaptureManager->subCaptureFilter.dumpKernelName.c_str()); |
261 | 257 | } |
262 | 258 |
|
263 | | -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenInitFileIsCalledWithInvalidFileNameThenFileIsNotOpened) { |
264 | | - std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, "", true, *pDevice->executionEnvironment)); |
265 | | - std::string invalidFileName = ""; |
266 | | - |
267 | | - aubCsr->initFile(invalidFileName); |
268 | | - EXPECT_FALSE(aubCsr->isFileOpen()); |
269 | | -} |
270 | | - |
271 | | -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenInitFileIsCalledThenFileIsOpenedAndFileNameIsStored) { |
272 | | - std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, "", true, *pDevice->executionEnvironment)); |
273 | | - std::string fileName = "file_name.aub"; |
274 | | - |
275 | | - aubCsr->initFile(fileName); |
276 | | - EXPECT_TRUE(aubCsr->isFileOpen()); |
277 | | - EXPECT_STREQ(fileName.c_str(), aubCsr->getFileName().c_str()); |
278 | | - |
279 | | - aubCsr->closeFile(); |
280 | | - EXPECT_FALSE(aubCsr->isFileOpen()); |
281 | | - EXPECT_TRUE(aubCsr->getFileName().empty()); |
282 | | -} |
283 | | - |
284 | | -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenReopenFileIsCalledThenFileWithSpecifiedNameIsReopened) { |
285 | | - auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment); |
286 | | - std::string fileName = "file_name.aub"; |
287 | | - std::string newFileName = "new_file_name.aub"; |
288 | | - |
289 | | - aubCsr->reopenFile(fileName); |
290 | | - EXPECT_TRUE(aubCsr->isFileOpen()); |
291 | | - EXPECT_STREQ(fileName.c_str(), aubCsr->getFileName().c_str()); |
292 | | - |
293 | | - aubCsr->reopenFile(newFileName); |
294 | | - EXPECT_TRUE(aubCsr->isFileOpen()); |
295 | | - EXPECT_STREQ(newFileName.c_str(), aubCsr->getFileName().c_str()); |
296 | | -} |
297 | | - |
298 | | -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenInitFileIsCalledThenFileShouldBeInitializedWithHeaderOnce) { |
299 | | - auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment); |
300 | | - std::string fileName = "file_name.aub"; |
301 | | - |
302 | | - std::unique_ptr<AUBCommandStreamReceiver::AubFileStream> mockAubFileStream(new MockAubFileStream()); |
303 | | - MockAubFileStream *mockAubFileStreamPtr = static_cast<MockAubFileStream *>(mockAubFileStream.get()); |
304 | | - ASSERT_NE(nullptr, mockAubFileStreamPtr); |
305 | | - aubCsr->stream = mockAubFileStreamPtr; |
306 | | - |
307 | | - aubCsr->initFile(fileName); |
308 | | - aubCsr->initFile(fileName); |
309 | | - |
310 | | - EXPECT_EQ(1u, mockAubFileStreamPtr->initCalledCnt); |
311 | | -} |
312 | | - |
313 | | -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenOpenFileIsCalledThenFileStreamShouldBeLocked) { |
314 | | - auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(true, true, true); |
315 | | - auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>(); |
316 | | - std::string fileName = "file_name.aub"; |
317 | | - |
318 | | - std::unique_ptr<AUBCommandStreamReceiver::AubFileStream> mockAubFileStream(new MockAubFileStream()); |
319 | | - MockAubFileStream *mockAubFileStreamPtr = static_cast<MockAubFileStream *>(mockAubFileStream.get()); |
320 | | - ASSERT_NE(nullptr, mockAubFileStreamPtr); |
321 | | - aubCsr->stream = mockAubFileStreamPtr; |
322 | | - |
323 | | - aubCsr->openFile(fileName); |
324 | | - EXPECT_TRUE(mockAubFileStreamPtr->lockStreamCalled); |
325 | | -} |
326 | | - |
327 | | -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenReopenFileIsCalledThenFileStreamShouldBeLocked) { |
328 | | - auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(true, true, true); |
329 | | - auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>(); |
330 | | - std::string fileName = "file_name.aub"; |
331 | | - |
332 | | - std::unique_ptr<AUBCommandStreamReceiver::AubFileStream> mockAubFileStream(new MockAubFileStream()); |
333 | | - MockAubFileStream *mockAubFileStreamPtr = static_cast<MockAubFileStream *>(mockAubFileStream.get()); |
334 | | - ASSERT_NE(nullptr, mockAubFileStreamPtr); |
335 | | - aubCsr->stream = mockAubFileStreamPtr; |
336 | | - |
337 | | - aubCsr->reopenFile(fileName); |
338 | | - EXPECT_TRUE(mockAubFileStreamPtr->lockStreamCalled); |
339 | | -} |
340 | | - |
341 | 259 | HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenFileStreamShouldBeLocked) { |
342 | 260 | auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(true, true, true); |
343 | 261 | auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>(); |
|
0 commit comments