Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/test_expectations/GPUTestExpectationsParser_unittest.cpp
1693 views
1
//
2
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// GPUTestExpectationsParser_unittest.cpp: Unit tests for GPUTestExpectationsParser*
7
//
8
9
#include "tests/test_expectations/GPUTestExpectationsParser.h"
10
#include <gtest/gtest.h>
11
#include "tests/test_expectations/GPUTestConfig.h"
12
13
using namespace angle;
14
15
namespace
16
{
17
enum class ConditionTestType
18
{
19
OnLoad,
20
OnGet,
21
};
22
23
class GPUTestConfigTester : public GPUTestConfig
24
{
25
public:
26
GPUTestConfigTester()
27
{
28
mConditions.reset();
29
mConditions[GPUTestConfig::kConditionWin] = true;
30
mConditions[GPUTestConfig::kConditionNVIDIA] = true;
31
mConditions[GPUTestConfig::kConditionD3D11] = true;
32
}
33
};
34
35
class GPUTestExpectationsParserTest : public testing::TestWithParam<ConditionTestType>
36
{
37
public:
38
bool load(const std::string &line)
39
{
40
if (GetParam() == ConditionTestType::OnLoad)
41
{
42
return parser.loadTestExpectations(config, line);
43
}
44
else
45
{
46
return parser.loadAllTestExpectations(line);
47
}
48
}
49
50
int32_t get(const std::string &testName)
51
{
52
if (GetParam() == ConditionTestType::OnLoad)
53
{
54
return parser.getTestExpectation(testName);
55
}
56
else
57
{
58
return parser.getTestExpectationWithConfig(config, testName);
59
}
60
}
61
62
GPUTestConfigTester config;
63
GPUTestExpectationsParser parser;
64
};
65
66
// A correct entry with a test that's skipped on all platforms should not lead
67
// to any errors, and should properly return the expectation SKIP.
68
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSkip)
69
{
70
std::string line =
71
R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
72
EXPECT_TRUE(load(line));
73
EXPECT_TRUE(parser.getErrorMessages().empty());
74
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
75
GPUTestExpectationsParser::kGpuTestSkip);
76
}
77
78
// A correct entry with a test that's failed on all platforms should not lead
79
// to any errors, and should properly return the expectation FAIL.
80
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserFail)
81
{
82
std::string line =
83
R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = FAIL)";
84
EXPECT_TRUE(load(line));
85
EXPECT_TRUE(parser.getErrorMessages().empty());
86
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
87
GPUTestExpectationsParser::kGpuTestFail);
88
}
89
90
// A correct entry with a test that's passed on all platforms should not lead
91
// to any errors, and should properly return the expectation PASS.
92
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserPass)
93
{
94
std::string line =
95
R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = PASS)";
96
EXPECT_TRUE(load(line));
97
EXPECT_TRUE(parser.getErrorMessages().empty());
98
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
99
GPUTestExpectationsParser::kGpuTestPass);
100
}
101
102
// A correct entry with a test that's timed out on all platforms should not lead
103
// to any errors, and should properly return the expectation TIMEOUT.
104
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserTimeout)
105
{
106
std::string line =
107
R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = TIMEOUT)";
108
EXPECT_TRUE(load(line));
109
EXPECT_TRUE(parser.getErrorMessages().empty());
110
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
111
GPUTestExpectationsParser::kGpuTestTimeout);
112
}
113
114
// A correct entry with a test that's flaky on all platforms should not lead
115
// to any errors, and should properly return the expectation FLAKY.
116
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserFlaky)
117
{
118
std::string line =
119
R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = FLAKY)";
120
EXPECT_TRUE(load(line));
121
EXPECT_TRUE(parser.getErrorMessages().empty());
122
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
123
GPUTestExpectationsParser::kGpuTestFlaky);
124
}
125
126
// A correct entry with a test that's skipped on windows should not lead
127
// to any errors, and should properly return the expectation SKIP on this
128
// tester.
129
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWin)
130
{
131
std::string line =
132
R"(100 WIN : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
133
EXPECT_TRUE(load(line));
134
EXPECT_TRUE(parser.getErrorMessages().empty());
135
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
136
GPUTestExpectationsParser::kGpuTestSkip);
137
}
138
139
// A correct entry with a test that's skipped on windows/NVIDIA should not lead
140
// to any errors, and should properly return the expectation SKIP on this
141
// tester.
142
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWinNVIDIA)
143
{
144
std::string line =
145
R"(100 WIN NVIDIA : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
146
EXPECT_TRUE(load(line));
147
EXPECT_TRUE(parser.getErrorMessages().empty());
148
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
149
GPUTestExpectationsParser::kGpuTestSkip);
150
}
151
152
// A correct entry with a test that's skipped on windows/NVIDIA/D3D11 should not
153
// lead to any errors, and should properly return the expectation SKIP on this
154
// tester.
155
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWinNVIDIAD3D11)
156
{
157
std::string line =
158
R"(100 WIN NVIDIA D3D11 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
159
EXPECT_TRUE(load(line));
160
EXPECT_TRUE(parser.getErrorMessages().empty());
161
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
162
GPUTestExpectationsParser::kGpuTestSkip);
163
}
164
165
// Same as GPUTestExpectationsParserSingleLineWinNVIDIAD3D11, but verifying that the order
166
// of these conditions doesn't matter
167
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWinNVIDIAD3D11OtherOrder)
168
{
169
std::string line =
170
R"(100 D3D11 NVIDIA WIN : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
171
EXPECT_TRUE(load(line));
172
EXPECT_TRUE(parser.getErrorMessages().empty());
173
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
174
GPUTestExpectationsParser::kGpuTestSkip);
175
}
176
177
// A correct entry with a test that's skipped on mac should not lead
178
// to any errors, and should default to PASS on this tester (windows).
179
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineMac)
180
{
181
std::string line =
182
R"(100 MAC : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
183
EXPECT_TRUE(load(line));
184
EXPECT_TRUE(parser.getErrorMessages().empty());
185
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
186
GPUTestExpectationsParser::kGpuTestPass);
187
}
188
189
// A correct entry with a test that has conflicting entries should not lead
190
// to any errors, and should default to PASS.
191
// (https:anglebug.com/3368) In the future, this condition should cause an
192
// error
193
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineConflict)
194
{
195
std::string line =
196
R"(100 WIN MAC : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
197
EXPECT_TRUE(load(line));
198
EXPECT_TRUE(parser.getErrorMessages().empty());
199
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
200
GPUTestExpectationsParser::kGpuTestPass);
201
}
202
203
// A line without a bug ID should return an error and not add the expectation.
204
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingBugId)
205
{
206
std::string line = R"( : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
207
EXPECT_FALSE(load(line));
208
EXPECT_EQ(parser.getErrorMessages().size(), 1u);
209
if (parser.getErrorMessages().size() >= 1)
210
{
211
EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");
212
}
213
// Default behavior is to let missing tests pass
214
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
215
GPUTestExpectationsParser::kGpuTestPass);
216
}
217
218
// A line without a bug ID should return an error and not add the expectation, (even if
219
// the line contains conditions that might be mistaken for a bug id)
220
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingBugIdWithConditions)
221
{
222
std::string line =
223
R"(WIN D3D11 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
224
EXPECT_FALSE(load(line));
225
EXPECT_EQ(parser.getErrorMessages().size(), 1u);
226
if (parser.getErrorMessages().size() >= 1)
227
{
228
EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");
229
}
230
// Default behavior is to let missing tests pass
231
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
232
GPUTestExpectationsParser::kGpuTestPass);
233
}
234
235
// A line without a colon should return an error and not add the expectation.
236
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingColon)
237
{
238
std::string line = R"(100 dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
239
EXPECT_FALSE(load(line));
240
EXPECT_EQ(parser.getErrorMessages().size(), 1u);
241
if (parser.getErrorMessages().size() >= 1)
242
{
243
EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");
244
}
245
// Default behavior is to let missing tests pass
246
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
247
GPUTestExpectationsParser::kGpuTestPass);
248
}
249
250
// A wild character (*) at the end of a line should match any expectations that are a subset of that
251
// line. It should not greedily match to omany expectations that aren't in that subset.
252
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserWildChar)
253
{
254
std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP)";
255
EXPECT_TRUE(load(line));
256
EXPECT_TRUE(parser.getErrorMessages().empty());
257
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
258
GPUTestExpectationsParser::kGpuTestSkip);
259
// Also ensure the wild char is not too wild, only covers tests that are more specific
260
EXPECT_EQ(get("dEQP-GLES31.functional.program_interface_query.transform_feedback_varying."
261
"resource_list.vertex_fragment.builtin_gl_position"),
262
GPUTestExpectationsParser::kGpuTestPass);
263
}
264
265
// A line without an equals should return an error and not add the expectation.
266
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingEquals)
267
{
268
std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max SKIP)";
269
EXPECT_FALSE(load(line));
270
EXPECT_EQ(parser.getErrorMessages().size(), 1u);
271
if (parser.getErrorMessages().size() >= 1)
272
{
273
EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");
274
}
275
// Default behavior is to let missing tests pass
276
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
277
GPUTestExpectationsParser::kGpuTestPass);
278
}
279
280
// A line without an expectation should return an error and not add the expectation.
281
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingExpectation)
282
{
283
std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max =)";
284
EXPECT_FALSE(load(line));
285
EXPECT_EQ(parser.getErrorMessages().size(), 1u);
286
if (parser.getErrorMessages().size() >= 1)
287
{
288
EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");
289
}
290
// Default behavior is to let missing tests pass
291
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
292
GPUTestExpectationsParser::kGpuTestPass);
293
}
294
295
// A line with an expectation that doesn't exist should return an error and not add the expectation.
296
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserInvalidExpectation)
297
{
298
std::string line =
299
R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = WRONG)";
300
EXPECT_FALSE(load(line));
301
EXPECT_EQ(parser.getErrorMessages().size(), 1u);
302
if (parser.getErrorMessages().size() >= 1)
303
{
304
EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");
305
}
306
// Default behavior is to let missing tests pass
307
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
308
GPUTestExpectationsParser::kGpuTestPass);
309
}
310
311
// ChromeOS is reserved as a token, but doesn't actually check any conditions. Any tokens that
312
// do not check conditions should return an error and not add the expectation
313
// (https://anglebug.com/3363) Remove/update this test when ChromeOS is supported
314
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserUnimplementedCondition)
315
{
316
// Does not apply when loading all expectations and not checking the config.
317
if (GetParam() == ConditionTestType::OnGet)
318
{
319
GTEST_SKIP() << "Test does not apply when loading all expectations.";
320
}
321
322
std::string line =
323
R"(100 CHROMEOS : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
324
EXPECT_FALSE(load(line));
325
EXPECT_EQ(parser.getErrorMessages().size(), 1u);
326
if (parser.getErrorMessages().size() >= 1)
327
{
328
EXPECT_EQ(parser.getErrorMessages()[0],
329
"Line 1 : entry invalid, likely unimplemented modifiers");
330
}
331
// Default behavior is to let missing tests pass
332
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
333
GPUTestExpectationsParser::kGpuTestPass);
334
}
335
336
// If a line starts with a comment, it's ignored and should not be added to the list.
337
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserComment)
338
{
339
std::string line =
340
R"(//100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";
341
EXPECT_TRUE(load(line));
342
EXPECT_TRUE(parser.getErrorMessages().empty());
343
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
344
GPUTestExpectationsParser::kGpuTestPass);
345
}
346
347
// A misspelled expectation should not be matched from getTestExpectation, and should lead to an
348
// unused expectation when later queried.
349
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMisspelledExpectation)
350
{
351
std::string line =
352
R"(100 : dEQP-GLES31.functionaal.layout_binding.ubo.* = SKIP)"; // "functionaal"
353
EXPECT_TRUE(load(line));
354
EXPECT_TRUE(parser.getErrorMessages().empty());
355
// Default behavior is to let missing tests pass
356
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
357
GPUTestExpectationsParser::kGpuTestPass);
358
EXPECT_EQ(parser.getUnusedExpectationsMessages().size(), 1u);
359
if (parser.getUnusedExpectationsMessages().size() >= 1)
360
{
361
EXPECT_EQ(parser.getUnusedExpectationsMessages()[0], "Line 1: expectation was unused.");
362
}
363
}
364
365
// Wild characters that match groups of expectations can be overridden with more specific lines.
366
// The parse should still compute correctly which lines were used and which were unused.
367
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserOverrideExpectation)
368
{
369
// Fail all layout_binding tests, but skip the layout_binding.ubo subset.
370
std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.* = FAIL
371
100 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP)";
372
EXPECT_TRUE(load(line));
373
EXPECT_TRUE(parser.getErrorMessages().empty());
374
// Default behavior is to let missing tests pass
375
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
376
GPUTestExpectationsParser::kGpuTestSkip);
377
// The FAIL expectation was unused because it was overridden.
378
EXPECT_EQ(parser.getUnusedExpectationsMessages().size(), 1u);
379
if (parser.getUnusedExpectationsMessages().size() >= 1)
380
{
381
EXPECT_EQ(parser.getUnusedExpectationsMessages()[0], "Line 1: expectation was unused.");
382
}
383
// Now try a test that doesn't match the override criteria
384
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.image.test"),
385
GPUTestExpectationsParser::kGpuTestFail);
386
EXPECT_TRUE(parser.getUnusedExpectationsMessages().empty());
387
}
388
389
// This test is the same as GPUTestExpectationsParserOverrideExpectation, but verifying the order
390
// doesn't matter when overriding.
391
TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserOverrideExpectationOtherOrder)
392
{
393
// Fail all layout_binding tests, but skip the layout_binding.ubo subset.
394
std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP
395
100 : dEQP-GLES31.functional.layout_binding.* = FAIL)";
396
EXPECT_TRUE(load(line));
397
EXPECT_TRUE(parser.getErrorMessages().empty());
398
// Default behavior is to let missing tests pass
399
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
400
GPUTestExpectationsParser::kGpuTestSkip);
401
// The FAIL expectation was unused because it was overridden.
402
EXPECT_EQ(parser.getUnusedExpectationsMessages().size(), 1u);
403
if (parser.getUnusedExpectationsMessages().size() >= 1)
404
{
405
EXPECT_EQ(parser.getUnusedExpectationsMessages()[0], "Line 2: expectation was unused.");
406
}
407
// Now try a test that doesn't match the override criteria
408
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.image.test"),
409
GPUTestExpectationsParser::kGpuTestFail);
410
EXPECT_TRUE(parser.getUnusedExpectationsMessages().empty());
411
}
412
413
// Tests that overlap checking doesn't generate false positives.
414
TEST_P(GPUTestExpectationsParserTest, OverlapConditions)
415
{
416
std::string lines = R"(
417
100 NVIDIA VULKAN : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP
418
100 NVIDIA D3D11 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP)";
419
420
ASSERT_TRUE(load(lines));
421
ASSERT_TRUE(parser.getErrorMessages().empty());
422
423
EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),
424
GPUTestExpectationsParser::kGpuTestSkip);
425
}
426
427
std::string ConditionTestTypeName(testing::TestParamInfo<ConditionTestType> testParamInfo)
428
{
429
if (testParamInfo.param == ConditionTestType::OnLoad)
430
{
431
return "OnLoad";
432
}
433
else
434
{
435
return "OnGet";
436
}
437
}
438
439
INSTANTIATE_TEST_SUITE_P(,
440
GPUTestExpectationsParserTest,
441
testing::Values(ConditionTestType::OnGet, ConditionTestType::OnLoad),
442
ConditionTestTypeName);
443
} // anonymous namespace
444
445