1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/test/gpu/gpu_test_config.h"
#include "content/public/common/gpu_info.h"
#include "testing/gtest/include/gtest/gtest.h"
class GPUTestConfigTest : public testing::Test {
public:
GPUTestConfigTest() { }
virtual ~GPUTestConfigTest() { }
protected:
virtual void SetUp() { }
virtual void TearDown() { }
};
TEST_F(GPUTestConfigTest, EmptyValues) {
GPUTestConfig config;
EXPECT_EQ(GPUTestConfig::kOsUnknown, config.os());
EXPECT_EQ(0u, config.gpu_vendor().size());
EXPECT_EQ(0u, config.gpu_device_id());
EXPECT_EQ(GPUTestConfig::kBuildTypeUnknown, config.build_type());
}
TEST_F(GPUTestConfigTest, SetGPUInfo) {
content::GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
GPUTestBotConfig config;
EXPECT_TRUE(config.SetGPUInfo(gpu_info));
EXPECT_EQ(1u, config.gpu_vendor().size());
EXPECT_EQ(gpu_info.gpu.vendor_id, config.gpu_vendor()[0]);
EXPECT_EQ(gpu_info.gpu.device_id, config.gpu_device_id());
gpu_info.gpu.vendor_id = 0x8086;
gpu_info.gpu.device_id = 0x0046;
EXPECT_TRUE(config.SetGPUInfo(gpu_info));
EXPECT_EQ(1u, config.gpu_vendor().size());
EXPECT_EQ(gpu_info.gpu.vendor_id, config.gpu_vendor()[0]);
EXPECT_EQ(gpu_info.gpu.device_id, config.gpu_device_id());
}
TEST_F(GPUTestConfigTest, IsValid) {
{
GPUTestConfig config;
config.set_gpu_device_id(0x0640);
EXPECT_FALSE(config.IsValid());
config.AddGPUVendor(0x10de);
EXPECT_TRUE(config.IsValid());
}
{
GPUTestBotConfig config;
config.set_build_type(GPUTestConfig::kBuildTypeRelease);
config.set_os(GPUTestConfig::kOsWin7);
config.set_gpu_device_id(0x0640);
EXPECT_FALSE(config.IsValid());
config.AddGPUVendor(0x10de);
EXPECT_TRUE(config.IsValid());
config.set_gpu_device_id(0);
EXPECT_FALSE(config.IsValid());
config.set_gpu_device_id(0x0640);
EXPECT_TRUE(config.IsValid());
config.set_os(GPUTestConfig::kOsWin);
EXPECT_FALSE(config.IsValid());
config.set_os(GPUTestConfig::kOsWin7 | GPUTestConfig::kOsWinXP);
EXPECT_FALSE(config.IsValid());
config.set_os(GPUTestConfig::kOsWin7);
EXPECT_TRUE(config.IsValid());
config.set_build_type(GPUTestConfig::kBuildTypeUnknown);
EXPECT_FALSE(config.IsValid());
config.set_build_type(GPUTestConfig::kBuildTypeRelease);
EXPECT_TRUE(config.IsValid());
}
}
TEST_F(GPUTestConfigTest, Matches) {
GPUTestBotConfig config;
config.set_os(GPUTestConfig::kOsWin7);
config.set_build_type(GPUTestConfig::kBuildTypeRelease);
config.AddGPUVendor(0x10de);
config.set_gpu_device_id(0x0640);
EXPECT_TRUE(config.IsValid());
{ // os matching
GPUTestConfig config2;
EXPECT_TRUE(config.Matches(config2));
config2.set_os(GPUTestConfig::kOsWin);
EXPECT_TRUE(config.Matches(config2));
config2.set_os(GPUTestConfig::kOsWin7);
EXPECT_TRUE(config.Matches(config2));
config2.set_os(GPUTestConfig::kOsMac);
EXPECT_FALSE(config.Matches(config2));
config2.set_os(GPUTestConfig::kOsWin7 | GPUTestConfig::kOsLinux);
EXPECT_TRUE(config.Matches(config2));
}
{ // gpu vendor matching
{
GPUTestConfig config2;
config2.AddGPUVendor(0x10de);
EXPECT_TRUE(config.Matches(config2));
config2.AddGPUVendor(0x1004);
EXPECT_TRUE(config.Matches(config2));
}
{
GPUTestConfig config2;
config2.AddGPUVendor(0x8086);
EXPECT_FALSE(config.Matches(config2));
}
}
{ // build type matching
GPUTestConfig config2;
config2.set_build_type(GPUTestConfig::kBuildTypeRelease);
EXPECT_TRUE(config.Matches(config2));
config2.set_build_type(GPUTestConfig::kBuildTypeRelease |
GPUTestConfig::kBuildTypeDebug);
EXPECT_TRUE(config.Matches(config2));
config2.set_build_type(GPUTestConfig::kBuildTypeDebug);
EXPECT_FALSE(config.Matches(config2));
}
{ // exact matching
GPUTestConfig config2;
config2.set_os(GPUTestConfig::kOsWin7);
config2.set_build_type(GPUTestConfig::kBuildTypeRelease);
config2.AddGPUVendor(0x10de);
config2.set_gpu_device_id(0x0640);
EXPECT_TRUE(config.Matches(config2));
config2.set_gpu_device_id(0x0641);
EXPECT_FALSE(config.Matches(config2));
}
}
TEST_F(GPUTestConfigTest, StringMatches) {
GPUTestBotConfig config;
config.set_os(GPUTestConfig::kOsWin7);
config.set_build_type(GPUTestConfig::kBuildTypeRelease);
config.AddGPUVendor(0x10de);
config.set_gpu_device_id(0x0640);
EXPECT_TRUE(config.IsValid());
EXPECT_TRUE(config.Matches(std::string()));
// os matching
EXPECT_TRUE(config.Matches("WIN"));
EXPECT_TRUE(config.Matches("WIN7"));
EXPECT_FALSE(config.Matches("MAC"));
EXPECT_TRUE(config.Matches("WIN7 LINUX"));
// gpu vendor matching
EXPECT_TRUE(config.Matches("NVIDIA"));
EXPECT_TRUE(config.Matches("NVIDIA AMD"));
EXPECT_FALSE(config.Matches("INTEL"));
// build type matching
EXPECT_TRUE(config.Matches("RELEASE"));
EXPECT_TRUE(config.Matches("RELEASE DEBUG"));
EXPECT_FALSE(config.Matches("DEBUG"));
// exact matching
EXPECT_TRUE(config.Matches("WIN7 RELEASE NVIDIA 0X0640"));
EXPECT_FALSE(config.Matches("WIN7 RELEASE NVIDIA 0X0641"));
}
TEST_F(GPUTestConfigTest, OverlapsWith) {
{ // os
// win vs win7
GPUTestConfig config;
config.set_os(GPUTestConfig::kOsWin);
GPUTestConfig config2;
config2.set_os(GPUTestConfig::kOsWin7);
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
// win vs win7+linux
config2.set_os(GPUTestConfig::kOsWin7 | GPUTestConfig::kOsLinux);
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
// win vs mac
config2.set_os(GPUTestConfig::kOsMac);
EXPECT_FALSE(config.OverlapsWith(config2));
EXPECT_FALSE(config2.OverlapsWith(config));
// win vs unknown
config2.set_os(GPUTestConfig::kOsUnknown);
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
}
{ // gpu vendor
GPUTestConfig config;
config.AddGPUVendor(0x10de);
// nvidia vs unknown
GPUTestConfig config2;
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
// nvidia vs intel
config2.AddGPUVendor(0x1086);
EXPECT_FALSE(config.OverlapsWith(config2));
EXPECT_FALSE(config2.OverlapsWith(config));
// nvidia vs nvidia+intel
config2.AddGPUVendor(0x10de);
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
}
{ // build type
// release vs debug
GPUTestConfig config;
config.set_build_type(GPUTestConfig::kBuildTypeRelease);
GPUTestConfig config2;
config2.set_build_type(GPUTestConfig::kBuildTypeDebug);
EXPECT_FALSE(config.OverlapsWith(config2));
EXPECT_FALSE(config2.OverlapsWith(config));
// release vs release+debug
config2.set_build_type(GPUTestConfig::kBuildTypeRelease |
GPUTestConfig::kBuildTypeDebug);
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
// release vs unknown
config2.set_build_type(GPUTestConfig::kBuildTypeUnknown);
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
}
{ // win7 vs nvidia
GPUTestConfig config;
config.set_os(GPUTestConfig::kOsWin7);
GPUTestConfig config2;
config2.AddGPUVendor(0x10de);
EXPECT_TRUE(config.OverlapsWith(config2));
EXPECT_TRUE(config2.OverlapsWith(config));
}
}
TEST_F(GPUTestConfigTest, LoadCurrentConfig) {
GPUTestBotConfig config;
content::GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
EXPECT_TRUE(config.LoadCurrentConfig(&gpu_info));
EXPECT_TRUE(config.IsValid());
}
|