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
252
253
254
255
256
257
258
259
260
261
262
263
gpu / config / gpu_control_list_version_unittest.cc [blame]
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include "gpu/config/gpu_control_list.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gpu {
namespace {
constexpr auto kNumerical = GpuControlList::kVersionStyleNumerical;
constexpr auto kLexical = GpuControlList::kVersionStyleLexical;
constexpr auto kCommon = GpuControlList::kVersionSchemaCommon;
constexpr auto kIntelDriver = GpuControlList::kVersionSchemaIntelDriver;
constexpr auto kNvidiaDriver = GpuControlList::kVersionSchemaNvidiaDriver;
constexpr auto kBetween = GpuControlList::kBetween;
constexpr auto kEQ = GpuControlList::kEQ;
constexpr auto kLT = GpuControlList::kLT;
constexpr auto kLE = GpuControlList::kLE;
constexpr auto kGT = GpuControlList::kGT;
constexpr auto kGE = GpuControlList::kGE;
constexpr auto kAny = GpuControlList::kAny;
} // namespace anonymous
class VersionTest : public testing::Test {
public:
VersionTest() = default;
~VersionTest() override = default;
typedef GpuControlList::Version Version;
};
TEST_F(VersionTest, VersionComparison) {
{
Version info = {kAny, kNumerical, kCommon, nullptr, nullptr};
EXPECT_TRUE(info.Contains("0"));
EXPECT_TRUE(info.Contains("8.9"));
EXPECT_TRUE(info.Contains("100"));
EXPECT_TRUE(info.Contains("1.9.alpha"));
}
{
Version info = {kGT, kNumerical, kCommon, "8.9", nullptr};
EXPECT_FALSE(info.Contains("7"));
EXPECT_FALSE(info.Contains("8.9"));
EXPECT_FALSE(info.Contains("8.9.hs762"));
EXPECT_FALSE(info.Contains("8.9.1"));
EXPECT_TRUE(info.Contains("9"));
EXPECT_TRUE(info.Contains("9.hs762"));
}
{
Version info = {kGE, kNumerical, kCommon, "8.9", nullptr};
EXPECT_FALSE(info.Contains("7"));
EXPECT_FALSE(info.Contains("7.07hdy"));
EXPECT_TRUE(info.Contains("8.9"));
EXPECT_TRUE(info.Contains("8.9.1"));
EXPECT_TRUE(info.Contains("8.9.1beta0"));
EXPECT_TRUE(info.Contains("9"));
EXPECT_TRUE(info.Contains("9.0rel"));
}
{
Version info = {kEQ, kNumerical, kCommon, "8.9", nullptr};
EXPECT_FALSE(info.Contains("7"));
EXPECT_TRUE(info.Contains("8"));
EXPECT_TRUE(info.Contains("8.1uhdy"));
EXPECT_TRUE(info.Contains("8.9"));
EXPECT_TRUE(info.Contains("8.9.8alp9"));
EXPECT_TRUE(info.Contains("8.9.1"));
EXPECT_FALSE(info.Contains("9"));
}
{
Version info = {kLT, kNumerical, kCommon, "8.9", nullptr};
EXPECT_TRUE(info.Contains("7"));
EXPECT_TRUE(info.Contains("7.txt"));
EXPECT_TRUE(info.Contains("8.8"));
EXPECT_TRUE(info.Contains("8.8.test"));
EXPECT_FALSE(info.Contains("8"));
EXPECT_FALSE(info.Contains("8.9"));
EXPECT_FALSE(info.Contains("8.9.1"));
EXPECT_FALSE(info.Contains("8.9.duck"));
EXPECT_FALSE(info.Contains("9"));
}
{
Version info = {kLE, kNumerical, kCommon, "8.9", nullptr};
EXPECT_TRUE(info.Contains("7"));
EXPECT_TRUE(info.Contains("8.8"));
EXPECT_TRUE(info.Contains("8"));
EXPECT_TRUE(info.Contains("8.9"));
EXPECT_TRUE(info.Contains("8.9.chicken"));
EXPECT_TRUE(info.Contains("8.9.1"));
EXPECT_FALSE(info.Contains("9"));
EXPECT_FALSE(info.Contains("9.pork"));
}
{
Version info = {kBetween, kNumerical, kCommon, "8.9", "9.1"};
EXPECT_FALSE(info.Contains("7"));
EXPECT_FALSE(info.Contains("8.8"));
EXPECT_TRUE(info.Contains("8"));
EXPECT_TRUE(info.Contains("8.9"));
EXPECT_TRUE(info.Contains("8.9.1"));
EXPECT_TRUE(info.Contains("9"));
EXPECT_TRUE(info.Contains("9.1"));
EXPECT_TRUE(info.Contains("9.1.9"));
EXPECT_FALSE(info.Contains("9.2"));
EXPECT_FALSE(info.Contains("10"));
}
}
TEST_F(VersionTest, DateComparison) {
// When we use '-' as splitter, we assume a format of mm-dd-yyyy
// or mm-yyyy, i.e., a date.
{
Version info = {kEQ, kNumerical, kCommon, "1976.3.21", nullptr};
EXPECT_TRUE(info.Contains("3-21-1976", '-'));
EXPECT_TRUE(info.Contains("3-1976", '-'));
EXPECT_TRUE(info.Contains("03-1976", '-'));
EXPECT_FALSE(info.Contains("21-3-1976", '-'));
}
{
Version info = {kGT, kNumerical, kCommon, "1976.3.21", nullptr};
EXPECT_TRUE(info.Contains("3-22-1976", '-'));
EXPECT_TRUE(info.Contains("4-1976", '-'));
EXPECT_TRUE(info.Contains("04-1976", '-'));
EXPECT_FALSE(info.Contains("3-1976", '-'));
EXPECT_FALSE(info.Contains("2-1976", '-'));
}
{
Version info = {kBetween, kNumerical, kCommon, "1976.3.21", "2012.12.25"};
EXPECT_FALSE(info.Contains("3-20-1976", '-'));
EXPECT_TRUE(info.Contains("3-21-1976", '-'));
EXPECT_TRUE(info.Contains("3-22-1976", '-'));
EXPECT_TRUE(info.Contains("3-1976", '-'));
EXPECT_TRUE(info.Contains("4-1976", '-'));
EXPECT_TRUE(info.Contains("1-1-2000", '-'));
EXPECT_TRUE(info.Contains("1-2000", '-'));
EXPECT_TRUE(info.Contains("2000", '-'));
EXPECT_TRUE(info.Contains("11-2012", '-'));
EXPECT_TRUE(info.Contains("12-2012", '-'));
EXPECT_TRUE(info.Contains("12-24-2012", '-'));
EXPECT_TRUE(info.Contains("12-25-2012", '-'));
EXPECT_FALSE(info.Contains("12-26-2012", '-'));
EXPECT_FALSE(info.Contains("1-2013", '-'));
EXPECT_FALSE(info.Contains("2013", '-'));
}
}
TEST_F(VersionTest, LexicalComparison) {
// When we use lexical style, we assume a format major.minor.*.
// We apply numerical comparison to major, lexical comparison to others.
{
Version info = {kLT, kLexical, kCommon, "8.201", nullptr};
EXPECT_TRUE(info.Contains("8.001.100"));
EXPECT_TRUE(info.Contains("8.109"));
EXPECT_TRUE(info.Contains("8.10900"));
EXPECT_TRUE(info.Contains("8.109.100"));
EXPECT_TRUE(info.Contains("8.2"));
EXPECT_TRUE(info.Contains("8.20"));
EXPECT_TRUE(info.Contains("8.200"));
EXPECT_TRUE(info.Contains("8.20.100"));
EXPECT_FALSE(info.Contains("8.201"));
EXPECT_FALSE(info.Contains("8.2010"));
EXPECT_FALSE(info.Contains("8.21"));
EXPECT_FALSE(info.Contains("8.21.100"));
EXPECT_FALSE(info.Contains("9.002"));
EXPECT_FALSE(info.Contains("9.201"));
EXPECT_FALSE(info.Contains("12"));
EXPECT_FALSE(info.Contains("12.201"));
}
{
Version info = {kLT, kLexical, kCommon, "9.002", nullptr};
EXPECT_TRUE(info.Contains("8.001.100"));
EXPECT_TRUE(info.Contains("8.109"));
EXPECT_TRUE(info.Contains("8.10900"));
EXPECT_TRUE(info.Contains("8.109.100"));
EXPECT_TRUE(info.Contains("8.2"));
EXPECT_TRUE(info.Contains("8.20"));
EXPECT_TRUE(info.Contains("8.200"));
EXPECT_TRUE(info.Contains("8.20.100"));
EXPECT_TRUE(info.Contains("8.201"));
EXPECT_TRUE(info.Contains("8.2010"));
EXPECT_TRUE(info.Contains("8.21"));
EXPECT_TRUE(info.Contains("8.21.100"));
EXPECT_FALSE(info.Contains("9.002"));
EXPECT_FALSE(info.Contains("9.201"));
EXPECT_FALSE(info.Contains("12"));
EXPECT_FALSE(info.Contains("12.201"));
}
}
TEST_F(VersionTest, IntelDriverSchema) {
{
Version info = {kLT, kNumerical, kIntelDriver, "25.20.100.6952", nullptr};
EXPECT_TRUE(info.Contains("0.0.100.6000"));
EXPECT_FALSE(info.Contains("0.0.100.7000"));
EXPECT_FALSE(info.Contains("0.0.200.6000"));
EXPECT_TRUE(info.Contains("26.20.100.6000"));
EXPECT_FALSE(info.Contains("24.20.100.7000"));
EXPECT_TRUE(info.Contains("23.20.16.5037"));
}
{
Version info = {kGT, kNumerical, kIntelDriver, "10.18.15.4256", nullptr};
EXPECT_TRUE(info.Contains("0.0.15.6000"));
EXPECT_FALSE(info.Contains("0.0.15.4000"));
EXPECT_TRUE(info.Contains("10.18.15.4279"));
EXPECT_FALSE(info.Contains("15.40.15.4058"));
EXPECT_TRUE(info.Contains("26.20.100.6000"));
EXPECT_TRUE(info.Contains("26.20.100.4000"));
}
}
TEST_F(VersionTest, NvidiaDriverSchema) {
{
// Nvidia drivers, XX.XX.XXXA.AABB, only AAA.BB is considered. The version
// is specified as "AAA.BB" or "AAA" in the workaround file.
{
// "AAA.BB" should exactly specify one version.
Version info = {kLT, kNumerical, kNvidiaDriver, "234.56", nullptr};
EXPECT_TRUE(info.Contains("26.10.0012.3455"));
EXPECT_TRUE(info.Contains("00.00.0012.3455"));
EXPECT_TRUE(info.Contains("00.00.012.3455"));
EXPECT_TRUE(info.Contains("00.00.12.3455"));
EXPECT_FALSE(info.Contains("26.10.0012.3456"));
EXPECT_FALSE(info.Contains("26.10.012.3456"));
EXPECT_FALSE(info.Contains("26.10.12.3456"));
EXPECT_FALSE(info.Contains("26.10.0012.3457"));
EXPECT_FALSE(info.Contains("00.00.0012.3457"));
EXPECT_TRUE(info.Contains("26.10.0012.2457"));
EXPECT_TRUE(info.Contains("26.10.0011.3457"));
// Leading zeros in the third stanza are okay.
EXPECT_TRUE(info.Contains("26.10.0002.3455"));
EXPECT_FALSE(info.Contains("26.10.0002.3456"));
EXPECT_FALSE(info.Contains("26.10.0002.3457"));
EXPECT_TRUE(info.Contains("26.10.0010.3457"));
EXPECT_TRUE(info.Contains("26.10.0000.3457"));
// Missing zeros in the fourth stanza are replaced.
EXPECT_TRUE(info.Contains("26.10.0012.455"));
EXPECT_TRUE(info.Contains("26.10.0012.57"));
EXPECT_FALSE(info.Contains("26.10.0013.456"));
EXPECT_FALSE(info.Contains("26.10.0013.57"));
// Too short is rejected.
EXPECT_FALSE(info.Contains("26.10..57"));
EXPECT_FALSE(info.Contains("26.10.100"));
EXPECT_FALSE(info.Contains("26.10.100."));
}
{
// "AAA" should allow "AAA.*"
Version info = {kEQ, kNumerical, kNvidiaDriver, "234", nullptr};
EXPECT_FALSE(info.Contains("26.10.0012.3556"));
EXPECT_TRUE(info.Contains("26.10.0012.3456"));
}
}
}
} // namespace gpu