2018-09-26 21:28:11 +08:00
|
|
|
/*
|
2023-02-16 02:19:30 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-09-26 21:28:11 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-07-06 21:44:16 +08:00
|
|
|
#include "shared/source/command_stream/aub_command_stream_receiver.h"
|
2018-10-02 16:37:17 +08:00
|
|
|
|
2021-12-28 20:04:55 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-09-26 21:28:11 +08:00
|
|
|
|
|
|
|
struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
|
|
|
|
bool init(uint32_t stepping, uint32_t device) override {
|
|
|
|
initCalledCnt++;
|
|
|
|
return true;
|
|
|
|
}
|
2019-02-20 05:50:52 +08:00
|
|
|
void open(const char *filePath) override {
|
|
|
|
fileName.assign(filePath);
|
|
|
|
openCalledCnt++;
|
|
|
|
}
|
|
|
|
void close() override {
|
|
|
|
fileName.clear();
|
|
|
|
closeCalled = true;
|
|
|
|
}
|
|
|
|
bool isOpen() const override {
|
|
|
|
isOpenCalled = true;
|
|
|
|
return !fileName.empty();
|
|
|
|
}
|
|
|
|
const std::string &getFileName() const override {
|
|
|
|
getFileNameCalled = true;
|
|
|
|
return fileName;
|
|
|
|
}
|
2018-09-26 21:28:11 +08:00
|
|
|
void flush() override {
|
|
|
|
flushCalled = true;
|
|
|
|
}
|
2019-05-10 23:29:06 +08:00
|
|
|
std::unique_lock<std::mutex> lockStream() override {
|
2018-09-26 21:28:11 +08:00
|
|
|
lockStreamCalled = true;
|
|
|
|
return AUBCommandStreamReceiver::AubFileStream::lockStream();
|
|
|
|
}
|
2020-03-10 22:21:12 +08:00
|
|
|
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue) override {
|
2019-02-20 05:50:52 +08:00
|
|
|
mmioRegisterFromExpectMMIO = mmioRegister;
|
|
|
|
expectedValueFromExpectMMIO = expectedValue;
|
|
|
|
}
|
2018-11-16 18:18:53 +08:00
|
|
|
void expectMemory(uint64_t physAddress, const void *memory, size_t size, uint32_t addressSpace, uint32_t compareOperation) override {
|
2018-09-26 21:28:11 +08:00
|
|
|
physAddressCapturedFromExpectMemory = physAddress;
|
|
|
|
memoryCapturedFromExpectMemory = reinterpret_cast<uintptr_t>(memory);
|
|
|
|
sizeCapturedFromExpectMemory = size;
|
|
|
|
addressSpaceCapturedFromExpectMemory = addressSpace;
|
2018-11-16 18:18:53 +08:00
|
|
|
compareOperationFromExpectMemory = compareOperation;
|
2018-09-26 21:28:11 +08:00
|
|
|
}
|
2019-04-01 15:33:19 +08:00
|
|
|
bool addComment(const char *message) override {
|
2021-12-28 20:04:55 +08:00
|
|
|
addCommentCalled++;
|
|
|
|
comments.push_back(std::string(message));
|
|
|
|
|
|
|
|
if (addCommentCalled <= addCommentResults.size()) {
|
|
|
|
return addCommentResults[addCommentCalled - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return addCommentResult;
|
2019-04-01 15:33:19 +08:00
|
|
|
}
|
2019-01-29 17:39:34 +08:00
|
|
|
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);
|
|
|
|
}
|
2021-12-28 20:04:55 +08:00
|
|
|
uint32_t addCommentCalled = 0u;
|
2019-02-20 05:50:52 +08:00
|
|
|
uint32_t openCalledCnt = 0;
|
|
|
|
std::string fileName = "";
|
2021-12-28 20:04:55 +08:00
|
|
|
bool addCommentResult = true;
|
|
|
|
std::vector<bool> addCommentResults = {};
|
2019-02-20 05:50:52 +08:00
|
|
|
bool closeCalled = false;
|
2018-09-26 21:28:11 +08:00
|
|
|
uint32_t initCalledCnt = 0;
|
2019-02-20 05:50:52 +08:00
|
|
|
mutable bool isOpenCalled = false;
|
|
|
|
mutable bool getFileNameCalled = false;
|
2019-01-29 17:39:34 +08:00
|
|
|
bool registerPollCalled = false;
|
2018-09-26 21:28:11 +08:00
|
|
|
bool flushCalled = false;
|
|
|
|
bool lockStreamCalled = false;
|
2019-02-20 05:50:52 +08:00
|
|
|
uint32_t mmioRegisterFromExpectMMIO = 0;
|
|
|
|
uint32_t expectedValueFromExpectMMIO = 0;
|
2018-09-26 21:28:11 +08:00
|
|
|
uint64_t physAddressCapturedFromExpectMemory = 0;
|
|
|
|
uintptr_t memoryCapturedFromExpectMemory = 0;
|
|
|
|
size_t sizeCapturedFromExpectMemory = 0;
|
|
|
|
uint32_t addressSpaceCapturedFromExpectMemory = 0;
|
2018-11-16 18:18:53 +08:00
|
|
|
uint32_t compareOperationFromExpectMemory = 0;
|
2021-12-28 20:04:55 +08:00
|
|
|
std::vector<std::string> comments;
|
2018-10-02 16:37:17 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|