mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 22:08:53 +08:00
fix: handle empty print format in case without string map
https://github.com/intel/compute-runtime/issues/635 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c93b084a4b
commit
1a1bd04d4a
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -45,7 +45,9 @@ void PrintFormatter::printKernelOutput(const std::function<void(char *)> &print)
|
||||
while (currentOffset + sizeof(char *) <= printfOutputBufferSize) {
|
||||
char *formatString = nullptr;
|
||||
read(&formatString);
|
||||
printString(formatString, print);
|
||||
if (formatString != nullptr) {
|
||||
printString(formatString, print);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,6 +957,16 @@ TEST_F(PrintFormatterTest, GivenNoStringMapAndBufferWithFormatStringThenItIsPrin
|
||||
EXPECT_STREQ(formatString, output);
|
||||
}
|
||||
|
||||
TEST_F(PrintFormatterTest, GivenNoStringMapAndBufferWithEmptyFormatThenNothingIsPrinted) {
|
||||
printFormatter.reset(new PrintFormatter(static_cast<uint8_t *>(data->getUnderlyingBuffer()), printfBufferSize, true));
|
||||
const char *formatString = nullptr;
|
||||
storeData(formatString);
|
||||
|
||||
char output[maxPrintfOutputLength]{};
|
||||
printFormatter->printKernelOutput([&output](char *str) { strncpy_s(output, maxPrintfOutputLength, str, maxPrintfOutputLength - 1); });
|
||||
EXPECT_STREQ("", output);
|
||||
}
|
||||
|
||||
TEST_F(PrintFormatterTest, GivenNoStringMapAndBufferWithFormatStringAnd2StringsThenDataIsParsedAndPrintedProperly) {
|
||||
printFormatter.reset(new PrintFormatter(static_cast<uint8_t *>(data->getUnderlyingBuffer()), printfBufferSize, true));
|
||||
const char *formatString = "%s %s";
|
||||
|
||||
Reference in New Issue
Block a user