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 33e5c31af7Sopenharmony_ci#include <cstdio> 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ci// Implement this in your platform port. 36e5c31af7Sopenharmony_citcu::Platform* createPlatform (void); 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_ciint main (int argc, char** argv) 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_ci int exitStatus = EXIT_SUCCESS; 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_ci#if (DE_OS != DE_OS_WIN32) 43e5c31af7Sopenharmony_ci // Set stdout to line-buffered mode (will be fully buffered by default if stdout is pipe). 44e5c31af7Sopenharmony_ci setvbuf(stdout, DE_NULL, _IOLBF, 4*1024); 45e5c31af7Sopenharmony_ci#endif 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ci try 48e5c31af7Sopenharmony_ci { 49e5c31af7Sopenharmony_ci tcu::CommandLine cmdLine (argc, argv); 50e5c31af7Sopenharmony_ci tcu::DirArchive archive (cmdLine.getArchiveDir()); 51e5c31af7Sopenharmony_ci tcu::TestLog log (cmdLine.getLogFileName(), cmdLine.getLogFlags()); 52e5c31af7Sopenharmony_ci de::UniquePtr<tcu::Platform> platform (createPlatform()); 53e5c31af7Sopenharmony_ci de::UniquePtr<tcu::App> app (new tcu::App(*platform, archive, log, cmdLine)); 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_ci // Main loop. 56e5c31af7Sopenharmony_ci for (;;) 57e5c31af7Sopenharmony_ci { 58e5c31af7Sopenharmony_ci if (!app->iterate()) 59e5c31af7Sopenharmony_ci { 60e5c31af7Sopenharmony_ci if (cmdLine.getRunMode() == tcu::RUNMODE_EXECUTE && 61e5c31af7Sopenharmony_ci (!app->getResult().isComplete || app->getResult().numFailed)) 62e5c31af7Sopenharmony_ci { 63e5c31af7Sopenharmony_ci exitStatus = EXIT_FAILURE; 64e5c31af7Sopenharmony_ci } 65e5c31af7Sopenharmony_ci 66e5c31af7Sopenharmony_ci break; 67e5c31af7Sopenharmony_ci } 68e5c31af7Sopenharmony_ci } 69e5c31af7Sopenharmony_ci } 70e5c31af7Sopenharmony_ci catch (const std::exception& e) 71e5c31af7Sopenharmony_ci { 72e5c31af7Sopenharmony_ci tcu::die("%s", e.what()); 73e5c31af7Sopenharmony_ci } 74e5c31af7Sopenharmony_ci 75e5c31af7Sopenharmony_ci return exitStatus; 76e5c31af7Sopenharmony_ci} 77