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(IsMac(), config.getConditions()[GPUTestConfig::kConditionMac]);
27 EXPECT_EQ(IsIOS(), config.getConditions()[GPUTestConfig::kConditionIOS]);
28 EXPECT_EQ(IsLinux(), config.getConditions()[GPUTestConfig::kConditionLinux]);
29 EXPECT_EQ(IsAndroid(), config.getConditions()[GPUTestConfig::kConditionAndroid]);
30 EXPECT_EQ(IsNexus5X(), config.getConditions()[GPUTestConfig::kConditionNexus5X]);
31 EXPECT_EQ((IsPixel2() || IsPixel2XL()),
32 config.getConditions()[GPUTestConfig::kConditionPixel2OrXL]);
33 EXPECT_EQ(IsIntel(), config.getConditions()[GPUTestConfig::kConditionIntel]);
34 EXPECT_EQ(IsAMD(), config.getConditions()[GPUTestConfig::kConditionAMD]);
35 EXPECT_EQ(IsNVIDIA(), config.getConditions()[GPUTestConfig::kConditionNVIDIA]);
36 EXPECT_EQ(IsDebug(), config.getConditions()[GPUTestConfig::kConditionDebug]);
37 EXPECT_EQ(IsRelease(), config.getConditions()[GPUTestConfig::kConditionRelease]);
38 EXPECT_EQ(IsASan(), config.getConditions()[GPUTestConfig::kConditionASan]);
39 EXPECT_EQ(IsTSan(), config.getConditions()[GPUTestConfig::kConditionTSan]);
40 EXPECT_EQ(IsUBSan(), config.getConditions()[GPUTestConfig::kConditionUBSan]);
41 }
42
validateConfigAPI(const GPUTestConfig & config,const GPUTestConfig::API & api,uint32_t preRotation)43 void validateConfigAPI(const GPUTestConfig &config,
44 const GPUTestConfig::API &api,
45 uint32_t preRotation)
46 {
47 bool D3D9 = false;
48 bool D3D11 = false;
49 bool GLDesktop = false;
50 bool GLES = false;
51 bool Vulkan = false;
52 bool Metal = false;
53 switch (api)
54 {
55 case GPUTestConfig::kAPID3D9:
56 D3D9 = true;
57 break;
58 case GPUTestConfig::kAPID3D11:
59 D3D11 = true;
60 break;
61 case GPUTestConfig::kAPIGLDesktop:
62 GLDesktop = true;
63 break;
64 case GPUTestConfig::kAPIGLES:
65 GLES = true;
66 break;
67 case GPUTestConfig::kAPIVulkan:
68 Vulkan = true;
69 break;
70 case GPUTestConfig::kAPIMetal:
71 Metal = true;
72 break;
73 case GPUTestConfig::kAPIUnknown:
74 default:
75 break;
76 }
77 EXPECT_EQ(D3D9, config.getConditions()[GPUTestConfig::kConditionD3D9]);
78 EXPECT_EQ(D3D11, config.getConditions()[GPUTestConfig::kConditionD3D11]);
79 EXPECT_EQ(GLDesktop, config.getConditions()[GPUTestConfig::kConditionGLDesktop]);
80 EXPECT_EQ(GLES, config.getConditions()[GPUTestConfig::kConditionGLES]);
81 EXPECT_EQ(Vulkan, config.getConditions()[GPUTestConfig::kConditionVulkan]);
82 EXPECT_EQ(Metal, config.getConditions()[GPUTestConfig::kConditionMetal]);
83
84 switch (preRotation)
85 {
86 case 90:
87 EXPECT_TRUE(config.getConditions()[GPUTestConfig::kConditionPreRotation]);
88 EXPECT_TRUE(config.getConditions()[GPUTestConfig::kConditionPreRotation90]);
89 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation180]);
90 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation270]);
91 break;
92 case 180:
93 EXPECT_TRUE(config.getConditions()[GPUTestConfig::kConditionPreRotation]);
94 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation90]);
95 EXPECT_TRUE(config.getConditions()[GPUTestConfig::kConditionPreRotation180]);
96 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation270]);
97 break;
98 case 270:
99 EXPECT_TRUE(config.getConditions()[GPUTestConfig::kConditionPreRotation]);
100 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation90]);
101 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation180]);
102 EXPECT_TRUE(config.getConditions()[GPUTestConfig::kConditionPreRotation270]);
103 break;
104 default:
105 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation]);
106 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation90]);
107 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation180]);
108 EXPECT_FALSE(config.getConditions()[GPUTestConfig::kConditionPreRotation270]);
109 break;
110 }
111 }
112 };
113
114 // Create a new GPUTestConfig and make sure all the condition flags were set
115 // correctly based on the hardware.
TEST_P(GPUTestConfigTest,GPUTestConfigConditions)116 TEST_P(GPUTestConfigTest, GPUTestConfigConditions)
117 {
118 GPUTestConfig config;
119 validateConfigBase(config);
120 }
121
122 // Create a new GPUTestConfig with each backend specified and validate the
123 // condition flags are set correctly.
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_D3D9)124 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_D3D9)
125 {
126 GPUTestConfig config(GPUTestConfig::kAPID3D9, 0);
127 validateConfigAPI(config, GPUTestConfig::kAPID3D9, 0);
128 }
129
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_D3D11)130 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_D3D11)
131 {
132 GPUTestConfig config(GPUTestConfig::kAPID3D11, 0);
133 validateConfigAPI(config, GPUTestConfig::kAPID3D11, 0);
134 }
135
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_Metal)136 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_Metal)
137 {
138 GPUTestConfig config(GPUTestConfig::kAPIMetal, 0);
139 validateConfigAPI(config, GPUTestConfig::kAPIMetal, 0);
140 }
141
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_GLDesktop)142 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_GLDesktop)
143 {
144 GPUTestConfig config(GPUTestConfig::kAPIGLDesktop, 0);
145 validateConfigAPI(config, GPUTestConfig::kAPIGLDesktop, 0);
146 }
147
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_GLES)148 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_GLES)
149 {
150 GPUTestConfig config(GPUTestConfig::kAPIGLES, 0);
151 validateConfigAPI(config, GPUTestConfig::kAPIGLES, 0);
152 }
153
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_Vulkan)154 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_Vulkan)
155 {
156 GPUTestConfig config(GPUTestConfig::kAPIVulkan, 0);
157 validateConfigAPI(config, GPUTestConfig::kAPIVulkan, 0);
158 }
159
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_Vulkan_PreRotation90)160 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_Vulkan_PreRotation90)
161 {
162 GPUTestConfig config(GPUTestConfig::kAPIVulkan, 90);
163 validateConfigAPI(config, GPUTestConfig::kAPIVulkan, 90);
164 }
165
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_Vulkan_PreRotation180)166 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_Vulkan_PreRotation180)
167 {
168 GPUTestConfig config(GPUTestConfig::kAPIVulkan, 180);
169 validateConfigAPI(config, GPUTestConfig::kAPIVulkan, 180);
170 }
171
TEST_P(GPUTestConfigTest,GPUTestConfigConditions_Vulkan_PreRotation270)172 TEST_P(GPUTestConfigTest, GPUTestConfigConditions_Vulkan_PreRotation270)
173 {
174 GPUTestConfig config(GPUTestConfig::kAPIVulkan, 270);
175 validateConfigAPI(config, GPUTestConfig::kAPIVulkan, 270);
176 }
177
178 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
179 // tests should be run against.
180 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(GPUTestConfigTest);
181
182 } // namespace angle
183