Refactor of IO functions

Related-To: NEO-4562

Signed-off-by: Konstanty Misiak <konstanty.misiak@intel.com>
This commit is contained in:
Konstanty Misiak
2023-02-13 09:55:24 +00:00
committed by Compute-Runtime-Automation
parent c0f0472b6e
commit 1f37e69fd2
13 changed files with 27 additions and 16 deletions

View File

@@ -142,7 +142,6 @@ TEST(EuThread, GivenThreadStateStoppedWhenVerifyingStopWithEvenCounterThenFalseR
}
TEST(EuThread, GivenEnabledErrorLogsWhenThreadStateStoppedAndVerifyingStopWithEvenCounterThenErrorMessageIsPrinted) {
DebugManagerStateRestore restorer;
NEO::DebugManager.flags.DebuggerLogBitmask.set(NEO::DebugVariables::DEBUGGER_LOG_BITMASK::LOG_ERROR);
@@ -215,7 +214,6 @@ TEST(EuThread, GivenEnabledErrorLogsWhenThreadStateStoppedAndVerifyingStopWithOd
}
TEST(EuThread, GivenEnabledErrorLogsWhenThreadStateRunningAndVerifyingStopWithOddCounterEqualToPreviousThenErrorMessageIsPrinted) {
DebugManagerStateRestore restorer;
NEO::DebugManager.flags.DebuggerLogBitmask.set(NEO::DebugVariables::DEBUGGER_LOG_BITMASK::LOG_ERROR);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@@ -9,6 +9,7 @@
#include "shared/source/helpers/array_count.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/timestamp_packet.h"
#include "shared/source/utilities/io_functions.h"
#include "shared/source/utilities/tag_allocator.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
@@ -195,7 +196,7 @@ struct AubWalkerPartitionTest : public AubWalkerPartitionFixture,
dispatchParamters.localWorkSize[2],
partitionType,
partitionCount);
fflush(stdout);
IoFunctions::fflushPtr(stdout);
goodWorkingSizeGenerated = true;
}
};

View File

@@ -7,6 +7,7 @@
#pragma once
#include "shared/source/helpers/string.h"
#include "shared/source/utilities/io_functions.h"
#include <cstdint>
#include <memory>
@@ -37,13 +38,13 @@ extern FileLogger<globalDebugFunctionalityLevel> &fileLoggerInstance();
template <typename StreamT, typename... Args>
void flushDebugStream(StreamT stream, Args &&...args) {
fflush(stream);
IoFunctions::fflushPtr(stream);
}
template <typename... Args>
void printDebugString(bool showDebugLogs, Args &&...args) {
if (showDebugLogs) {
fprintf(std::forward<Args>(args)...);
IoFunctions::fprintf(std::forward<Args>(args)...);
flushDebugStream(args...);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -18,5 +18,6 @@ ftellFuncPtr ftellPtr = &ftell;
rewindFuncPtr rewindPtr = &rewind;
freadFuncPtr freadPtr = &fread;
fwriteFuncPtr fwritePtr = &fwrite;
fflushFuncPtr fflushPtr = &fflush;
} // namespace IoFunctions
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -21,6 +21,7 @@ using ftellFuncPtr = decltype(&ftell);
using rewindFuncPtr = decltype(&rewind);
using freadFuncPtr = decltype(&fread);
using fwriteFuncPtr = decltype(&fwrite);
using fflushFuncPtr = decltype(&fflush);
extern fopenFuncPtr fopenPtr;
extern vfprintfFuncPtr vfprintfPtr;
@@ -31,6 +32,7 @@ extern ftellFuncPtr ftellPtr;
extern rewindFuncPtr rewindPtr;
extern freadFuncPtr freadPtr;
extern fwriteFuncPtr fwritePtr;
extern fflushFuncPtr fflushPtr;
inline int fprintf(FILE *fileDesc, char const *const formatStr, ...) {
va_list args;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -18,6 +18,7 @@ ftellFuncPtr ftellPtr = &mockFtell;
rewindFuncPtr rewindPtr = &mockRewind;
freadFuncPtr freadPtr = &mockFread;
fwriteFuncPtr fwritePtr = &mockFwrite;
fflushFuncPtr fflushPtr = &mockFflush;
uint32_t mockFopenCalled = 0;
FILE *mockFopenReturned = reinterpret_cast<FILE *>(0x40);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -42,7 +42,7 @@ inline FILE *mockFopen(const char *filename, const char *mode) {
inline int mockVfptrinf(FILE *stream, const char *format, va_list arg) {
mockVfptrinfCalled++;
if (mockVfptrinfUseStdioFunction) {
if (stream == stdout || stream == stderr || mockVfptrinfUseStdioFunction) {
return vfprintf(stream, format, arg);
}
return 0x10;
@@ -85,5 +85,12 @@ inline size_t mockFwrite(const void *ptr, size_t size, size_t nmemb, FILE *strea
return mockFwriteReturn;
}
inline int mockFflush(FILE *stream) {
if (stream == stdout || stream == stderr)
return fflush(stream);
return 0;
}
} // namespace IoFunctions
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
* Copyright (C) 2019-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Intel Corporation
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*