Home | History | Annotate | Download | only in common
      1 #ifndef _TCUCOMMANDLINE_HPP
      2 #define _TCUCOMMANDLINE_HPP
      3 /*-------------------------------------------------------------------------
      4  * drawElements Quality Program Tester Core
      5  * ----------------------------------------
      6  *
      7  * Copyright 2014 The Android Open Source Project
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  *//*!
     22  * \file
     23  * \brief Command line parsing.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "tcuDefs.hpp"
     27 #include "deCommandLine.hpp"
     28 #include "deUniquePtr.hpp"
     29 
     30 #include <string>
     31 #include <vector>
     32 
     33 namespace tcu
     34 {
     35 
     36 /*--------------------------------------------------------------------*//*!
     37  * \brief Run mode tells whether the test program should run the tests or
     38  *		  dump out metadata about the tests.
     39  *//*--------------------------------------------------------------------*/
     40 enum RunMode
     41 {
     42 	RUNMODE_EXECUTE = 0,			//! Test program executes the tests.
     43 	RUNMODE_DUMP_XML_CASELIST,		//! Test program dumps the list of contained test cases in XML format.
     44 	RUNMODE_DUMP_TEXT_CASELIST,		//! Test program dumps the list of contained test cases in plain-text format.
     45 
     46 	RUNMODE_LAST
     47 };
     48 
     49 /*--------------------------------------------------------------------*//*!
     50  * \brief Should graphical tests show rendering results on screen.
     51  *//*--------------------------------------------------------------------*/
     52 enum WindowVisibility
     53 {
     54 	WINDOWVISIBILITY_WINDOWED = 0,
     55 	WINDOWVISIBILITY_FULLSCREEN,
     56 	WINDOWVISIBILITY_HIDDEN,
     57 
     58 	WINDOWVISIBILITY_LAST
     59 };
     60 
     61 /*--------------------------------------------------------------------*//*!
     62  * \brief The type of rendering surface the tests should be executed on.
     63  *//*--------------------------------------------------------------------*/
     64 enum SurfaceType
     65 {
     66 	SURFACETYPE_WINDOW = 0,			//!< Native window.
     67 	SURFACETYPE_OFFSCREEN_NATIVE,	//!< Native offscreen surface, such as pixmap.
     68 	SURFACETYPE_OFFSCREEN_GENERIC,	//!< Generic offscreen surface, such as pbuffer.
     69 	SURFACETYPE_FBO,				//!< Framebuffer object.
     70 
     71 	SURFACETYPE_LAST
     72 };
     73 
     74 /*--------------------------------------------------------------------*//*!
     75  * \brief Screen rotation, always to clockwise direction.
     76  *//*--------------------------------------------------------------------*/
     77 enum ScreenRotation
     78 {
     79 	SCREENROTATION_UNSPECIFIED,		//!< Use default / current orientation.
     80 	SCREENROTATION_0,				//!< Set rotation to 0 degrees from baseline.
     81 	SCREENROTATION_90,
     82 	SCREENROTATION_180,
     83 	SCREENROTATION_270,
     84 
     85 	SCREENROTATION_LAST
     86 };
     87 
     88 class CaseTreeNode;
     89 class CasePaths;
     90 
     91 /*--------------------------------------------------------------------*//*!
     92  * \brief Test command line
     93  *
     94  * CommandLine handles argument parsing and provides convinience functions
     95  * for querying test parameters.
     96  *//*--------------------------------------------------------------------*/
     97 class CommandLine
     98 {
     99 public:
    100 									CommandLine					(void);
    101 									CommandLine					(int argc, const char* const* argv);
    102 	explicit						CommandLine					(const std::string& cmdLine);
    103 									~CommandLine				(void);
    104 
    105 	bool							parse						(int argc, const char* const* argv);
    106 	bool							parse						(const std::string& cmdLine);
    107 
    108 	//! Get log file name (--deqp-log-filename)
    109 	const char*						getLogFileName				(void) const;
    110 
    111 	//! Get logging flags
    112 	deUint32						getLogFlags					(void) const;
    113 
    114 	//! Get run mode (--deqp-runmode)
    115 	RunMode							getRunMode					(void) const;
    116 
    117 	//! Get default window visibility (--deqp-visibility)
    118 	WindowVisibility				getVisibility				(void) const;
    119 
    120 	//! Get watchdog enable status (--deqp-watchdog)
    121 	bool							isWatchDogEnabled			(void) const;
    122 
    123 	//! Get crash handling enable status (--deqp-crashhandler)
    124 	bool							isCrashHandlingEnabled		(void) const;
    125 
    126 	//! Get base seed for randomization (--deqp-base-seed)
    127 	int								getBaseSeed					(void) const;
    128 
    129 	//! Get test iteration count (--deqp-test-iteration-count)
    130 	int								getTestIterationCount		(void) const;
    131 
    132 	//! Get rendering target width (--deqp-surface-width)
    133 	int								getSurfaceWidth				(void) const;
    134 
    135 	//! Get rendering target height (--deqp-surface-height)
    136 	int								getSurfaceHeight			(void) const;
    137 
    138 	//! Get rendering taget type (--deqp-surface-type)
    139 	SurfaceType						getSurfaceType				(void) const;
    140 
    141 	//! Get screen rotation (--deqp-screen-rotation)
    142 	ScreenRotation					getScreenRotation			(void) const;
    143 
    144 	//! Get GL context factory name (--deqp-gl-context-type)
    145 	const char*						getGLContextType			(void) const;
    146 
    147 	//! Get GL config ID (--deqp-gl-config-id)
    148 	int								getGLConfigId				(void) const;
    149 
    150 	//! Get GL config name (--deqp-gl-config-name)
    151 	const char*						getGLConfigName				(void) const;
    152 
    153 	//! Get GL context flags (--deqp-gl-context-flags)
    154 	const char*						getGLContextFlags			(void) const;
    155 
    156 	//! Get OpenCL platform ID (--deqp-cl-platform-id)
    157 	int								getCLPlatformId				(void) const;
    158 
    159 	//! Get OpenCL device IDs (--deqp-cl-device-ids)
    160 	void							getCLDeviceIds				(std::vector<int>& deviceIds) const	{ deviceIds = getCLDeviceIds(); }
    161 	const std::vector<int>&			getCLDeviceIds				(void) const;
    162 
    163 	//! Get extra OpenCL program build options (--deqp-cl-build-options)
    164 	const char*						getCLBuildOptions			(void) const;
    165 
    166 	//! Get EGL native display factory (--deqp-egl-display-type)
    167 	const char*						getEGLDisplayType			(void) const;
    168 
    169 	//! Get EGL native window factory (--deqp-egl-window-type)
    170 	const char*						getEGLWindowType			(void) const;
    171 
    172 	//! Get EGL native pixmap factory (--deqp-egl-pixmap-type)
    173 	const char*						getEGLPixmapType			(void) const;
    174 
    175 	//! Should we run tests that exhaust memory (--deqp-test-oom)
    176 	bool							isOutOfMemoryTestEnabled(void) const;
    177 
    178 	//! Check if test group is in supplied test case list.
    179 	bool							checkTestGroupName			(const char* groupName) const;
    180 
    181 	//! Check if test case is in supplied test case list.
    182 	bool							checkTestCaseName			(const char* caseName) const;
    183 
    184 protected:
    185 	const de::cmdline::CommandLine&	getCommandLine				(void) const;
    186 
    187 private:
    188 									CommandLine					(const CommandLine&);	// not allowed!
    189 	CommandLine&					operator=					(const CommandLine&);	// not allowed!
    190 
    191 	void							clear						(void);
    192 
    193 	virtual void					registerExtendedOptions		(de::cmdline::Parser& parser);
    194 
    195 	de::cmdline::CommandLine		m_cmdLine;
    196 	deUint32						m_logFlags;
    197 	CaseTreeNode*					m_caseTree;
    198 	de::MovePtr<const CasePaths>	m_casePaths;
    199 };
    200 
    201 } // tcu
    202 
    203 #endif // _TCUCOMMANDLINE_HPP
    204