Cloc: correctly handle nonexistant platform

Change-Id: I85a81c10dc101e8af68dd4c52c7f604d563c4396
Signed-off-by: Cetnerowski <adam.cetnerowski@intel.com>
This commit is contained in:
Cetnerowski 2018-09-25 16:37:52 +02:00 committed by sys_ocldev
parent 1346148d69
commit 17fe3e740e
2 changed files with 19 additions and 2 deletions

View File

@ -505,9 +505,10 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const char *const *argv) {
retVal = getHardwareInfo(deviceName.c_str());
if (retVal != CL_SUCCESS) {
printf("Error: Cannot get HW Info for device %s.\n", deviceName.c_str());
} else {
std::string extensionsList = getExtensionsList(*hwInfo);
internalOptions.append(convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str()));
}
std::string extensionsList = getExtensionsList(*hwInfo);
internalOptions.append(convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str()));
}
}

View File

@ -298,6 +298,22 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_NumArgs) {
delete pOfflineCompiler;
}
TEST_F(OfflineCompilerTests, GivenNonexistantDeviceWhenCompilingThenExitWithErrorMsg) {
auto argv = {
"cloc",
"-file",
"test_files/copybuffer.cl",
"-device",
"foobar"};
testing::internal::CaptureStdout();
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv.begin(), retVal);
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.c_str(), "Error: Cannot get HW Info for device foobar.\n");
EXPECT_EQ(nullptr, pOfflineCompiler);
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
}
TEST_F(OfflineCompilerTests, NaughtyKernelTest) {
auto argv = {
"cloc",