refactor: mock filesystem in ocloc ult pt.1

Mocked IO operations in ./ocloc_tests application

Mocked gtest stdout capture in ocloc tests

Related-To: NEO-14084
Signed-off-by: Marcel Skierkowski <marcel.skierkowski@intel.com>
This commit is contained in:
Marcel Skierkowski
2025-04-08 14:26:04 +00:00
committed by Compute-Runtime-Automation
parent 679d3a2be5
commit b75fbe8e2c
24 changed files with 2136 additions and 1197 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -19,5 +19,7 @@ rewindFuncPtr rewindPtr = &rewind;
freadFuncPtr freadPtr = &fread;
fwriteFuncPtr fwritePtr = &fwrite;
fflushFuncPtr fflushPtr = &fflush;
mkdirFuncPtr mkdirPtr = &makedir;
} // namespace IoFunctions
} // namespace NEO
} // namespace NEO

View File

@@ -14,18 +14,25 @@
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#endif
namespace NEO {
namespace IoFunctions {
using fopenFuncPtr = FILE *(*)(const char *, const char *);
using vfprintfFuncPtr = int (*)(FILE *, char const *const formatStr, va_list arg);
using fcloseFuncPtr = int (*)(FILE *);
using getenvFuncPtr = decltype(&getenv);
using fseekFuncPtr = decltype(&fseek);
using ftellFuncPtr = decltype(&ftell);
using fseekFuncPtr = int (*)(FILE *, long int, int);
using ftellFuncPtr = long int (*)(FILE *);
using rewindFuncPtr = decltype(&rewind);
using freadFuncPtr = decltype(&fread);
using freadFuncPtr = size_t (*)(void *, size_t, size_t, FILE *);
using fwriteFuncPtr = decltype(&fwrite);
using fflushFuncPtr = decltype(&fflush);
using mkdirFuncPtr = int (*)(const char *);
extern fopenFuncPtr fopenPtr;
extern vfprintfFuncPtr vfprintfPtr;
@@ -37,6 +44,7 @@ extern rewindFuncPtr rewindPtr;
extern freadFuncPtr freadPtr;
extern fwriteFuncPtr fwritePtr;
extern fflushFuncPtr fflushPtr;
extern mkdirFuncPtr mkdirPtr;
inline int fprintf(FILE *fileDesc, char const *const formatStr, ...) {
va_list args;
@@ -64,5 +72,15 @@ inline char *getEnvironmentVariable(const char *name) {
return nullptr;
}
#ifdef _WIN32
inline int makedir(const char *dirName) {
return _mkdir(dirName);
}
#else
inline int makedir(const char *dirName) {
return mkdir(dirName, 0777);
}
#endif
} // namespace IoFunctions
} // namespace NEO
} // namespace NEO