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