Improve error reporting in ocloc

Related-To: NEO-6425
Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
This commit is contained in:
Warchulski, Jaroslaw 2022-10-24 10:28:53 +00:00 committed by Compute-Runtime-Automation
parent 0606e8ddf3
commit f0a9533c83
2 changed files with 36 additions and 5 deletions

View File

@ -413,6 +413,33 @@ TEST(OclocApiTests, givenInvalidOclocOptionsFileWhenCmdlineIsPrintedThenTheyAreP
EXPECT_FALSE(output.find("Building with ocloc options:") != std::string::npos);
}
TEST(OclocApiTests, givenInvalidOclocOptionsFileWhenCmdlineIsPrintedThenTheyAreNotPrinted) {
ASSERT_TRUE(fileExists(clFiles + "valid_kernel.cl"));
ASSERT_TRUE(fileExists(clFiles + "valid_kernel_ocloc_options.txt"));
std::string clFileName(clFiles + "valid_kernel.cl");
const char *argv[] = {
"ocloc",
"-qq",
"-file",
clFileName.c_str(),
"-device",
gEnvironment->devicePrefix.c_str()};
unsigned int argc = sizeof(argv) / sizeof(const char *);
testing::internal::CaptureStdout();
int retVal = oclocInvoke(argc, argv,
0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr);
std::string output = testing::internal::GetCapturedStdout();
EXPECT_NE(retVal, NEO::OclocErrorCode::SUCCESS);
EXPECT_FALSE(output.find("Failed with ocloc options from file:\n"
"-invalid_ocloc_option") != std::string::npos);
EXPECT_FALSE(output.find("Building with ocloc options:") != std::string::npos);
}
TEST(OclocApiTests, GivenIncludeHeadersWhenCompilingThenPassesToFclHeadersPackedAsElf) {
auto prevFclDebugVars = NEO::getFclDebugVars();
auto debugVars = prevFclDebugVars;

View File

@ -562,16 +562,16 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
std::string oclocOptionsFromFile;
bool oclocOptionsRead = readOptionsFromFile(oclocOptionsFromFile, oclocOptionsFileName, argHelper);
if (oclocOptionsRead) {
argHelper->printf("Building with ocloc options:\n%s\n", oclocOptionsFromFile.c_str());
if (!isQuiet()) {
argHelper->printf("Building with ocloc options:\n%s\n", oclocOptionsFromFile.c_str());
}
std::istringstream iss(allArgs[0] + " " + oclocOptionsFromFile);
std::vector<std::string> tokens{
std::istream_iterator<std::string>{iss}, std::istream_iterator<std::string>{}};
retVal = parseCommandLine(tokens.size(), tokens);
if (retVal != SUCCESS) {
if (isQuiet()) {
printf("Failed with ocloc options from file:\n%s\n", oclocOptionsFromFile.c_str());
}
argHelper->printf("Failed with ocloc options from file:\n%s\n", oclocOptionsFromFile.c_str());
return retVal;
}
}
@ -732,6 +732,8 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
cacheDir = argv[argIndex + 1];
argIndex++;
} else if ("-q" == currArg) {
quiet = true;
} else if ("-qq" == currArg) {
argHelper->getPrinterRef() = MessagePrinter(true);
quiet = true;
} else if ("-spv_only" == currArg) {
@ -1008,7 +1010,9 @@ Usage: ocloc [compile] -file <filename> -device <device_type> [-output <filename
-force_stos_opt Will forcibly enable stateless to stateful optimization,
i.e. skip "-cl-intel-greater-than-4GB-buffer-required".
-q Will silence most of output messages.
-q Will silence output messages (except errors).
-qq Will silence most of output messages.
-spv_only Will generate only spirV file.