1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program Tester Core 3e5c31af7Sopenharmony_ci * ---------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Generic main(). 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "tcuDefs.hpp" 25e5c31af7Sopenharmony_ci#include "tcuCommandLine.hpp" 26e5c31af7Sopenharmony_ci#include "tcuPlatform.hpp" 27e5c31af7Sopenharmony_ci#include "tcuApp.hpp" 28e5c31af7Sopenharmony_ci#include "tcuResource.hpp" 29e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 30e5c31af7Sopenharmony_ci#include "tcuTestSessionExecutor.hpp" 31e5c31af7Sopenharmony_ci#include "deUniquePtr.hpp" 32e5c31af7Sopenharmony_ci#include "tcuOhosPlatform.hpp" 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_ci#include <cstdio> 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ci// Implement this in your platform port. 37e5c31af7Sopenharmony_citcu::Platform* createPlatform (void); 38e5c31af7Sopenharmony_ci 39e5c31af7Sopenharmony_ciint main (int argc, char** argv) 40e5c31af7Sopenharmony_ci{ 41e5c31af7Sopenharmony_ci int exitStatus = EXIT_SUCCESS; 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_ci#if (DE_OS != DE_OS_WIN32) 44e5c31af7Sopenharmony_ci // Set stdout to line-buffered mode (will be fully buffered by default if stdout is pipe). 45e5c31af7Sopenharmony_ci setvbuf(stdout, DE_NULL, _IOLBF, 4*1024); 46e5c31af7Sopenharmony_ci#endif 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ci try 49e5c31af7Sopenharmony_ci { 50e5c31af7Sopenharmony_ci tcu::CommandLine cmdLine (argc, argv); 51e5c31af7Sopenharmony_ci tcu::DirArchive archive (cmdLine.getArchiveDir()); 52e5c31af7Sopenharmony_ci tcu::TestLog log (cmdLine.getLogFileName(), cmdLine.getLogFlags()); 53e5c31af7Sopenharmony_ci de::UniquePtr<tcu::Platform> platform (createOhosPlatform()); 54e5c31af7Sopenharmony_ci de::UniquePtr<tcu::App> app (new tcu::App(*platform, archive, log, cmdLine)); 55e5c31af7Sopenharmony_ci 56e5c31af7Sopenharmony_ci // Main loop. 57e5c31af7Sopenharmony_ci for (;;) 58e5c31af7Sopenharmony_ci { 59e5c31af7Sopenharmony_ci if (!app->iterate()) 60e5c31af7Sopenharmony_ci { 61e5c31af7Sopenharmony_ci if (cmdLine.getRunMode() == tcu::RUNMODE_EXECUTE && 62e5c31af7Sopenharmony_ci (!app->getResult().isComplete || app->getResult().numFailed)) 63e5c31af7Sopenharmony_ci { 64e5c31af7Sopenharmony_ci exitStatus = EXIT_FAILURE; 65e5c31af7Sopenharmony_ci } 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci break; 68e5c31af7Sopenharmony_ci } 69e5c31af7Sopenharmony_ci } 70e5c31af7Sopenharmony_ci } 71e5c31af7Sopenharmony_ci catch (const std::exception& e) 72e5c31af7Sopenharmony_ci { 73e5c31af7Sopenharmony_ci tcu::die("%s", e.what()); 74e5c31af7Sopenharmony_ci } 75e5c31af7Sopenharmony_ci 76e5c31af7Sopenharmony_ci return exitStatus; 77e5c31af7Sopenharmony_ci}