mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
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:
committed by
Compute-Runtime-Automation
parent
679d3a2be5
commit
b75fbe8e2c
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user