| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 sizeof(kErrorMessage) / sizeof(kErrorMessage[0])); | 180 sizeof(kErrorMessage) / sizeof(kErrorMessage[0])); |
| 181 } | 181 } |
| 182 | 182 |
| 183 GPUTestExpectationsParser::~GPUTestExpectationsParser() { | 183 GPUTestExpectationsParser::~GPUTestExpectationsParser() { |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { | 186 bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { |
| 187 entries_.clear(); | 187 entries_.clear(); |
| 188 error_messages_.clear(); | 188 error_messages_.clear(); |
| 189 | 189 |
| 190 std::vector<std::string> lines; | 190 std::vector<std::string> lines = base::SplitString( |
| 191 base::SplitString(data, '\n', &lines); | 191 data, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 192 bool rt = true; | 192 bool rt = true; |
| 193 for (size_t i = 0; i < lines.size(); ++i) { | 193 for (size_t i = 0; i < lines.size(); ++i) { |
| 194 if (!ParseLine(lines[i], i + 1)) | 194 if (!ParseLine(lines[i], i + 1)) |
| 195 rt = false; | 195 rt = false; |
| 196 } | 196 } |
| 197 if (DetectConflictsBetweenEntries()) { | 197 if (DetectConflictsBetweenEntries()) { |
| 198 entries_.clear(); | 198 entries_.clear(); |
| 199 rt = false; | 199 rt = false; |
| 200 } | 200 } |
| 201 | 201 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 227 } | 227 } |
| 228 | 228 |
| 229 const std::vector<std::string>& | 229 const std::vector<std::string>& |
| 230 GPUTestExpectationsParser::GetErrorMessages() const { | 230 GPUTestExpectationsParser::GetErrorMessages() const { |
| 231 return error_messages_; | 231 return error_messages_; |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool GPUTestExpectationsParser::ParseConfig( | 234 bool GPUTestExpectationsParser::ParseConfig( |
| 235 const std::string& config_data, GPUTestConfig* config) { | 235 const std::string& config_data, GPUTestConfig* config) { |
| 236 DCHECK(config); | 236 DCHECK(config); |
| 237 std::vector<std::string> tokens; | 237 std::vector<std::string> tokens = base::SplitString( |
| 238 base::SplitStringAlongWhitespace(config_data, &tokens); | 238 config_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, |
| 239 base::SPLIT_WANT_NONEMPTY); |
| 239 | 240 |
| 240 for (size_t i = 0; i < tokens.size(); ++i) { | 241 for (size_t i = 0; i < tokens.size(); ++i) { |
| 241 Token token = ParseToken(tokens[i]); | 242 Token token = ParseToken(tokens[i]); |
| 242 switch (token) { | 243 switch (token) { |
| 243 case kConfigWinXP: | 244 case kConfigWinXP: |
| 244 case kConfigWinVista: | 245 case kConfigWinVista: |
| 245 case kConfigWin7: | 246 case kConfigWin7: |
| 246 case kConfigWin8: | 247 case kConfigWin8: |
| 247 case kConfigWin10: | 248 case kConfigWin10: |
| 248 case kConfigWin: | 249 case kConfigWin: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 277 break; | 278 break; |
| 278 default: | 279 default: |
| 279 return false; | 280 return false; |
| 280 } | 281 } |
| 281 } | 282 } |
| 282 return true; | 283 return true; |
| 283 } | 284 } |
| 284 | 285 |
| 285 bool GPUTestExpectationsParser::ParseLine( | 286 bool GPUTestExpectationsParser::ParseLine( |
| 286 const std::string& line_data, size_t line_number) { | 287 const std::string& line_data, size_t line_number) { |
| 287 std::vector<std::string> tokens; | 288 std::vector<std::string> tokens = base::SplitString( |
| 288 base::SplitStringAlongWhitespace(line_data, &tokens); | 289 line_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, |
| 290 base::SPLIT_WANT_NONEMPTY); |
| 289 int32 stage = kLineParserBegin; | 291 int32 stage = kLineParserBegin; |
| 290 GPUTestExpectationEntry entry; | 292 GPUTestExpectationEntry entry; |
| 291 entry.line_number = line_number; | 293 entry.line_number = line_number; |
| 292 GPUTestConfig& config = entry.test_config; | 294 GPUTestConfig& config = entry.test_config; |
| 293 bool comments_encountered = false; | 295 bool comments_encountered = false; |
| 294 for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i) { | 296 for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i) { |
| 295 Token token = ParseToken(tokens[i]); | 297 Token token = ParseToken(tokens[i]); |
| 296 switch (token) { | 298 switch (token) { |
| 297 case kTokenComment: | 299 case kTokenComment: |
| 298 comments_encountered = true; | 300 comments_encountered = true; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 message.c_str())); | 540 message.c_str())); |
| 539 } | 541 } |
| 540 | 542 |
| 541 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() | 543 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() |
| 542 : test_expectation(0), | 544 : test_expectation(0), |
| 543 line_number(0) { | 545 line_number(0) { |
| 544 } | 546 } |
| 545 | 547 |
| 546 } // namespace gpu | 548 } // namespace gpu |
| 547 | 549 |
| OLD | NEW |