mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 18:25:05 +08:00
Cloc: correctly handle nonexistant platform
Change-Id: I85a81c10dc101e8af68dd4c52c7f604d563c4396 Signed-off-by: Cetnerowski <adam.cetnerowski@intel.com>
This commit is contained in:
@@ -505,11 +505,12 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const char *const *argv) {
|
|||||||
retVal = getHardwareInfo(deviceName.c_str());
|
retVal = getHardwareInfo(deviceName.c_str());
|
||||||
if (retVal != CL_SUCCESS) {
|
if (retVal != CL_SUCCESS) {
|
||||||
printf("Error: Cannot get HW Info for device %s.\n", deviceName.c_str());
|
printf("Error: Cannot get HW Info for device %s.\n", deviceName.c_str());
|
||||||
}
|
} else {
|
||||||
std::string extensionsList = getExtensionsList(*hwInfo);
|
std::string extensionsList = getExtensionsList(*hwInfo);
|
||||||
internalOptions.append(convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str()));
|
internalOptions.append(convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,6 +298,22 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_NumArgs) {
|
|||||||
delete pOfflineCompiler;
|
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) {
|
TEST_F(OfflineCompilerTests, NaughtyKernelTest) {
|
||||||
auto argv = {
|
auto argv = {
|
||||||
"cloc",
|
"cloc",
|
||||||
|
|||||||
Reference in New Issue
Block a user