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