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 "content/test/gpu/gpu_test_expectations_parser.h" | 5 #include "gpu/config/gpu_test_expectations_parser.h" |
6 | 6 |
7 #include "base/base_paths.h" | |
8 #include "base/file_util.h" | 7 #include "base/file_util.h" |
9 #include "base/logging.h" | 8 #include "base/logging.h" |
10 #include "base/path_service.h" | |
11 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
12 #include "base/string_util.h" | 10 #include "base/string_util.h" |
13 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
14 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
15 #include "content/public/common/content_paths.h" | 13 |
| 14 namespace gpu { |
16 | 15 |
17 namespace { | 16 namespace { |
18 | 17 |
19 enum LineParserStage { | 18 enum LineParserStage { |
20 kLineParserBegin = 0, | 19 kLineParserBegin = 0, |
21 kLineParserBugID, | 20 kLineParserBugID, |
22 kLineParserConfigs, | 21 kLineParserConfigs, |
23 kLineParserColon, | 22 kLineParserColon, |
24 kLineParserTestName, | 23 kLineParserTestName, |
25 kLineParserEqual, | 24 kLineParserEqual, |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 error_messages_.clear(); | 191 error_messages_.clear(); |
193 | 192 |
194 std::string data; | 193 std::string data; |
195 if (!file_util::ReadFileToString(path, &data)) { | 194 if (!file_util::ReadFileToString(path, &data)) { |
196 error_messages_.push_back(kErrorMessage[kErrorFileIO]); | 195 error_messages_.push_back(kErrorMessage[kErrorFileIO]); |
197 return false; | 196 return false; |
198 } | 197 } |
199 return LoadTestExpectations(data); | 198 return LoadTestExpectations(data); |
200 } | 199 } |
201 | 200 |
202 bool GPUTestExpectationsParser::LoadTestExpectations( | |
203 GPUTestProfile profile) { | |
204 base::FilePath path; | |
205 if (!GetExpectationsPath(profile, &path)) | |
206 return false; | |
207 return LoadTestExpectations(path); | |
208 } | |
209 | |
210 int32 GPUTestExpectationsParser::GetTestExpectation( | 201 int32 GPUTestExpectationsParser::GetTestExpectation( |
211 const std::string& test_name, | 202 const std::string& test_name, |
212 const GPUTestBotConfig& bot_config) const { | 203 const GPUTestBotConfig& bot_config) const { |
213 for (size_t i = 0; i < entries_.size(); ++i) { | 204 for (size_t i = 0; i < entries_.size(); ++i) { |
214 if (NamesMatching(entries_[i].test_name, test_name) && | 205 if (NamesMatching(entries_[i].test_name, test_name) && |
215 bot_config.Matches(entries_[i].test_config)) | 206 bot_config.Matches(entries_[i].test_config)) |
216 return entries_[i].test_expectation; | 207 return entries_[i].test_expectation; |
217 } | 208 } |
218 return kGpuTestPass; | 209 return kGpuTestPass; |
219 } | 210 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 const std::string& message, | 487 const std::string& message, |
497 size_t entry1_line_number, | 488 size_t entry1_line_number, |
498 size_t entry2_line_number) { | 489 size_t entry2_line_number) { |
499 error_messages_.push_back( | 490 error_messages_.push_back( |
500 base::StringPrintf("Line %d and %d : %s", | 491 base::StringPrintf("Line %d and %d : %s", |
501 static_cast<int>(entry1_line_number), | 492 static_cast<int>(entry1_line_number), |
502 static_cast<int>(entry2_line_number), | 493 static_cast<int>(entry2_line_number), |
503 message.c_str())); | 494 message.c_str())); |
504 } | 495 } |
505 | 496 |
506 // static | |
507 bool GPUTestExpectationsParser::GetExpectationsPath( | |
508 GPUTestProfile profile, base::FilePath* path) { | |
509 DCHECK(path); | |
510 | |
511 bool rt = true; | |
512 switch (profile) { | |
513 case kWebGLConformanceTest: | |
514 rt = PathService::Get(content::DIR_TEST_DATA, path); | |
515 if (rt) { | |
516 *path = path->Append(FILE_PATH_LITERAL("gpu")) | |
517 .Append(FILE_PATH_LITERAL( | |
518 "webgl_conformance_test_expectations.txt")); | |
519 rt = file_util::PathExists(*path); | |
520 } | |
521 break; | |
522 default: | |
523 DCHECK(false); | |
524 } | |
525 return rt; | |
526 } | |
527 | |
528 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() | 497 GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() |
529 : test_expectation(0), | 498 : test_expectation(0), |
530 line_number(0) { | 499 line_number(0) { |
531 } | 500 } |
532 | 501 |
| 502 } // namespace gpu |
| 503 |
OLD | NEW |