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_CONFIG_H_ | |
6 #define CONTENT_TEST_GPU_GPU_TEST_CONFIG_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/compiler_specific.h" | |
13 | |
14 namespace gpu { | |
15 struct GPUInfo; | |
16 } // namespace content | |
17 | |
18 class GPUTestConfig { | |
19 public: | |
20 enum OS { | |
21 kOsUnknown = 0, | |
22 kOsWinXP = 1 << 0, | |
23 kOsWinVista = 1 << 1, | |
24 kOsWin7 = 1 << 2, | |
25 kOsWin8 = 1 << 3, | |
26 kOsWin = kOsWinXP | kOsWinVista | kOsWin7 | kOsWin8, | |
27 kOsMacLeopard = 1 << 4, | |
28 kOsMacSnowLeopard = 1 << 5, | |
29 kOsMacLion = 1 << 6, | |
30 kOsMacMountainLion = 1 << 7, | |
31 kOsMac = kOsMacLeopard | kOsMacSnowLeopard | kOsMacLion | | |
32 kOsMacMountainLion, | |
33 kOsLinux = 1 << 8, | |
34 kOsChromeOS = 1 << 9, | |
35 kOsAndroid = 1 << 10, | |
36 }; | |
37 | |
38 enum BuildType { | |
39 kBuildTypeUnknown = 0, | |
40 kBuildTypeRelease = 1 << 0, | |
41 kBuildTypeDebug = 1 << 1, | |
42 }; | |
43 | |
44 GPUTestConfig(); | |
45 virtual ~GPUTestConfig(); | |
46 | |
47 void set_os(int32 os); | |
48 void set_gpu_device_id(uint32 id); | |
49 void set_build_type(int32 build_type); | |
50 | |
51 virtual void AddGPUVendor(uint32 gpu_vendor); | |
52 | |
53 int32 os() const { return os_; } | |
54 const std::vector<uint32>& gpu_vendor() const { return gpu_vendor_; } | |
55 uint32 gpu_device_id() const { return gpu_device_id_; } | |
56 int32 build_type() const { return build_type_; } | |
57 | |
58 // Check if the config is valid. For example, if gpu_device_id_ is set, but | |
59 // gpu_vendor_ is unknown, then it's invalid. | |
60 virtual bool IsValid() const; | |
61 | |
62 // Check if two configs overlap, i.e., if there exists a config that matches | |
63 // both configs. | |
64 bool OverlapsWith(const GPUTestConfig& config) const; | |
65 | |
66 // Disable validation of GPU vendor and device ids. | |
67 void DisableGPUInfoValidation(); | |
68 | |
69 protected: | |
70 void ClearGPUVendor(); | |
71 | |
72 // Indicates that the OS has the notion of a numeric GPU vendor and device id | |
73 // and this data should be validated. | |
74 bool validate_gpu_info_; | |
75 | |
76 private: | |
77 // operating system. | |
78 int32 os_; | |
79 | |
80 // GPU vendor. | |
81 std::vector<uint32> gpu_vendor_; | |
82 | |
83 // GPU device id (unique to each vendor). | |
84 uint32 gpu_device_id_; | |
85 | |
86 // Release or Debug. | |
87 int32 build_type_; | |
88 }; | |
89 | |
90 class GPUTestBotConfig : public GPUTestConfig { | |
91 public: | |
92 GPUTestBotConfig() { } | |
93 virtual ~GPUTestBotConfig(); | |
94 | |
95 // This should only be called when no gpu_vendor is added. | |
96 virtual void AddGPUVendor(uint32 gpu_vendor) OVERRIDE; | |
97 | |
98 // Return false if gpu_info does not have valid vendor_id and device_id. | |
99 bool SetGPUInfo(const gpu::GPUInfo& gpu_info); | |
100 | |
101 // Check if the bot config is valid, i.e., if it is one valid test-bot | |
102 // environment. For example, if a field is unknown, or if OS is not one | |
103 // fully defined OS, then it's valid. | |
104 virtual bool IsValid() const OVERRIDE; | |
105 | |
106 // Check if a bot config matches a test config, i.e., the test config is a | |
107 // superset of the bot config. | |
108 bool Matches(const GPUTestConfig& config) const; | |
109 bool Matches(const std::string& config_data) const; | |
110 | |
111 // Setup the config with the current gpu testing environment. | |
112 // If gpu_info is NULL, collect GPUInfo first. | |
113 bool LoadCurrentConfig(const gpu::GPUInfo* gpu_info); | |
114 | |
115 // Check if this bot's config matches |config_data| or any of the |configs|. | |
116 static bool CurrentConfigMatches(const std::string& config_data); | |
117 static bool CurrentConfigMatches(const std::vector<std::string>& configs); | |
118 }; | |
119 | |
120 #endif // CONTENT_TEST_GPU_GPU_TEST_CONFIG_H_ | |
121 | |
OLD | NEW |