OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_TEST_GPU_GPU_TEST_EXPECTATIONS_PARSER_H_ | |
6 #define CONTENT_TEST_GPU_GPU_TEST_EXPECTATIONS_PARSER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/files/file_path.h" | |
13 #include "content/test/gpu/gpu_test_config.h" | |
14 | |
15 class GPUTestExpectationsParser { | |
16 public: | |
17 enum GPUTestExpectation { | |
18 kGpuTestPass = 1 << 0, | |
19 kGpuTestFail = 1 << 1, | |
20 kGpuTestFlaky = 1 << 2, | |
21 kGpuTestTimeout = 1 << 3, | |
22 kGpuTestSkip = 1 << 4, | |
23 }; | |
24 | |
25 enum GPUTestProfile { | |
26 kWebGLConformanceTest, | |
27 }; | |
28 | |
29 GPUTestExpectationsParser(); | |
30 ~GPUTestExpectationsParser(); | |
31 | |
32 // Parse the text expectations, and if no error is encountered, | |
33 // save all the entries. Otherwise, generate error messages. | |
34 // Return true if parsing succeeds. | |
35 bool LoadTestExpectations(const std::string& data); | |
36 bool LoadTestExpectations(const base::FilePath& path); | |
37 bool LoadTestExpectations(GPUTestProfile profile); | |
38 | |
39 // Query error messages from the last LoadTestExpectations() call. | |
40 const std::vector<std::string>& GetErrorMessages() const; | |
41 | |
42 // Get the test expectation of a given test on a given bot. | |
43 int32 GetTestExpectation(const std::string& test_name, | |
44 const GPUTestBotConfig& bot_config) const; | |
45 | |
46 // Parse a list of config modifiers. If we have a valid entry with no | |
47 // conflicts, | config | stores it, and the function returns true. | |
48 bool ParseConfig(const std::string& config_data, GPUTestConfig* config); | |
49 | |
50 private: | |
51 struct GPUTestExpectationEntry { | |
52 GPUTestExpectationEntry(); | |
53 | |
54 std::string test_name; | |
55 GPUTestConfig test_config; | |
56 int32 test_expectation; | |
57 size_t line_number; | |
58 }; | |
59 | |
60 // Parse a line of text. If we have a valid entry, save it; otherwise, | |
61 // generate error messages. | |
62 bool ParseLine(const std::string& line_data, size_t line_number); | |
63 | |
64 // Update OS/GPUVendor/BuildType modifiers. May generate an error message. | |
65 bool UpdateTestConfig( | |
66 GPUTestConfig* config, int32 token, size_t line_number); | |
67 | |
68 // Update GPUDeviceID modifier. May generate an error message. | |
69 bool UpdateTestConfig(GPUTestConfig* config, | |
70 const std::string & gpu_device_id, | |
71 size_t line_number); | |
72 | |
73 // Check if two entries' config overlap with each other. May generate an | |
74 // error message. | |
75 bool DetectConflictsBetweenEntries(); | |
76 | |
77 // Save an error message, which can be queried later. | |
78 void PushErrorMessage(const std::string& message, size_t line_number); | |
79 void PushErrorMessage(const std::string& message, | |
80 size_t entry1_line_number, | |
81 size_t entry2_line_number); | |
82 | |
83 // Return false if an error occurs or the path does not exist. | |
84 static bool GetExpectationsPath(GPUTestProfile profile, | |
85 base::FilePath* path); | |
86 | |
87 std::vector<GPUTestExpectationEntry> entries_; | |
88 std::vector<std::string> error_messages_; | |
89 }; | |
90 | |
91 #endif // CONTENT_TEST_GPU_GPU_TEST_EXPECTATIONS_PARSER_H_ | |
92 | |
OLD | NEW |