|
15 | 15 | #include "gtest/gtest.h"
|
16 | 16 | #include "hw_cmds.h"
|
17 | 17 |
|
| 18 | +#include <algorithm> |
18 | 19 | #include <string>
|
19 | 20 |
|
20 | 21 | extern Environment *gEnvironment;
|
@@ -181,6 +182,58 @@ TEST(OclocApiTests, WhenArgsWithMissingFileAreGivenThenErrorMessageIsProduced) {
|
181 | 182 | EXPECT_NE(std::string::npos, output.find("Command was: ocloc -q -file test_files/IDoNotExist.cl -device "s + argv[5]));
|
182 | 183 | }
|
183 | 184 |
|
| 185 | +TEST(OfflineCompilerTest, givenInputOptionsAndInternalOptionsWhenCmdlineIsPrintedThenBothAreInQuotes) { |
| 186 | + const char *argv[] = { |
| 187 | + "ocloc", |
| 188 | + "-q", |
| 189 | + "-file", |
| 190 | + "test_files/IDoNotExist.cl", |
| 191 | + "-device", |
| 192 | + gEnvironment->devicePrefix.c_str(), |
| 193 | + "-options", "-D DEBUG -cl-kernel-arg-info", "-internal_options", "-internalOption1 -internal-option-2"}; |
| 194 | + unsigned int argc = sizeof(argv) / sizeof(const char *); |
| 195 | + |
| 196 | + testing::internal::CaptureStdout(); |
| 197 | + int retVal = oclocInvoke(argc, argv, |
| 198 | + 0, nullptr, nullptr, nullptr, |
| 199 | + 0, nullptr, nullptr, nullptr, |
| 200 | + nullptr, nullptr, nullptr, nullptr); |
| 201 | + std::string output = testing::internal::GetCapturedStdout(); |
| 202 | + EXPECT_NE(retVal, NEO::OfflineCompiler::ErrorCode::SUCCESS); |
| 203 | + EXPECT_TRUE(output.find("Command was: ocloc -q -file test_files/IDoNotExist.cl -device "s + |
| 204 | + gEnvironment->devicePrefix.c_str() + |
| 205 | + " -options \"-D DEBUG -cl-kernel-arg-info\" -internal_options \"-internalOption1 -internal-option-2\"") != std::string::npos); |
| 206 | + |
| 207 | + size_t quotesCount = std::count(output.begin(), output.end(), '\"'); |
| 208 | + EXPECT_EQ(quotesCount, 4u); |
| 209 | +} |
| 210 | + |
| 211 | +TEST(OfflineCompilerTest, givenInputOptionsCalledOptionsWhenCmdlineIsPrintedThenQuotesAreCorrect) { |
| 212 | + const char *argv[] = { |
| 213 | + "ocloc", |
| 214 | + "-q", |
| 215 | + "-file", |
| 216 | + "test_files/IDoNotExist.cl", |
| 217 | + "-device", |
| 218 | + gEnvironment->devicePrefix.c_str(), |
| 219 | + "-options", "-options", "-internal_options", "-internalOption"}; |
| 220 | + unsigned int argc = sizeof(argv) / sizeof(const char *); |
| 221 | + |
| 222 | + testing::internal::CaptureStdout(); |
| 223 | + int retVal = oclocInvoke(argc, argv, |
| 224 | + 0, nullptr, nullptr, nullptr, |
| 225 | + 0, nullptr, nullptr, nullptr, |
| 226 | + nullptr, nullptr, nullptr, nullptr); |
| 227 | + std::string output = testing::internal::GetCapturedStdout(); |
| 228 | + EXPECT_NE(retVal, NEO::OfflineCompiler::ErrorCode::SUCCESS); |
| 229 | + EXPECT_TRUE(output.find("Command was: ocloc -q -file test_files/IDoNotExist.cl -device "s + |
| 230 | + gEnvironment->devicePrefix.c_str() + |
| 231 | + " -options \"-options\" -internal_options \"-internalOption\"") != std::string::npos); |
| 232 | + |
| 233 | + size_t quotesCount = std::count(output.begin(), output.end(), '\"'); |
| 234 | + EXPECT_EQ(quotesCount, 4u); |
| 235 | +} |
| 236 | + |
184 | 237 | TEST(OclocApiTests, GivenIncludeHeadersWhenCompilingThenPassesToFclHeadersPackedAsElf) {
|
185 | 238 | auto prevFclDebugVars = NEO::getFclDebugVars();
|
186 | 239 | auto debugVars = prevFclDebugVars;
|
|
0 commit comments