| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/config/gpu_test_expectations_parser.h" | 5 #include "gpu/config/gpu_test_expectations_parser.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 "entry invalid, likely wrong modifiers combination", | 122 "entry invalid, likely wrong modifiers combination", |
| 123 "entry with OS modifier conflicts", | 123 "entry with OS modifier conflicts", |
| 124 "entry with GPU vendor modifier conflicts", | 124 "entry with GPU vendor modifier conflicts", |
| 125 "entry with GPU build type conflicts", | 125 "entry with GPU build type conflicts", |
| 126 "entry with GPU device id conflicts or malformat", | 126 "entry with GPU device id conflicts or malformat", |
| 127 "entry with expectation modifier conflicts", | 127 "entry with expectation modifier conflicts", |
| 128 "two entries's configs overlap", | 128 "two entries's configs overlap", |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 Token ParseToken(const std::string& word) { | 131 Token ParseToken(const std::string& word) { |
| 132 if (base::StartsWithASCII(word, "//", false)) | 132 if (base::StartsWith(word, "//", base::CompareCase::INSENSITIVE_ASCII)) |
| 133 return kTokenComment; | 133 return kTokenComment; |
| 134 if (base::StartsWithASCII(word, "0x", false)) | 134 if (base::StartsWith(word, "0x", base::CompareCase::INSENSITIVE_ASCII)) |
| 135 return kConfigGPUDeviceID; | 135 return kConfigGPUDeviceID; |
| 136 | 136 |
| 137 for (int32 i = 0; i < kNumberOfExactMatchTokens; ++i) { | 137 for (int32 i = 0; i < kNumberOfExactMatchTokens; ++i) { |
| 138 if (base::LowerCaseEqualsASCII(word, kTokenData[i].name)) | 138 if (base::LowerCaseEqualsASCII(word, kTokenData[i].name)) |
| 139 return static_cast<Token>(i); | 139 return static_cast<Token>(i); |
| 140 } | 140 } |
| 141 return kTokenWord; | 141 return kTokenWord; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // reference name can have the last character as *. | 144 // reference name can have the last character as *. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 165 sizeof(kErrorMessage) / sizeof(kErrorMessage[0])); | 165 sizeof(kErrorMessage) / sizeof(kErrorMessage[0])); |
| 166 } | 166 } |
| 167 | 167 |
| 168 GPUTestExpectationsParser::~GPUTestExpectationsParser() { | 168 GPUTestExpectationsParser::~GPUTestExpectationsParser() { |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { | 171 bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { |
| 172 entries_.clear(); | 172 entries_.clear(); |
| 173 error_messages_.clear(); | 173 error_messages_.clear(); |
| 174 | 174 |
| 175 std::vector<std::string> lines; | 175 std::vector<std::string> lines = base::SplitString( |
| 176 base::SplitString(data, '\n', &lines); | 176 data, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 177 bool rt = true; | 177 bool rt = true; |
| 178 for (size_t i = 0; i < lines.size(); ++i) { | 178 for (size_t i = 0; i < lines.size(); ++i) { |
| 179 if (!ParseLine(lines[i], i + 1)) | 179 if (!ParseLine(lines[i], i + 1)) |
| 180 rt = false; | 180 rt = false; |
| 181 } | 181 } |
| 182 if (DetectConflictsBetweenEntries()) { | 182 if (DetectConflictsBetweenEntries()) { |
| 183 entries_.clear(); | 183 entries_.clear(); |
| 184 rt = false; | 184 rt = false; |
| 185 } | 185 } |
| 186 | 186 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 const std::vector<std::string>& | 214 const std::vector<std::string>& |
| 215 GPUTestExpectationsParser::GetErrorMessages() const { | 215 GPUTestExpectationsParser::GetErrorMessages() const { |
| 216 return error_messages_; | 216 return error_messages_; |
| 217 } | 217 } |
| 218 | 218 |
| 219 bool GPUTestExpectationsParser::ParseConfig( | 219 bool GPUTestExpectationsParser::ParseConfig( |
| 220 const std::string& config_data, GPUTestConfig* config) { | 220 const std::string& config_data, GPUTestConfig* config) { |
| 221 DCHECK(config); | 221 DCHECK(config); |
| 222 std::vector<std::string> tokens; | 222 std::vector<std::string> tokens = |
| 223 base::SplitStringAlongWhitespace(config_data, &tokens); | 223 base::SplitString(config_data, base::kWhitespaceASCII, |
| 224 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 224 | 225 |
| 225 for (size_t i = 0; i < tokens.size(); ++i) { | 226 for (size_t i = 0; i < tokens.size(); ++i) { |
| 226 Token token = ParseToken(tokens[i]); | 227 Token token = ParseToken(tokens[i]); |
| 227 switch (token) { | 228 switch (token) { |
| 228 case kConfigWinXP: | 229 case kConfigWinXP: |
| 229 case kConfigWinVista: | 230 case kConfigWinVista: |
| 230 case kConfigWin7: | 231 case kConfigWin7: |
| 231 case kConfigWin8: | 232 case kConfigWin8: |
| 232 case kConfigWin: | 233 case kConfigWin: |
| 233 case kConfigMacLeopard: | 234 case kConfigMacLeopard: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 256 break; | 257 break; |
| 257 default: | 258 default: |
| 258 return false; | 259 return false; |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 return true; | 262 return true; |
| 262 } | 263 } |
| 263 | 264 |
| 264 bool GPUTestExpectationsParser::ParseLine( | 265 bool GPUTestExpectationsParser::ParseLine( |
| 265 const std::string& line_data, size_t line_number) { | 266 const std::string& line_data, size_t line_number) { |
| 266 std::vector<std::string> tokens; | 267 std::vector<std::string> tokens = |
| 267 base::SplitStringAlongWhitespace(line_data, &tokens); | 268 base::SplitString(line_data, base::kWhitespaceASCII, |
| 269 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 268 int32 stage = kLineParserBegin; | 270 int32 stage = kLineParserBegin; |
| 269 GPUTestExpectationEntry entry; | 271 GPUTestExpectationEntry entry; |
| 270 entry.line_number = line_number; | 272 entry.line_number = line_number; |
| 271 GPUTestConfig& config = entry.test_config; | 273 GPUTestConfig& config = entry.test_config; |
| 272 bool comments_encountered = false; | 274 bool comments_encountered = false; |
| 273 for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i) { | 275 for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i) { |
| 274 Token token = ParseToken(tokens[i]); | 276 Token token = ParseToken(tokens[i]); |
| 275 switch (token) { | 277 switch (token) { |
| 276 case kTokenComment: | 278 case kTokenComment: |
| 277 comments_encountered = true; | 279 comments_encountered = true; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 message.c_str())); | 500 message.c_str())); |
| 499 } | 501 } |
| 500 | 502 |
| 501 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() | 503 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() |
| 502 : test_expectation(0), | 504 : test_expectation(0), |
| 503 line_number(0) { | 505 line_number(0) { |
| 504 } | 506 } |
| 505 | 507 |
| 506 } // namespace gpu | 508 } // namespace gpu |
| 507 | 509 |
| OLD | NEW |