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
7 // GPUTestExpectationsTest.cpp : Tests of the test_expectations library.
8
9 #include "test_expectations/GPUTestConfig.h"
10 #include "test_expectations/GPUTestExpectationsParser.h"
11 #include "test_utils/ANGLETest.h"
12
13 namespace angle
14 {
15
16 class GPUTestConfigTest : public ANGLETest
17 {
18 protected:
GPUTestConfigTest()19 GPUTestConfigTest() {}
20
21 // todo(jonahr): Eventually could add support for all conditions/operating
22 // systems, but these are the ones in use for now
validateConfigBase(const GPUTestConfig & config)23 void validateConfigBase(const GPUTestConfig &config)
24 {
25 EXPECT_EQ(IsWindows(), config.getConditions()[GPUTestConfig::kConditionWin]);
26 EXPECT_EQ(IsOSX(), config.getConditions()[GPUTestConfig::kConditionMac]);
27 EXPECT_EQ(IsLinux(), config.getConditions()[GPUTestConfig::kConditionLinux]);
28 EXPECT_EQ(IsAndroid(), config.getConditions()[GPUTestConfig::kConditionAndroid]);
29 EXPECT_EQ(IsNexus5X(), config.getConditions()[GPUTestConfig::kConditionNexus5X]);
30 EXPECT_EQ((IsPixel2() || IsPixel2XL()),
31 config.getConditions()[GPUTestConfig::kConditionPixel2OrXL]);
32 EXPECT_EQ(IsIntel(), config.getConditions()[GPUTestConfig::kConditionIntel]);
33 EXPECT_EQ(IsAMD(), config.getConditions()[GPUTestConfig::kConditionAMD]);
34 EXPECT_EQ(IsNVIDIA(), config.getConditions()[GPUTestConfig::kConditionNVIDIA]);
35 EXPECT_EQ(IsDebug(), config.getConditions()[GPUTestConfig::kConditionDebug]);
36 EXPECT_EQ(IsRelease(), config.getConditions()[GPUTestConfig::kConditionRelease]);
37 }
38
validateConfigAPI(const GPUTestConfig & config,const GPUTestConfig::API & api)39 void validateConfigAPI(const GPUTestConfig &config, const GPUTestConfig::API &api)
40 {
41 bool D3D9 = false;
42 bool D3D11 = false;
43 bool GLDesktop = false;
44 bool GLES = false;
45 bool Vulkan = false;
46 bool Metal = false;
47 switch (api)
48 {
49 case GPUTestConfig::kAPID3D9:
50 D3D9 = true;
51 break;
52 case GPUTestConfig::kAPID3D11:
53 D3D11 = true;
54 break;
55 case GPUTestConfig::kAPIGLDesktop:
56 GLDesktop = true;
57 break;
58 case GPUTestConfig::kAPIGLES:
59 GLES = true;
60 break;
61 case GPUTestConfig::kAPIVulkan:
62 Vulkan = true;
63 break;
64 case GPUTestConfig::kAPIMetal:
65 Metal = true;
66 break;
67 case GPUTestConfig::kAPIUnknown:
68 default:
69 break;
70 }
71 EXPECT_EQ(D3D9, config.getConditions()[GPUTestConfig::kConditionD3D9]);
72 EXPECT_EQ(D3D11, config.getConditions()[GPUTestConfig::kConditionD3D11]);
73 EXPECT_EQ(GLDesktop, config.getConditions()[GPUTestConfig::kConditionGLDesktop]);
74 EXPECT_EQ(GLES, config.getConditions()[GPUTestConfig::kConditionGLES]);
75 EXPECT_EQ(Vulkan, config.getConditions()[GPUTestConfig::kConditionVulkan]);
76 EXPECT_EQ(Metal, config.getConditions()[GPUTestConfig::kConditionMetal]);
77 }
78 };
79
80 // Create a new GPUTestConfig and make sure all the condition flags were set
81 // correctly based on the hardware.
TEST_P(GPUTestConfigTest,GPUTestConfigConditions)82 TEST_P(GPUTestConfigTest, GPUTestConfigConditions)
83 {
84 GPUTestConfig config;
85 validateConfigBase(config);
86 }
87
88 // Create a new GPUTestConfig with each backend specified and validate the
89 // condition flags are set correctly.
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_D3D9)90 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_D3D9)
91 {
92 GPUTestConfig config(GPUTestConfig::kAPID3D9);
93 validateConfigAPI(config, GPUTestConfig::kAPID3D9);
94 }
95
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_D3D11)96 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_D3D11)
97 {
98 GPUTestConfig config(GPUTestConfig::kAPID3D11);
99 validateConfigAPI(config, GPUTestConfig::kAPID3D11);
100 }
101
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_Metal)102 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_Metal)
103 {
104 GPUTestConfig config(GPUTestConfig::kAPIMetal);
105 validateConfigAPI(config, GPUTestConfig::kAPIMetal);
106 }
107
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_GLDesktop)108 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_GLDesktop)
109 {
110 GPUTestConfig config(GPUTestConfig::kAPIGLDesktop);
111 validateConfigAPI(config, GPUTestConfig::kAPIGLDesktop);
112 }
113
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_GLES)114 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_GLES)
115 {
116 GPUTestConfig config(GPUTestConfig::kAPIGLES);
117 validateConfigAPI(config, GPUTestConfig::kAPIGLES);
118 }
119
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_Vulkan)120 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_Vulkan)
121 {
122 GPUTestConfig config(GPUTestConfig::kAPIVulkan);
123 validateConfigAPI(config, GPUTestConfig::kAPIVulkan);
124 }
125
126 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
127 // tests should be run against.
128 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(GPUTestConfigTest);
129
130 } // namespace angle
131