Add new IO functions

Related-To: NEO-5718

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2021-04-16 12:59:40 +02:00
committed by Compute-Runtime-Automation
parent 927c097b0e
commit e0b5f2f7f7
4 changed files with 51 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -13,11 +13,21 @@ fopenFuncPtr fopenPtr = &mockFopen;
vfprintfFuncPtr vfprintfPtr = &mockVfptrinf;
fcloseFuncPtr fclosePtr = &mockFclose;
getenvFuncPtr getenvPtr = &mockGetenv;
fseekFuncPtr fseekPtr = &mockFseek;
ftellFuncPtr ftellPtr = &mockFtell;
rewindFuncPtr rewindPtr = &mockRewind;
freadFuncPtr freadPtr = &mockFread;
uint32_t mockFopenCalled = 0;
uint32_t mockVfptrinfCalled = 0;
uint32_t mockFcloseCalled = 0;
uint32_t mockGetenvCalled = 0;
uint32_t mockFseekCalled = 0;
uint32_t mockFtellCalled = 0;
long int mockFtellReturn = 0;
uint32_t mockRewindCalled = 0;
uint32_t mockFreadCalled = 0;
size_t mockFreadReturn = 0;
std::unordered_map<std::string, std::string> *mockableEnvValues = nullptr;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -18,6 +18,12 @@ extern uint32_t mockFopenCalled;
extern uint32_t mockVfptrinfCalled;
extern uint32_t mockFcloseCalled;
extern uint32_t mockGetenvCalled;
extern uint32_t mockFseekCalled;
extern uint32_t mockFtellCalled;
extern long int mockFtellReturn;
extern uint32_t mockRewindCalled;
extern uint32_t mockFreadCalled;
extern size_t mockFreadReturn;
extern std::unordered_map<std::string, std::string> *mockableEnvValues;
@ -44,5 +50,24 @@ inline char *mockGetenv(const char *name) noexcept {
return nullptr;
}
inline int mockFseek(FILE *stream, long int offset, int origin) {
mockFseekCalled++;
return 0;
}
inline long int mockFtell(FILE *stream) {
mockFtellCalled++;
return mockFtellReturn;
}
inline void mockRewind(FILE *stream) {
mockRewindCalled++;
}
inline size_t mockFread(void *ptr, size_t size, size_t count, FILE *stream) {
mockFreadCalled++;
return mockFreadReturn;
}
} // namespace IoFunctions
} // namespace NEO