1e5c31af7Sopenharmony_ci/* 2e5c31af7Sopenharmony_ci * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 5e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e5c31af7Sopenharmony_ci * 9e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 13e5c31af7Sopenharmony_ci * limitations under the License. 14e5c31af7Sopenharmony_ci */ 15e5c31af7Sopenharmony_ci 16e5c31af7Sopenharmony_ci#include <cstdio> 17e5c31af7Sopenharmony_ci#include <iostream> 18e5c31af7Sopenharmony_ci#include "tcuDefs.hpp" 19e5c31af7Sopenharmony_ci#include "tcuCommandLine.hpp" 20e5c31af7Sopenharmony_ci#include "tcuPlatform.hpp" 21e5c31af7Sopenharmony_ci#include "tcuApp.hpp" 22e5c31af7Sopenharmony_ci#include "tcuResource.hpp" 23e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 24e5c31af7Sopenharmony_ci#include "tcuTestSessionExecutor.hpp" 25e5c31af7Sopenharmony_ci#include "deUniquePtr.hpp" 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ci#include "external/openglcts/modules/common/glcConfigPackage.hpp" 28e5c31af7Sopenharmony_ci#include "external/openglcts/modules/common/glcTestPackage.hpp" 29e5c31af7Sopenharmony_ci#include "external/openglcts/modules/gles2/es2cTestPackage.hpp" 30e5c31af7Sopenharmony_ci#include "external/openglcts/modules/gles3/es3cTestPackage.hpp" 31e5c31af7Sopenharmony_ci#include "external/openglcts/modules/gles32/es32cTestPackage.hpp" 32e5c31af7Sopenharmony_ci#include "external/openglcts/modules/gles31/es31cTestPackage.hpp" 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_ci#include "modules/egl/teglTestPackage.hpp" 35e5c31af7Sopenharmony_ci#include "modules/gles2/tes2TestPackage.hpp" 36e5c31af7Sopenharmony_ci#include "modules/gles3/tes3TestPackage.hpp" 37e5c31af7Sopenharmony_ci#include "modules/gles31/tes31TestPackage.hpp" 38e5c31af7Sopenharmony_ci 39e5c31af7Sopenharmony_ci#include "ohos_context_i.h" 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ci#include "tcuTestContext.hpp" 42e5c31af7Sopenharmony_ci#include "tcuOhosPlatform.hpp" 43e5c31af7Sopenharmony_ci 44e5c31af7Sopenharmony_cistatic tcu::TestPackage *createES2Package(tcu::TestContext &testCtx) 45e5c31af7Sopenharmony_ci{ 46e5c31af7Sopenharmony_ci return new es2cts::TestPackage(testCtx, "KHR-GLES2"); 47e5c31af7Sopenharmony_ci} 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_cistatic tcu::TestPackage *createES32Package(tcu::TestContext &testCtx) 50e5c31af7Sopenharmony_ci{ 51e5c31af7Sopenharmony_ci return new es32cts::ES32TestPackage(testCtx, "KHR-GLES32"); 52e5c31af7Sopenharmony_ci} 53e5c31af7Sopenharmony_cistatic tcu::TestPackage* createES30Package(tcu::TestContext& testCtx) 54e5c31af7Sopenharmony_ci{ 55e5c31af7Sopenharmony_ci return new es3cts::ES30TestPackage(testCtx, "KHR-GLES3"); 56e5c31af7Sopenharmony_ci} 57e5c31af7Sopenharmony_cistatic tcu::TestPackage* createES31Package(tcu::TestContext& testCtx) 58e5c31af7Sopenharmony_ci{ 59e5c31af7Sopenharmony_ci return new es31cts::ES31TestPackage(testCtx, "KHR-GLES31"); 60e5c31af7Sopenharmony_ci} 61e5c31af7Sopenharmony_ci 62e5c31af7Sopenharmony_cistatic tcu::TestPackage* createdEQPES2Package(tcu::TestContext& testCtx) 63e5c31af7Sopenharmony_ci{ 64e5c31af7Sopenharmony_ci return new deqp::gles2::TestPackage(testCtx); 65e5c31af7Sopenharmony_ci} 66e5c31af7Sopenharmony_cistatic tcu::TestPackage* createdEQPES30Package(tcu::TestContext& testCtx) 67e5c31af7Sopenharmony_ci{ 68e5c31af7Sopenharmony_ci return new deqp::gles3::TestPackage(testCtx); 69e5c31af7Sopenharmony_ci} 70e5c31af7Sopenharmony_cistatic tcu::TestPackage* createdEQPES31Package(tcu::TestContext& testCtx) 71e5c31af7Sopenharmony_ci{ 72e5c31af7Sopenharmony_ci return new deqp::gles31::TestPackage(testCtx); 73e5c31af7Sopenharmony_ci} 74e5c31af7Sopenharmony_cistatic tcu::TestPackage* createdEQPEGLPackage(tcu::TestContext& testCtx) 75e5c31af7Sopenharmony_ci{ 76e5c31af7Sopenharmony_ci return new deqp::egl::TestPackage(testCtx); 77e5c31af7Sopenharmony_ci} 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_ci// Implement this in your platform port. 80e5c31af7Sopenharmony_ci 81e5c31af7Sopenharmony_civoid RegistPackage() 82e5c31af7Sopenharmony_ci{ 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_ci tcu::TestPackageRegistry *registry = tcu::TestPackageRegistry::getSingleton(); 85e5c31af7Sopenharmony_ci // registry->registerPackage("CTS-Configs", createConfigPackage); 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci // TODO: 判断当前上下文EGL环境是哪个? 88e5c31af7Sopenharmony_ci /* 89e5c31af7Sopenharmony_ciKHR-GLES2 90e5c31af7Sopenharmony_ciKHR-GLES3 91e5c31af7Sopenharmony_ciKHR-GLES31 92e5c31af7Sopenharmony_ciKHR-GLESEXT 93e5c31af7Sopenharmony_ciKHR-GLES32 94e5c31af7Sopenharmony_ci */ 95e5c31af7Sopenharmony_ci // OHOS::Rosen::RosenContext::GetInstance().GetGlesVer() == 3.2 96e5c31af7Sopenharmony_ci registry->registerPackage("KHR-GLES31", createES31Package); 97e5c31af7Sopenharmony_ci registry->registerPackage("KHR-GLES2", createES2Package); 98e5c31af7Sopenharmony_ci registry->registerPackage("KHR-GLES3", createES30Package); 99e5c31af7Sopenharmony_ci registry->registerPackage("KHR-GLES32", createES32Package); 100e5c31af7Sopenharmony_ci registry->registerPackage("dEQP-GLES2", createdEQPES2Package); 101e5c31af7Sopenharmony_ci registry->registerPackage("dEQP-GLES3", createdEQPES30Package); 102e5c31af7Sopenharmony_ci registry->registerPackage("dEQP-GLES31", createdEQPES31Package); 103e5c31af7Sopenharmony_ci registry->registerPackage("dEQP-EGL", createdEQPEGLPackage); 104e5c31af7Sopenharmony_ci} 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_cibool GetCasePath(tcu::TestNode *node, std::vector<tcu::TestNode *> &casePath, std::vector<std::string> &namePath, uint32_t deep = 0) 107e5c31af7Sopenharmony_ci{ 108e5c31af7Sopenharmony_ci if (deep >= namePath.size()) 109e5c31af7Sopenharmony_ci return false; 110e5c31af7Sopenharmony_ci if (namePath[deep].compare(node->getName()) != 0) 111e5c31af7Sopenharmony_ci return false; 112e5c31af7Sopenharmony_ci casePath.push_back(node); 113e5c31af7Sopenharmony_ci switch (node->getNodeType()) 114e5c31af7Sopenharmony_ci { 115e5c31af7Sopenharmony_ci case tcu::NODETYPE_ROOT: // = 0, //!< Root for all test packages. 116e5c31af7Sopenharmony_ci printf("NODETYPE_ROOT\n"); 117e5c31af7Sopenharmony_ci break; 118e5c31af7Sopenharmony_ci case tcu::NODETYPE_PACKAGE: //, //!< Test case package -- same as group, but is omitted from XML dump. 119e5c31af7Sopenharmony_ci case tcu::NODETYPE_GROUP: //, //!< Test case container -- cannot be executed. 120e5c31af7Sopenharmony_ci printf("NODETYPE_GROUP\n"); 121e5c31af7Sopenharmony_ci { 122e5c31af7Sopenharmony_ci std::vector<tcu::TestNode *> children; 123e5c31af7Sopenharmony_ci node->getChildren(children); 124e5c31af7Sopenharmony_ci for (uint32_t i = 0; i < children.size(); i++) 125e5c31af7Sopenharmony_ci { 126e5c31af7Sopenharmony_ci // printf("-----------%s==%s\n",children[i]->getName(),namePath[deep+1].c_str()); 127e5c31af7Sopenharmony_ci if (GetCasePath(children[i], casePath, namePath, deep + 1)) 128e5c31af7Sopenharmony_ci return true; 129e5c31af7Sopenharmony_ci } 130e5c31af7Sopenharmony_ci } 131e5c31af7Sopenharmony_ci break; 132e5c31af7Sopenharmony_ci case tcu::NODETYPE_SELF_VALIDATE: //, //!< Self-validating test case -- can be executed 133e5c31af7Sopenharmony_ci printf("NODETYPE_SELF_VALIDATE\n"); 134e5c31af7Sopenharmony_ci return true; 135e5c31af7Sopenharmony_ci case tcu::NODETYPE_PERFORMANCE: //, //!< Performace test case -- can be executed 136e5c31af7Sopenharmony_ci printf("NODETYPE_PERFORMANCE\n"); 137e5c31af7Sopenharmony_ci return true; 138e5c31af7Sopenharmony_ci case tcu::NODETYPE_CAPABILITY: //, //!< Capability score case -- can be executed 139e5c31af7Sopenharmony_ci printf("NODETYPE_CAPABILITY\n"); 140e5c31af7Sopenharmony_ci return true; 141e5c31af7Sopenharmony_ci case tcu::NODETYPE_ACCURACY: // //!< Accuracy test case -- can be executed 142e5c31af7Sopenharmony_ci printf("NODETYPE_ACCURACY\n"); 143e5c31af7Sopenharmony_ci return true; 144e5c31af7Sopenharmony_ci } 145e5c31af7Sopenharmony_ci return false; 146e5c31af7Sopenharmony_ci} 147e5c31af7Sopenharmony_ci 148e5c31af7Sopenharmony_ciint main(int argc, char **argv) 149e5c31af7Sopenharmony_ci{ 150e5c31af7Sopenharmony_ci printf("testmain start --- \n"); 151e5c31af7Sopenharmony_ci int exitStatus = EXIT_SUCCESS; 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_ci#if (DE_OS != DE_OS_WIN32) 154e5c31af7Sopenharmony_ci // Set stdout to line-buffered mode (will be fully buffered by default if stdout is pipe). 155e5c31af7Sopenharmony_ci setvbuf(stdout, DE_NULL, _IOLBF, 4 * 1024); 156e5c31af7Sopenharmony_ci#endif 157e5c31af7Sopenharmony_ci 158e5c31af7Sopenharmony_ci try 159e5c31af7Sopenharmony_ci { 160e5c31af7Sopenharmony_ci RegistPackage(); 161e5c31af7Sopenharmony_ci 162e5c31af7Sopenharmony_ci tcu::CommandLine cmdLine(argc, argv); 163e5c31af7Sopenharmony_ci tcu::DirArchive archive(cmdLine.getArchiveDir()); 164e5c31af7Sopenharmony_ci tcu::TestLog log(cmdLine.getLogFileName(), cmdLine.getLogFlags()); 165e5c31af7Sopenharmony_ci de::UniquePtr<tcu::Platform> platform(createOhosPlatform()); 166e5c31af7Sopenharmony_ci de::UniquePtr<tcu::App> app(new tcu::App(*platform, archive, log, cmdLine)); 167e5c31af7Sopenharmony_ci 168e5c31af7Sopenharmony_ci // Main loop. 169e5c31af7Sopenharmony_ci for (;;) 170e5c31af7Sopenharmony_ci { 171e5c31af7Sopenharmony_ci if (!app->iterate()) 172e5c31af7Sopenharmony_ci { 173e5c31af7Sopenharmony_ci if (cmdLine.getRunMode() == tcu::RUNMODE_EXECUTE && 174e5c31af7Sopenharmony_ci (!app->getResult().isComplete || app->getResult().numFailed)) 175e5c31af7Sopenharmony_ci { 176e5c31af7Sopenharmony_ci exitStatus = EXIT_FAILURE; 177e5c31af7Sopenharmony_ci } 178e5c31af7Sopenharmony_ci 179e5c31af7Sopenharmony_ci break; 180e5c31af7Sopenharmony_ci } 181e5c31af7Sopenharmony_ci } 182e5c31af7Sopenharmony_ci } 183e5c31af7Sopenharmony_ci catch (const std::exception &e) 184e5c31af7Sopenharmony_ci { 185e5c31af7Sopenharmony_ci tcu::die("%s", e.what()); 186e5c31af7Sopenharmony_ci } 187e5c31af7Sopenharmony_ci 188e5c31af7Sopenharmony_ci return exitStatus; 189e5c31af7Sopenharmony_ci}