2020-03-17 12:19:38 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-03-27 16:32:07 +01:00
|
|
|
#include "shared/source/utilities/io_functions.h"
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
2020-06-08 16:19:52 +02:00
|
|
|
#include <string>
|
2020-07-30 13:03:04 +02:00
|
|
|
#include <unordered_map>
|
2020-03-17 12:19:38 +01:00
|
|
|
|
|
|
|
|
namespace NEO {
|
2020-03-27 16:32:07 +01:00
|
|
|
namespace IoFunctions {
|
2020-03-17 12:19:38 +01:00
|
|
|
extern uint32_t mockFopenCalled;
|
|
|
|
|
extern uint32_t mockVfptrinfCalled;
|
|
|
|
|
extern uint32_t mockFcloseCalled;
|
2020-07-13 15:14:16 +02:00
|
|
|
extern uint32_t mockGetenvCalled;
|
2020-03-17 12:19:38 +01:00
|
|
|
|
2020-07-30 13:03:04 +02:00
|
|
|
extern std::unordered_map<std::string, std::string> *mockableEnvValues;
|
2020-06-08 16:19:52 +02:00
|
|
|
|
2020-03-19 10:53:05 +01:00
|
|
|
inline FILE *mockFopen(const char *filename, const char *mode) {
|
2020-03-17 12:19:38 +01:00
|
|
|
mockFopenCalled++;
|
|
|
|
|
return reinterpret_cast<FILE *>(0x40);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-19 10:53:05 +01:00
|
|
|
inline int mockVfptrinf(FILE *stream, const char *format, va_list arg) {
|
2020-03-17 12:19:38 +01:00
|
|
|
mockVfptrinfCalled++;
|
|
|
|
|
return 0x10;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-19 10:53:05 +01:00
|
|
|
inline int mockFclose(FILE *stream) {
|
2020-03-17 12:19:38 +01:00
|
|
|
mockFcloseCalled++;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-06-08 16:19:52 +02:00
|
|
|
|
|
|
|
|
inline char *mockGetenv(const char *name) noexcept {
|
2020-07-13 15:14:16 +02:00
|
|
|
mockGetenvCalled++;
|
2020-07-30 13:03:04 +02:00
|
|
|
if (mockableEnvValues != nullptr && mockableEnvValues->find(name) != mockableEnvValues->end()) {
|
|
|
|
|
return const_cast<char *>(mockableEnvValues->find(name)->second.c_str());
|
2020-06-08 16:19:52 +02:00
|
|
|
}
|
2020-10-09 10:24:12 +02:00
|
|
|
return nullptr;
|
2020-06-08 16:19:52 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 16:32:07 +01:00
|
|
|
} // namespace IoFunctions
|
2020-03-17 12:19:38 +01:00
|
|
|
} // namespace NEO
|