mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Fix parsing ocloc options file
Resolves: NEO-5330 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
93ba4e646b
commit
1792516043
@@ -1092,6 +1092,27 @@ TEST(OfflineCompilerTest, givenInputOptionsAndInternalOptionsFilesWhenOfflineCom
|
||||
EXPECT_TRUE(internalOptions.find("-shouldfailInternalOptions") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST(OfflineCompilerTest, givenInputOptionsFileWithSpecialCharsWhenOfflineCompilerIsInitializedThenCorrectOptionsAreSet) {
|
||||
auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler());
|
||||
ASSERT_NE(nullptr, mockOfflineCompiler);
|
||||
|
||||
ASSERT_TRUE(fileExists("test_files/simple_kernels_opts_options.txt"));
|
||||
|
||||
std::vector<std::string> argv = {
|
||||
"ocloc",
|
||||
"-q",
|
||||
"-file",
|
||||
"test_files/simple_kernels_opts.cl",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str()};
|
||||
|
||||
int retVal = mockOfflineCompiler->initialize(argv.size(), argv);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto &options = mockOfflineCompiler->options;
|
||||
EXPECT_STREQ(options.c_str(), "-cl-opt-disable -DDEF_WAS_SPECIFIED=1 -DARGS=\", const __global int *arg1, float arg2, const __global int *arg3, float arg4\"");
|
||||
}
|
||||
|
||||
TEST(OfflineCompilerTest, givenInputOptionsAndOclockOptionsFileWithForceStosOptWhenOfflineCompilerIsInitializedThenCompilerOptionGreaterThan4gbBuffersRequiredIsNotApplied) {
|
||||
auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler());
|
||||
ASSERT_NE(nullptr, mockOfflineCompiler);
|
||||
|
||||
@@ -232,7 +232,7 @@ TEST_F(ProcessElfBinaryTests, GivenNonEmptyBuildOptionsWhenCreatingProgramFromBi
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
const auto &options = program->getOptions();
|
||||
std::string buildOptionsNotEmpty = CompilerOptions::concatenate(CompilerOptions::optDisable, "-DDEF_WAS_SPECIFIED=1");
|
||||
EXPECT_STREQ(buildOptionsNotEmpty.c_str(), options.c_str());
|
||||
EXPECT_THAT(options.c_str(), ::testing::HasSubstr(buildOptionsNotEmpty.c_str()));
|
||||
}
|
||||
|
||||
TEST_F(ProcessElfBinaryTests, GivenBinaryWhenIncompatiblePatchtokenVerionThenProramCreationFails) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2020, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -20,7 +20,7 @@
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
-cl-opt-disable -DDEF_WAS_SPECIFIED=1
|
||||
-cl-opt-disable -DDEF_WAS_SPECIFIED=1 -DARGS=", const __global int *arg1, float arg2, const __global int *arg3, float arg4"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -992,10 +992,11 @@ bool OfflineCompiler::readOptionsFromFile(std::string &options, const std::strin
|
||||
if (optionsSize > 0) {
|
||||
// Remove comment containing copyright header
|
||||
options = optionsFromFile.get();
|
||||
size_t commentBegin = options.find_first_of("/*");
|
||||
size_t commentEnd = options.find_last_of("*/");
|
||||
size_t commentBegin = options.find("/*");
|
||||
size_t commentEnd = options.rfind("*/");
|
||||
if (commentBegin != std::string::npos && commentEnd != std::string::npos) {
|
||||
options = options.replace(commentBegin, commentEnd - commentBegin + 1, "");
|
||||
auto sizeToReplace = commentEnd - commentBegin + 2;
|
||||
options = options.replace(commentBegin, sizeToReplace, "");
|
||||
size_t optionsBegin = options.find_first_not_of(" \t\n\r");
|
||||
if (optionsBegin != std::string::npos) {
|
||||
options = options.substr(optionsBegin, options.length());
|
||||
|
||||
Reference in New Issue
Block a user