2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-03-15 19:39:58 +08:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-05-21 18:22:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_cif.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#include "cif/builtins/memory/buffer/buffer.h"
|
2018-02-21 04:26:24 +08:00
|
|
|
#include "cif/export/library_api.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
bool failCreateCifMain = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace CIF {
|
|
|
|
|
|
|
|
namespace Builtins {
|
|
|
|
|
|
|
|
template <typename... ArgsT>
|
2021-03-15 19:39:58 +08:00
|
|
|
Buffer<0>::Buffer(ArgsT &&...args) {
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Buffer<0>::~Buffer() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BufferSimple::SetAllocator(CIF::Builtins::AllocatorT allocator, CIF::Builtins::DeallocatorT deallocator,
|
|
|
|
CIF::Builtins::ReallocatorT reallocator) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BufferSimple::SetUnderlyingStorage(void *memory, size_t size, CIF::Builtins::DeallocatorT deallocator) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BufferSimple::SetUnderlyingStorage(const void *memory, size_t size) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void *BufferSimple::DetachAllocation() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const void *BufferSimple::GetMemoryRaw() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *BufferSimple::GetMemoryRawWriteable() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t BufferSimple::GetSizeRaw() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t BufferSimple::GetCapacityRaw() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BufferSimple::Resize(size_t newSize) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BufferSimple::Reserve(size_t newCapacity) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BufferSimple::Clear() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void BufferSimple::Deallocate() {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BufferSimple::AlignUp(uint32_t alignment) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BufferSimple::PushBackRawBytes(const void *newData, size_t size) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BufferSimple::IsConst() const {
|
|
|
|
return false;
|
|
|
|
}
|
2018-06-13 03:54:39 +08:00
|
|
|
} // namespace Builtins
|
|
|
|
} // namespace CIF
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
std::map<CIF::InterfaceId_t, CreatorFuncT> MockCIFMain::globalCreators;
|
|
|
|
|
|
|
|
bool MockCIFBuffer::failAllocations = false;
|
|
|
|
|
|
|
|
CIF::ICIF *MockCIFBuffer::Create(CIF::InterfaceId_t intId, CIF::Version_t version) {
|
|
|
|
if (failAllocations) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (version != CIF::Builtins::BufferSimple::GetVersion()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new MockCIFBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
MockCIFBuffer::MockCIFBuffer() {
|
|
|
|
}
|
|
|
|
|
|
|
|
MockCIFMain::MockCIFMain() {
|
|
|
|
defaultCreators[CIF::Builtins::BufferSimple::GetInterfaceId()] = MockCIFBuffer::Create;
|
|
|
|
}
|
|
|
|
|
|
|
|
CIF::ICIF *MockCIFMain::CreateInterfaceImpl(CIF::InterfaceId_t intId, CIF::Version_t version) {
|
|
|
|
auto it = globalCreators.find(intId);
|
|
|
|
if ((it == globalCreators.end()) || (it->second == nullptr)) {
|
|
|
|
it = defaultCreators.find(intId);
|
|
|
|
if ((it == defaultCreators.end()) || (it->second == nullptr)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return it->second(intId, version);
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
extern CIF::CIFMain *CreateCIFMainImpl() {
|
2019-03-26 18:59:46 +08:00
|
|
|
if (NEO::failCreateCifMain) {
|
2017-12-21 07:45:38 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
return new NEO::MockCIFMain;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|