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