• 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/gles2/es2cTestPackage.hpp"
30 #include "external/openglcts/modules/gles3/es3cTestPackage.hpp"
31 #include "external/openglcts/modules/gles32/es32cTestPackage.hpp"
32 #include "external/openglcts/modules/gles31/es31cTestPackage.hpp"
33 
34 #include "modules/egl/teglTestPackage.hpp"
35 #include "modules/gles2/tes2TestPackage.hpp"
36 #include "modules/gles3/tes3TestPackage.hpp"
37 #include "modules/gles31/tes31TestPackage.hpp"
38 
39 #include "ohos_context_i.h"
40 
41 #include "tcuTestContext.hpp"
42 #include "tcuOhosPlatform.hpp"
43 
createES2Package(tcu::TestContext & testCtx)44 static tcu::TestPackage *createES2Package(tcu::TestContext &testCtx)
45 {
46     return new es2cts::TestPackage(testCtx, "KHR-GLES2");
47 }
48 
createES32Package(tcu::TestContext & testCtx)49 static tcu::TestPackage *createES32Package(tcu::TestContext &testCtx)
50 {
51     return new es32cts::ES32TestPackage(testCtx, "KHR-GLES32");
52 }
createES30Package(tcu::TestContext & testCtx)53 static tcu::TestPackage* createES30Package(tcu::TestContext& testCtx)
54 {
55 	return new es3cts::ES30TestPackage(testCtx, "KHR-GLES3");
56 }
createES31Package(tcu::TestContext & testCtx)57 static tcu::TestPackage* createES31Package(tcu::TestContext& testCtx)
58 {
59 	return new es31cts::ES31TestPackage(testCtx, "KHR-GLES31");
60 }
61 
createdEQPES2Package(tcu::TestContext & testCtx)62 static tcu::TestPackage* createdEQPES2Package(tcu::TestContext& testCtx)
63 {
64 	return new deqp::gles2::TestPackage(testCtx);
65 }
createdEQPES30Package(tcu::TestContext & testCtx)66 static tcu::TestPackage* createdEQPES30Package(tcu::TestContext& testCtx)
67 {
68 	return new deqp::gles3::TestPackage(testCtx);
69 }
createdEQPES31Package(tcu::TestContext & testCtx)70 static tcu::TestPackage* createdEQPES31Package(tcu::TestContext& testCtx)
71 {
72 	return new deqp::gles31::TestPackage(testCtx);
73 }
createdEQPEGLPackage(tcu::TestContext & testCtx)74 static tcu::TestPackage* createdEQPEGLPackage(tcu::TestContext& testCtx)
75 {
76        return new deqp::egl::TestPackage(testCtx);
77 }
78 
79 // Implement this in your platform port.
80 
RegistPackage()81 void RegistPackage()
82 {
83 
84     tcu::TestPackageRegistry *registry = tcu::TestPackageRegistry::getSingleton();
85     // registry->registerPackage("CTS-Configs", createConfigPackage);
86 
87     // TODO: 判断当前上下文EGL环境是哪个?
88     /*
89 KHR-GLES2
90 KHR-GLES3
91 KHR-GLES31
92 KHR-GLESEXT
93 KHR-GLES32
94     */
95     // OHOS::Rosen::RosenContext::GetInstance().GetGlesVer() == 3.2
96     registry->registerPackage("KHR-GLES31", createES31Package);
97     registry->registerPackage("KHR-GLES2", createES2Package);
98     registry->registerPackage("KHR-GLES3", createES30Package);
99     registry->registerPackage("KHR-GLES32", createES32Package);
100     registry->registerPackage("dEQP-GLES2", createdEQPES2Package);
101     registry->registerPackage("dEQP-GLES3", createdEQPES30Package);
102     registry->registerPackage("dEQP-GLES31", createdEQPES31Package);
103     registry->registerPackage("dEQP-EGL", createdEQPEGLPackage);
104 }
105 
GetCasePath(tcu::TestNode * node,std::vector<tcu::TestNode * > & casePath,std::vector<std::string> & namePath,uint32_t deep=0)106 bool GetCasePath(tcu::TestNode *node, std::vector<tcu::TestNode *> &casePath, std::vector<std::string> &namePath, uint32_t deep = 0)
107 {
108     if (deep >= namePath.size())
109         return false;
110     if (namePath[deep].compare(node->getName()) != 0)
111         return false;
112     casePath.push_back(node);
113     switch (node->getNodeType())
114     {
115     case tcu::NODETYPE_ROOT: // = 0,		//!< Root for all test packages.
116         printf("NODETYPE_ROOT\n");
117         break;
118     case tcu::NODETYPE_PACKAGE: //,		//!< Test case package -- same as group, but is omitted from XML dump.
119     case tcu::NODETYPE_GROUP: //,			//!< Test case container -- cannot be executed.
120         printf("NODETYPE_GROUP\n");
121         {
122             std::vector<tcu::TestNode *> children;
123             node->getChildren(children);
124             for (uint32_t i = 0; i < children.size(); i++)
125             {
126                 // printf("-----------%s==%s\n",children[i]->getName(),namePath[deep+1].c_str());
127                 if (GetCasePath(children[i], casePath, namePath, deep + 1))
128                     return true;
129             }
130         }
131         break;
132     case tcu::NODETYPE_SELF_VALIDATE: //,	//!< Self-validating test case -- can be executed
133         printf("NODETYPE_SELF_VALIDATE\n");
134         return true;
135     case tcu::NODETYPE_PERFORMANCE: //,	//!< Performace test case -- can be executed
136         printf("NODETYPE_PERFORMANCE\n");
137         return true;
138     case tcu::NODETYPE_CAPABILITY: //,	//!< Capability score case -- can be executed
139         printf("NODETYPE_CAPABILITY\n");
140         return true;
141     case tcu::NODETYPE_ACCURACY: //		//!< Accuracy test case -- can be executed
142         printf("NODETYPE_ACCURACY\n");
143         return true;
144     }
145     return false;
146 }
147 
main(int argc,char ** argv)148 int main(int argc, char **argv)
149 {
150     printf("testmain start --- \n");
151     int exitStatus = EXIT_SUCCESS;
152 
153 #if (DE_OS != DE_OS_WIN32)
154     // Set stdout to line-buffered mode (will be fully buffered by default if stdout is pipe).
155     setvbuf(stdout, DE_NULL, _IOLBF, 4 * 1024);
156 #endif
157 
158     try
159     {
160         RegistPackage();
161 
162         tcu::CommandLine cmdLine(argc, argv);
163         tcu::DirArchive archive(cmdLine.getArchiveDir());
164         tcu::TestLog log(cmdLine.getLogFileName(), cmdLine.getLogFlags());
165         de::UniquePtr<tcu::Platform> platform(createOhosPlatform());
166         de::UniquePtr<tcu::App> app(new tcu::App(*platform, archive, log, cmdLine));
167 
168         // Main loop.
169         for (;;)
170         {
171             if (!app->iterate())
172             {
173                 if (cmdLine.getRunMode() == tcu::RUNMODE_EXECUTE &&
174                     (!app->getResult().isComplete || app->getResult().numFailed))
175                 {
176                     exitStatus = EXIT_FAILURE;
177                 }
178 
179                 break;
180             }
181         }
182     }
183     catch (const std::exception &e)
184     {
185         tcu::die("%s", e.what());
186     }
187 
188     return exitStatus;
189 }