Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Side by Side Diff: tests/TestConfigParsing.cpp

Issue 1490113005: Add config options to run different GPU APIs to dm and nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-03-context-factory-glcontext-type
Patch Set: fix chromium build Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/StringTest.cpp ('k') | tools/flags/SkCommandLineFlags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
mtklein 2015/12/15 23:47:39 Before you reland this, please make sure these new
8 #include "SkCommonFlagsConfig.h"
9 #include "Test.h"
10
11 DEF_TEST(ParseConfigs_Gpu, reporter) {
12 // Parses a normal config and returns correct "tag".
13 // Gpu config defaults work.
14 DEFINE_string(config1, "gpu", "");
15 SkCommandLineConfigArray configs;
16 ParseConfigs(FLAGS_config1, &configs);
17
18 REPORTER_ASSERT(reporter, configs.count() == 1);
19 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu"));
20 REPORTER_ASSERT(reporter, configs[0]->getViaParts().count() == 0);
21 #if SK_SUPPORT_GPU
22 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu());
23 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType()
24 == GrContextFactory::kNative_GLContextType);
25 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false);
26 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false );
27 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
28 #endif
29 }
30
31 DEF_TEST(ParseConfigs_OutParam, reporter) {
32 // Clears the out parameter.
33 DEFINE_string(config1, "gpu", "");
34 SkCommandLineConfigArray configs;
35 ParseConfigs(FLAGS_config1, &configs);
36 REPORTER_ASSERT(reporter, configs.count() == 1);
37 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu"));
38 DEFINE_string(config2, "8888", "");
39 ParseConfigs(FLAGS_config2, &configs);
40 REPORTER_ASSERT(reporter, configs.count() == 1);
41 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("8888"));
42 }
43
44 DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
45 // Parses all default configs and returns correct "tag".
46
47 DEFINE_string(config1, "565 8888 debug gpu gpudebug gpudft gpunull "
48 "msaa16 msaa4 nonrendering null nullgpu nvprmsaa16 nvprmsaa4 "
49 "pdf pdf_poppler skp svg xps angle angle-gl commandbuffer "
50 "mesa hwui", "");
51
52 SkCommandLineConfigArray configs;
53 ParseConfigs(FLAGS_config1, &configs);
54
55 const char* expectedConfigs[] = {
56 "565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16" , "msaa4",
57 "nonrendering", "null", "nullgpu", "nvprmsaa16", "nvprmsaa4", "pdf", "pd f_poppler",
58 "skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui "
59 };
60 REPORTER_ASSERT(reporter, configs.count() == static_cast<int>(SK_ARRAY_COUNT (expectedConfigs)));
61 for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs)); ++i) {
62 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(expectedConfigs[i] ));
63 REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == 0);
64 }
65 #if SK_SUPPORT_GPU
66 REPORTER_ASSERT(reporter, !configs[0]->asConfigGpu());
67 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
68 REPORTER_ASSERT(reporter, configs[2]->asConfigGpu());
69 REPORTER_ASSERT(reporter, configs[3]->asConfigGpu());
70 REPORTER_ASSERT(reporter, configs[4]->asConfigGpu());
71 REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getUseDIText());
72 REPORTER_ASSERT(reporter, configs[6]->asConfigGpu());
73 REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 16);
74 REPORTER_ASSERT(reporter, configs[8]->asConfigGpu()->getSamples() == 4);
75 REPORTER_ASSERT(reporter, !configs[9]->asConfigGpu());
76 REPORTER_ASSERT(reporter, !configs[10]->asConfigGpu());
77 REPORTER_ASSERT(reporter, configs[11]->asConfigGpu());
78 REPORTER_ASSERT(reporter, configs[12]->asConfigGpu()->getSamples() == 16);
79 REPORTER_ASSERT(reporter, configs[12]->asConfigGpu()->getUseNVPR());
80 REPORTER_ASSERT(reporter, configs[13]->asConfigGpu()->getSamples() == 4);
81 REPORTER_ASSERT(reporter, configs[13]->asConfigGpu()->getUseNVPR());
82 REPORTER_ASSERT(reporter, !configs[14]->asConfigGpu());
83 REPORTER_ASSERT(reporter, !configs[15]->asConfigGpu());
84 REPORTER_ASSERT(reporter, !configs[16]->asConfigGpu());
85 REPORTER_ASSERT(reporter, !configs[17]->asConfigGpu());
86 REPORTER_ASSERT(reporter, !configs[18]->asConfigGpu());
87 REPORTER_ASSERT(reporter, !configs[23]->asConfigGpu());
88 #if SK_ANGLE
89 #ifdef SK_BUILD_FOR_WIN
90 REPORTER_ASSERT(reporter, configs[19]->asConfigGpu());
91 #else
92 REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu());
93 #endif
94 REPORTER_ASSERT(reporter, configs[20]->asConfigGpu());
95 #else
96 REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu());
97 REPORTER_ASSERT(reporter, !configs[20]->asConfigGpu());
98 #endif
99 #if SK_COMMAND_BUFFER
100 REPORTER_ASSERT(reporter, configs[21]->asConfigGpu());
101 #else
102 REPORTER_ASSERT(reporter, !configs[21]->asConfigGpu());
103 #endif
104 #if SK_MESA
105 REPORTER_ASSERT(reporter, configs[22]->asConfigGpu());
106 #else
107 REPORTER_ASSERT(reporter, !configs[22]->asConfigGpu());
108 #endif
109 #endif
110 }
111
112 DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) {
113 DEFINE_string(config1, "gpu(nvpr=true,dit=true) gpu(api=angle) gpu(api=angle -gl) "
114 "gpu(api=mesa,samples=77) gpu(dit=true,api=commandbuffer) gpu( ) gpu(api=gles)",
115 "");
116
117 SkCommandLineConfigArray configs;
118 ParseConfigs(FLAGS_config1, &configs);
119 const char* expectedTags[] = {
120 "gpu(nvpr=true,dit=true)",
121 "gpu(api=angle)",
122 "gpu(api=angle-gl)",
123 "gpu(api=mesa,samples=77)",
124 "gpu(dit=true,api=commandbuffer)",
125 "gpu()",
126 "gpu(api=gles)"
127 };
128 REPORTER_ASSERT(reporter, configs.count() == static_cast<int>(SK_ARRAY_COUNT (expectedTags)));
129 for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(expectedTags)); ++i) {
130 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(expectedTags[i]));
131 }
132 #if SK_SUPPORT_GPU
133 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() ==
134 GrContextFactory::kNative_GLContextType);
135 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR());
136 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText());
137 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
138 #if SK_ANGLE
139 #ifdef SK_BUILD_FOR_WIN
140 REPORTER_ASSERT(reporter, configs[1]->asConfigGpu()->getContextType() ==
141 GrContextFactory::kANGLE_GLContextType);
142 #else
143 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
144 #endif
145 REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()->getContextType() ==
146 GrContextFactory::kANGLE_GL_GLContextType);
147 #else
148 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
149 REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu());
150 #endif
151 #if SK_MESA
152 REPORTER_ASSERT(reporter, configs[3]->asConfigGpu()->getContextType() ==
153 GrContextFactory::kMESA_GLContextType);
154 #else
155 REPORTER_ASSERT(reporter, !configs[3]->asConfigGpu());
156 #endif
157 #if SK_COMMAND_BUFFER
158 REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()->getContextType() ==
159 GrContextFactory::kCommandBuffer_GLContextType);
160
161 #else
162 REPORTER_ASSERT(reporter, !configs[4]->asConfigGpu());
163 #endif
164 REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() ==
165 GrContextFactory::kNative_GLContextType);
166 REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR());
167 REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText());
168 REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0);
169 REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() ==
170 GrContextFactory::kGLES_GLContextType);
171 REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR());
172 REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText());
173 REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0);
174
175 #endif
176 }
177
178 DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) {
179 DEFINE_string(config1, "gpu(nvpr=1) gpu(api=gl,) gpu(api=angle-glu) "
180 "gpu(api=,samples=0) gpu(samples=true) gpu(samples=0,samples=0 ) "
181 "gpu(,samples=0) gpu(samples=54 ,, gpu( samples=54", "");
182
183 SkCommandLineConfigArray configs;
184 ParseConfigs(FLAGS_config1, &configs);
185 const char* expectedTags[] = {
186 "gpu(nvpr=1)", // Number as bool.
187 "gpu(api=gl,)", // Trailing in comma.
188 "gpu(api=angle-glu)", // Unknown api.
189 "gpu(api=,samples=0)", // Empty api.
190 "gpu(samples=true)", // Value true as a number.
191 "gpu(samples=0,samples=0)", // Duplicate option key.
192 "gpu(,samples=0)", // Leading comma.
193 "gpu(samples=54", // Missing closing parenthesis.
194 ",,",
195 "gpu(", // Missing parenthesis.
196 "samples=54" // No backend.
197 };
198 REPORTER_ASSERT(reporter, configs.count() == static_cast<int>(SK_ARRAY_COUNT (expectedTags)));
199 for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(expectedTags)); ++i) {
200 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(expectedTags[i]));
201 #if SK_SUPPORT_GPU
202 REPORTER_ASSERT(reporter, !configs[i]->asConfigGpu());
203 #endif
204 }
205 }
206
207
208 DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) {
209 // These just list explicitly some properties of the system.
210 DEFINE_string(config1, "gpu(nvpr=true,dit=true) gpu(dit=true,nvpr=true) "
211 "gpu(api=native) gpu(api=gl) gpu(api=gles) "
212 "gpu gpu() gpu(samples=0) gpu(api=native,samples=0)", "");
213
214 SkCommandLineConfigArray configs;
215 ParseConfigs(FLAGS_config1, &configs);
216 const char* expectedTags[] = {
217 // Options are not canonized -> two same configs have a different tag.
218 "gpu(nvpr=true,dit=true)", "gpu(dit=true,nvpr=true)",
219 // API native is alias for gl or gles, but it's not canonized -> differe nt tag.
220 "gpu(api=native)", "gpu(api=gl)", "gpu(api=gles)", ""
221 // Default values are not canonized -> different tag.
222 "gpu", "gpu()", "gpu(samples=0)", "gpu(api=native,samples=0)"
223 };
224 REPORTER_ASSERT(reporter, configs.count() == static_cast<int>(SK_ARRAY_COUNT (expectedTags)));
225 for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(expectedTags)); ++i) {
226 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(expectedTags[i]));
227 #if SK_SUPPORT_GPU
228 REPORTER_ASSERT(reporter, configs[i]->asConfigGpu());
229 #endif
230 }
231 }
232 DEF_TEST(ParseConfigs_ViaParsing, reporter) {
233 DEFINE_string(config1, "a-b-c-33-8888 zz-qq-gpu a-angle-gl", "");
234
235 SkCommandLineConfigArray configs;
236 ParseConfigs(FLAGS_config1, &configs);
237 const struct {
238 const char* tag;
239 const char* vias[3];
240 } expectedConfigs[] = {
241 { "8888", {"a", "b", "c"}},
242 { "gpu", {"zz", "qq", nullptr}},
243 { "angle-gl", {"a", nullptr, nullptr } } // The angle-gl tag is only tag that contains
244 // hyphen.
245 };
246 for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs)); ++i) {
247 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(expectedConfigs[i] .tag));
248 for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].v ias)); ++j) {
249 if (!expectedConfigs[i].vias[j]) {
250 REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == s tatic_cast<int>(j));
251 break;
252 }
253 REPORTER_ASSERT(reporter, configs[i]->getViaParts()[j].equals(expect edConfigs[i].vias[j]));
254 }
255 }
256 }
257
258 DEF_TEST(ParseConfigs_ViaParsingExtendedForm, reporter) {
259 DEFINE_string(config1, "zz-qq-gpu(api=gles) a-gpu(samples=1", "");
260
261 SkCommandLineConfigArray configs;
262 ParseConfigs(FLAGS_config1, &configs);
263 const struct {
264 const char* tag;
265 const char* vias[3];
266 } expectedConfigs[] = {
267 { "gpu(api=gles)", {"zz", "qq", nullptr}},
268 { "gpu(samples=1", {"a", nullptr, nullptr } } // This is not extended fo rm, but via still
269 // works as expected.
270 };
271 for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs)); ++i) {
272 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(expectedConfigs[i] .tag));
273 for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].v ias)); ++j) {
274 if (!expectedConfigs[i].vias[j]) {
275 REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() ==
276 static_cast<int>(j));
277 break;
278 }
279 REPORTER_ASSERT(reporter,
280 configs[i]->getViaParts()[j].equals(expectedConfigs[ i].vias[j]));
281 }
282 }
283 #if SK_SUPPORT_GPU
284 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu());
285 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
286 #endif
287 }
OLDNEW
« no previous file with comments | « tests/StringTest.cpp ('k') | tools/flags/SkCommandLineFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698