Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: gpu/config/gpu_test_expectations_parser.cc

Issue 2022983003: Roll base to 5e00da80f6adb7082d1c0e88d3274cf87cc43bc5 and tonic to f7acabb8fa6c91124486a41194eac3cd… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/config/gpu_info_collector_linux.cc ('k') | gpu/config/gpu_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
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
OLDNEW
« no previous file with comments | « gpu/config/gpu_info_collector_linux.cc ('k') | gpu/config/gpu_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698