• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <cstdio>
17 #include <iostream>
18 #include "tcuDefs.hpp"
19 #include "tcuCommandLine.hpp"
20 #include "tcuPlatform.hpp"
21 #include "tcuApp.hpp"
22 #include "tcuResource.hpp"
23 #include "tcuTestLog.hpp"
24 #include "tcuTestSessionExecutor.hpp"
25 #include "deUniquePtr.hpp"
26 
27 #include "external/openglcts/modules/common/glcConfigPackage.hpp"
28 #include "external/openglcts/modules/common/glcTestPackage.hpp"
29 #include "external/openglcts/modules/common/glcSingleConfigTestPackage.hpp"
30 #include "external/openglcts/modules/gles2/es2cTestPackage.hpp"
31 #include "external/openglcts/modules/gles3/es3cTestPackage.hpp"
32 #include "external/openglcts/modules/gles32/es32cTestPackage.hpp"
33 #include "external/openglcts/modules/gles31/es31cTestPackage.hpp"
34 #include "external/openglcts/modules/gl/gl3cTestPackages.hpp"
35 #include "external/openglcts/modules/gl/gl4cTestPackages.hpp"
36 
37 #include "modules/egl/teglTestPackage.hpp"
38 #include "modules/gles2/tes2TestPackage.hpp"
39 #include "modules/gles3/tes3TestPackage.hpp"
40 #include "modules/gles3/tgl45es3TestPackage.hpp"
41 #include "modules/gles31/tes31TestPackage.hpp"
42 #include "modules/gles31/tgl45es31TestPackage.hpp"
43 
44 #if defined(DEQP_GTF_AVAILABLE)
45 #include "gtfGL30TestPackage.hpp"
46 #include "gtfGL31TestPackage.hpp"
47 #include "gtfGL32TestPackage.hpp"
48 #include "gtfGL33TestPackage.hpp"
49 #include "gtfGL40TestPackage.hpp"
50 #include "gtfGL41TestPackage.hpp"
51 #include "gtfGL42TestPackage.hpp"
52 #include "gtfGL43TestPackage.hpp"
53 #include "gtfGL44TestPackage.hpp"
54 #include "gtfGL45TestPackage.hpp"
55 #include "gtfGL46TestPackage.hpp"
56 #endif
57 
58 #include "ohos_context_i.h"
59 
60 #include "tcuTestContext.hpp"
61 #include "tcuOhosPlatform.hpp"
62 
createES2Package(tcu::TestContext & testCtx)63 static tcu::TestPackage *createES2Package(tcu::TestContext &testCtx)
64 {
65     return new es2cts::TestPackage(testCtx, "KHR-GLES2");
66 }
67 
createES32Package(tcu::TestContext & testCtx)68 static tcu::TestPackage *createES32Package(tcu::TestContext &testCtx)
69 {
70     return new es32cts::ES32TestPackage(testCtx, "KHR-GLES32");
71 }
createES30Package(tcu::TestContext & testCtx)72 static tcu::TestPackage* createES30Package(tcu::TestContext& testCtx)
73 {
74 	return new es3cts::ES30TestPackage(testCtx, "KHR-GLES3");
75 }
createES31Package(tcu::TestContext & testCtx)76 static tcu::TestPackage* createES31Package(tcu::TestContext& testCtx)
77 {
78 	return new es31cts::ES31TestPackage(testCtx, "KHR-GLES31");
79 }
80 
createdEQPGL45ES31Package(tcu::TestContext & testCtx)81 static tcu::TestPackage* createdEQPGL45ES31Package(tcu::TestContext& testCtx)
82 {
83 	return new deqp::gles31::TestPackageGL45ES31(testCtx);
84 }
createdEQPGL45ES3Package(tcu::TestContext & testCtx)85 static tcu::TestPackage* createdEQPGL45ES3Package(tcu::TestContext& testCtx)
86 {
87 	return new deqp::gles3::TestPackageGL45ES3(testCtx);
88 }
89 
90 #if defined(DEQP_GTF_AVAILABLE)
createES2GTFPackage(tcu::TestContext & testCtx)91 static tcu::TestPackage* createES2GTFPackage(tcu::TestContext& testCtx)
92 {
93 	return new gtf::es2::TestPackage(testCtx, "GTF-GLES2");
94 }
95 #endif
96 
97 #if defined(DEQP_GTF_AVAILABLE)
createES30GTFPackage(tcu::TestContext & testCtx)98 static tcu::TestPackage* createES30GTFPackage(tcu::TestContext& testCtx)
99 {
100 	return new gtf::es3::TestPackage(testCtx, "GTF-GLES3");
101 }
102 #endif
103 
104 #if defined(DEQP_GTF_AVAILABLE)
createES31GTFPackage(tcu::TestContext & testCtx)105 static tcu::TestPackage* createES31GTFPackage(tcu::TestContext& testCtx)
106 {
107 	return new gtf::es31::TestPackage(testCtx, "GTF-GLES31");
108 }
109 #endif
110 
createdEQPES2Package(tcu::TestContext & testCtx)111 static tcu::TestPackage* createdEQPES2Package(tcu::TestContext& testCtx)
112 {
113 	return new deqp::gles2::TestPackage(testCtx);
114 }
createdEQPES30Package(tcu::TestContext & testCtx)115 static tcu::TestPackage* createdEQPES30Package(tcu::TestContext& testCtx)
116 {
117 	return new deqp::gles3::TestPackage(testCtx);
118 }
createdEQPES31Package(tcu::TestContext & testCtx)119 static tcu::TestPackage* createdEQPES31Package(tcu::TestContext& testCtx)
120 {
121 	return new deqp::gles31::TestPackage(testCtx);
122 }
createdEQPEGLPackage(tcu::TestContext & testCtx)123 static tcu::TestPackage* createdEQPEGLPackage(tcu::TestContext& testCtx)
124 {
125        return new deqp::egl::TestPackage(testCtx);
126 }
127 
createSingleConfigGL43TestPackage(tcu::TestContext & testCtx)128 static tcu::TestPackage* createSingleConfigGL43TestPackage(tcu::TestContext& testCtx)
129 {
130 	return new glcts::SingleConfigGL43TestPackage(testCtx, "KHR-Single-GL43");
131 }
createSingleConfigGL44TestPackage(tcu::TestContext & testCtx)132 static tcu::TestPackage* createSingleConfigGL44TestPackage(tcu::TestContext& testCtx)
133 {
134 	return new glcts::SingleConfigGL44TestPackage(testCtx, "KHR-Single-GL44");
135 }
createSingleConfigGL45TestPackage(tcu::TestContext & testCtx)136 static tcu::TestPackage* createSingleConfigGL45TestPackage(tcu::TestContext& testCtx)
137 {
138 	return new glcts::SingleConfigGL45TestPackage(testCtx, "KHR-Single-GL45");
139 }
createSingleConfigGL46TestPackage(tcu::TestContext & testCtx)140 static tcu::TestPackage* createSingleConfigGL46TestPackage(tcu::TestContext& testCtx)
141 {
142 	return new glcts::SingleConfigGL45TestPackage(testCtx, "KHR-Single-GL46");
143 }
createSingleConfigES32TestPackage(tcu::TestContext & testCtx)144 static tcu::TestPackage* createSingleConfigES32TestPackage(tcu::TestContext& testCtx)
145 {
146 	return new glcts::SingleConfigES32TestPackage(testCtx, "KHR-Single-GLES32");
147 }
148 
createGL30Package(tcu::TestContext & testCtx)149 static tcu::TestPackage* createGL30Package(tcu::TestContext& testCtx)
150 {
151 	return new gl3cts::GL30TestPackage(testCtx, "KHR-GL30");
152 }
createGL31Package(tcu::TestContext & testCtx)153 static tcu::TestPackage* createGL31Package(tcu::TestContext& testCtx)
154 {
155 	return new gl3cts::GL31TestPackage(testCtx, "KHR-GL31");
156 }
createGL32Package(tcu::TestContext & testCtx)157 static tcu::TestPackage* createGL32Package(tcu::TestContext& testCtx)
158 {
159 	return new gl3cts::GL32TestPackage(testCtx, "KHR-GL32");
160 }
createGL33Package(tcu::TestContext & testCtx)161 static tcu::TestPackage* createGL33Package(tcu::TestContext& testCtx)
162 {
163 	return new gl3cts::GL33TestPackage(testCtx, "KHR-GL33");
164 }
165 
createGL40Package(tcu::TestContext & testCtx)166 static tcu::TestPackage* createGL40Package(tcu::TestContext& testCtx)
167 {
168 	return new gl4cts::GL40TestPackage(testCtx, "KHR-GL40");
169 }
createGL41Package(tcu::TestContext & testCtx)170 static tcu::TestPackage* createGL41Package(tcu::TestContext& testCtx)
171 {
172 	return new gl4cts::GL41TestPackage(testCtx, "KHR-GL41");
173 }
createGL42Package(tcu::TestContext & testCtx)174 static tcu::TestPackage* createGL42Package(tcu::TestContext& testCtx)
175 {
176 	return new gl4cts::GL42TestPackage(testCtx, "KHR-GL42");
177 }
createGL42CompatPackage(tcu::TestContext & testCtx)178 static tcu::TestPackage* createGL42CompatPackage(tcu::TestContext& testCtx)
179 {
180 	return new gl4cts::GL42CompatTestPackage(testCtx, "KHR-GL42-COMPAT");
181 }
createGL43Package(tcu::TestContext & testCtx)182 static tcu::TestPackage* createGL43Package(tcu::TestContext& testCtx)
183 {
184 	return new gl4cts::GL43TestPackage(testCtx, "KHR-GL43");
185 }
createGL44Package(tcu::TestContext & testCtx)186 static tcu::TestPackage* createGL44Package(tcu::TestContext& testCtx)
187 {
188 	return new gl4cts::GL44TestPackage(testCtx, "KHR-GL44");
189 }
createGL45Package(tcu::TestContext & testCtx)190 static tcu::TestPackage* createGL45Package(tcu::TestContext& testCtx)
191 {
192 	return new gl4cts::GL45TestPackage(testCtx, "KHR-GL45");
193 }
createGL46Package(tcu::TestContext & testCtx)194 static tcu::TestPackage* createGL46Package(tcu::TestContext& testCtx)
195 {
196 	return new gl4cts::GL46TestPackage(testCtx, "KHR-GL46");
197 }
198 
199 #if defined(DEQP_GTF_AVAILABLE)
createGL30GTFPackage(tcu::TestContext & testCtx)200 static tcu::TestPackage* createGL30GTFPackage(tcu::TestContext& testCtx)
201 {
202 	return new gtf::gl30::TestPackage(testCtx, "GTF-GL30");
203 }
createGL31GTFPackage(tcu::TestContext & testCtx)204 static tcu::TestPackage* createGL31GTFPackage(tcu::TestContext& testCtx)
205 {
206 	return new gtf::gl31::TestPackage(testCtx, "GTF-GL31");
207 }
createGL32GTFPackage(tcu::TestContext & testCtx)208 static tcu::TestPackage* createGL32GTFPackage(tcu::TestContext& testCtx)
209 {
210 	return new gtf::gl32::TestPackage(testCtx, "GTF-GL32");
211 }
createGL33GTFPackage(tcu::TestContext & testCtx)212 static tcu::TestPackage* createGL33GTFPackage(tcu::TestContext& testCtx)
213 {
214 	return new gtf::gl32::TestPackage(testCtx, "GTF-GL33");
215 }
216 
createGL40GTFPackage(tcu::TestContext & testCtx)217 static tcu::TestPackage* createGL40GTFPackage(tcu::TestContext& testCtx)
218 {
219 	return new gtf::gl40::TestPackage(testCtx, "GTF-GL40");
220 }
createGL41GTFPackage(tcu::TestContext & testCtx)221 static tcu::TestPackage* createGL41GTFPackage(tcu::TestContext& testCtx)
222 {
223 	return new gtf::gl41::TestPackage(testCtx, "GTF-GL41");
224 }
createGL42GTFPackage(tcu::TestContext & testCtx)225 static tcu::TestPackage* createGL42GTFPackage(tcu::TestContext& testCtx)
226 {
227 	return new gtf::gl42::TestPackage(testCtx, "GTF-GL42");
228 }
createGL43GTFPackage(tcu::TestContext & testCtx)229 static tcu::TestPackage* createGL43GTFPackage(tcu::TestContext& testCtx)
230 {
231 	return new gtf::gl43::TestPackage(testCtx, "GTF-GL43");
232 }
createGL44GTFPackage(tcu::TestContext & testCtx)233 static tcu::TestPackage* createGL44GTFPackage(tcu::TestContext& testCtx)
234 {
235 	return new gtf::gl44::TestPackage(testCtx, "GTF-GL44");
236 }
createGL45GTFPackage(tcu::TestContext & testCtx)237 static tcu::TestPackage* createGL45GTFPackage(tcu::TestContext& testCtx)
238 {
239 	return new gtf::gl45::TestPackage(testCtx, "GTF-GL45");
240 }
createGL46GTFPackage(tcu::TestContext & testCtx)241 static tcu::TestPackage* createGL46GTFPackage(tcu::TestContext& testCtx)
242 {
243 	return new gtf::gl46::TestPackage(testCtx, "GTF-GL46");
244 }
245 #endif
246 
247 // Implement this in your platform port.
248 
RegistPackage()249 void RegistPackage()
250 {
251 
252     tcu::TestPackageRegistry *registry = tcu::TestPackageRegistry::getSingleton();
253     // registry->registerPackage("CTS-Configs", createConfigPackage);
254 
255     // TODO: 判断当前上下文EGL环境是哪个?
256     /*
257 KHR-GLES2
258 KHR-GLES3
259 KHR-GLES31
260 KHR-GLESEXT
261 KHR-GLES32
262     */
263     // OHOS::Rosen::RosenContext::GetInstance().GetGlesVer() == 3.2
264     registry->registerPackage("KHR-GLES31", createES31Package);
265     registry->registerPackage("KHR-GLES2", createES2Package);
266     registry->registerPackage("KHR-GLES3", createES30Package);
267     registry->registerPackage("KHR-GLES32", createES32Package);
268     registry->registerPackage("dEQP-GLES2", createdEQPES2Package);
269     registry->registerPackage("dEQP-GLES3", createdEQPES30Package);
270     registry->registerPackage("dEQP-GLES31", createdEQPES31Package);
271     registry->registerPackage("dEQP-EGL", createdEQPEGLPackage);
272     registry->registerPackage("KHR-GL30", createGL30Package);
273     registry->registerPackage("KHR-GL31", createGL31Package);
274 	registry->registerPackage("KHR-GL32", createGL32Package);
275 	registry->registerPackage("KHR-GL33", createGL33Package);
276 	registry->registerPackage("KHR-GL40", createGL40Package);
277 	registry->registerPackage("KHR-GL41", createGL41Package);
278 	registry->registerPackage("KHR-GL42", createGL42Package);
279 	registry->registerPackage("KHR-COMPAT-GL42", createGL42CompatPackage);
280 	registry->registerPackage("KHR-GL43", createGL43Package);
281 	registry->registerPackage("KHR-GL44", createGL44Package);
282 	registry->registerPackage("KHR-GL45", createGL45Package);
283 	registry->registerPackage("KHR-GL46", createGL46Package);
284     #if defined(DEQP_GTF_AVAILABLE)
285 	registry->registerPackage("GTF-GLES2", createES2GTFPackage);
286     registry->registerPackage("GTF-GLES3", createES30GTFPackage);
287     registry->registerPackage("GTF-GLES31", createES31GTFPackage);
288     registry->registerPackage("GTF-GL30", createGL30GTFPackage);
289 	registry->registerPackage("GTF-GL31", createGL31GTFPackage);
290 	registry->registerPackage("GTF-GL32", createGL32GTFPackage);
291 	registry->registerPackage("GTF-GL33", createGL33GTFPackage);
292 
293 	registry->registerPackage("GTF-GL40", createGL40GTFPackage);
294 	registry->registerPackage("GTF-GL41", createGL41GTFPackage);
295 	registry->registerPackage("GTF-GL42", createGL42GTFPackage);
296 	registry->registerPackage("GTF-GL43", createGL43GTFPackage);
297 	registry->registerPackage("GTF-GL44", createGL44GTFPackage);
298 	registry->registerPackage("GTF-GL45", createGL45GTFPackage);
299 	registry->registerPackage("GTF-GL46", createGL46GTFPackage);
300     #endif
301 	registry->registerPackage("dEQP-GL45-GLES31", createdEQPGL45ES31Package);
302 	registry->registerPackage("dEQP-GL45-GLES3", createdEQPGL45ES3Package);
303 	registry->registerPackage("KHR-Single-GL43", createSingleConfigGL43TestPackage);
304 	registry->registerPackage("KHR-Single-GL44", createSingleConfigGL44TestPackage);
305 	registry->registerPackage("KHR-Single-GL45", createSingleConfigGL45TestPackage);
306 	registry->registerPackage("KHR-Single-GL46", createSingleConfigGL46TestPackage);
307 	registry->registerPackage("KHR-Single-GLES32", createSingleConfigES32TestPackage);
308 }
309 
GetCasePath(tcu::TestNode * node,std::vector<tcu::TestNode * > & casePath,std::vector<std::string> & namePath,uint32_t deep=0)310 bool GetCasePath(tcu::TestNode *node, std::vector<tcu::TestNode *> &casePath, std::vector<std::string> &namePath, uint32_t deep = 0)
311 {
312     if (deep >= namePath.size())
313         return false;
314     if (namePath[deep].compare(node->getName()) != 0)
315         return false;
316     casePath.push_back(node);
317     switch (node->getNodeType())
318     {
319     case tcu::NODETYPE_ROOT: // = 0,		//!< Root for all test packages.
320         printf("NODETYPE_ROOT\n");
321         break;
322     case tcu::NODETYPE_PACKAGE: //,		//!< Test case package -- same as group, but is omitted from XML dump.
323     case tcu::NODETYPE_GROUP: //,			//!< Test case container -- cannot be executed.
324         printf("NODETYPE_GROUP\n");
325         {
326             std::vector<tcu::TestNode *> children;
327             node->getChildren(children);
328             for (uint32_t i = 0; i < children.size(); i++)
329             {
330                 // printf("-----------%s==%s\n",children[i]->getName(),namePath[deep+1].c_str());
331                 if (GetCasePath(children[i], casePath, namePath, deep + 1))
332                     return true;
333             }
334         }
335         break;
336     case tcu::NODETYPE_SELF_VALIDATE: //,	//!< Self-validating test case -- can be executed
337         printf("NODETYPE_SELF_VALIDATE\n");
338         return true;
339     case tcu::NODETYPE_PERFORMANCE: //,	//!< Performace test case -- can be executed
340         printf("NODETYPE_PERFORMANCE\n");
341         return true;
342     case tcu::NODETYPE_CAPABILITY: //,	//!< Capability score case -- can be executed
343         printf("NODETYPE_CAPABILITY\n");
344         return true;
345     case tcu::NODETYPE_ACCURACY: //		//!< Accuracy test case -- can be executed
346         printf("NODETYPE_ACCURACY\n");
347         return true;
348     }
349     return false;
350 }
351 
main(int argc,char ** argv)352 int main(int argc, char **argv)
353 {
354     printf("testmain start --- \n");
355     setenv("NEED_OPENG" , "1", 1);
356     setenv("LD_LIBRARY_PATH", "/system/lib64/:/system/lib64/ndk", 1);
357     int exitStatus = EXIT_SUCCESS;
358 
359 #if (DE_OS != DE_OS_WIN32)
360     // Set stdout to line-buffered mode (will be fully buffered by default if stdout is pipe).
361     setvbuf(stdout, DE_NULL, _IOLBF, 4 * 1024);
362 #endif
363 
364     try
365     {
366         RegistPackage();
367 
368         tcu::CommandLine cmdLine(argc, argv);
369         tcu::DirArchive archive(cmdLine.getArchiveDir());
370         tcu::TestLog log(cmdLine.getLogFileName(), cmdLine.getLogFlags());
371         de::UniquePtr<tcu::Platform> platform(createOhosPlatform());
372         de::UniquePtr<tcu::App> app(new tcu::App(*platform, archive, log, cmdLine));
373 
374         // Main loop.
375         for (;;)
376         {
377             if (!app->iterate())
378             {
379                 if (cmdLine.getRunMode() == tcu::RUNMODE_EXECUTE &&
380                     (!app->getResult().isComplete || app->getResult().numFailed))
381                 {
382                     exitStatus = EXIT_FAILURE;
383                 }
384 
385                 break;
386             }
387         }
388     }
389     catch (const std::exception &e)
390     {
391         tcu::die("%s", e.what());
392     }
393 
394     return exitStatus;
395 }