OclocInvoke suppress print to stdout if has output

Suppressing output could be achieved with quiet option "-q",
but some information was gone because of it.
Call to oclocInvoke with output parameters passed should not
print message to stdout. All messages should be stored,
and returned to the user via output as stdout.log file.
This commit turns off printing messages to stdout when
output parameters are present.

Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
Krystian Chmielewski
2022-01-11 13:03:13 +00:00
committed by Compute-Runtime-Automation
parent 2194b647e9
commit 0089cb698f
4 changed files with 57 additions and 6 deletions

View File

@@ -2063,4 +2063,52 @@ TEST(OfflineCompilerTest, GivenDebugFlagWhenSetStatelessToStatefullBufferOffsetF
}
}
struct WhiteBoxOclocArgHelper : public OclocArgHelper {
using OclocArgHelper::messagePrinter;
using OclocArgHelper::OclocArgHelper;
};
TEST(OclocArgHelperTest, GivenOutputSuppressMessagesAndSaveItToFile) {
uint32_t numOutputs = 0U;
uint64_t *lenOutputs = nullptr;
uint8_t **outputs = nullptr;
char **nameOutputs = nullptr;
auto helper = std::unique_ptr<WhiteBoxOclocArgHelper>(new WhiteBoxOclocArgHelper(0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr,
&numOutputs, &outputs, &lenOutputs, &nameOutputs));
EXPECT_TRUE(helper->messagePrinter.isSuppressed());
ConstStringRef printMsg = "Hello world!";
testing::internal::CaptureStdout();
helper->printf(printMsg.data());
std::string capturedStdout = testing::internal::GetCapturedStdout();
EXPECT_TRUE(capturedStdout.empty());
helper.reset(); // Delete helper. Destructor saves data to output
EXPECT_EQ(1U, numOutputs);
EXPECT_EQ(printMsg.length(), lenOutputs[0]);
EXPECT_STREQ("stdout.log", nameOutputs[0]);
std::string stdoutStr = std::string(reinterpret_cast<const char *>(outputs[0]),
static_cast<size_t>(lenOutputs[0]));
EXPECT_STREQ(printMsg.data(), stdoutStr.c_str());
delete[] nameOutputs[0];
delete[] outputs[0];
delete[] nameOutputs;
delete[] outputs;
delete[] lenOutputs;
}
TEST(OclocArgHelperTest, GivenNoOutputPrintMessages) {
auto helper = WhiteBoxOclocArgHelper(0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr);
EXPECT_FALSE(helper.messagePrinter.isSuppressed());
ConstStringRef printMsg = "Hello world!";
testing::internal::CaptureStdout();
helper.printf(printMsg.data());
std::string capturedStdout = testing::internal::GetCapturedStdout();
EXPECT_STREQ(printMsg.data(), capturedStdout.c_str());
}
} // namespace NEO