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
33namespace 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 *//*--------------------------------------------------------------------*/
40enum 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	RUNMODE_DUMP_STDOUT_CASELIST,	//! Test program dumps the list of contained test cases in plain-text format into stdout.
46
47	RUNMODE_LAST
48};
49
50/*--------------------------------------------------------------------*//*!
51 * \brief Should graphical tests show rendering results on screen.
52 *//*--------------------------------------------------------------------*/
53enum WindowVisibility
54{
55	WINDOWVISIBILITY_WINDOWED = 0,
56	WINDOWVISIBILITY_FULLSCREEN,
57	WINDOWVISIBILITY_HIDDEN,
58
59	WINDOWVISIBILITY_LAST
60};
61
62/*--------------------------------------------------------------------*//*!
63 * \brief The type of rendering surface the tests should be executed on.
64 *//*--------------------------------------------------------------------*/
65enum SurfaceType
66{
67	SURFACETYPE_WINDOW = 0,			//!< Native window.
68	SURFACETYPE_OFFSCREEN_NATIVE,	//!< Native offscreen surface, such as pixmap.
69	SURFACETYPE_OFFSCREEN_GENERIC,	//!< Generic offscreen surface, such as pbuffer.
70	SURFACETYPE_FBO,				//!< Framebuffer object.
71
72	SURFACETYPE_LAST
73};
74
75/*--------------------------------------------------------------------*//*!
76 * \brief Screen rotation, always to clockwise direction.
77 *//*--------------------------------------------------------------------*/
78enum ScreenRotation
79{
80	SCREENROTATION_UNSPECIFIED,		//!< Use default / current orientation.
81	SCREENROTATION_0,				//!< Set rotation to 0 degrees from baseline.
82	SCREENROTATION_90,
83	SCREENROTATION_180,
84	SCREENROTATION_270,
85
86	SCREENROTATION_LAST
87};
88
89class CaseTreeNode;
90class CasePaths;
91
92/*--------------------------------------------------------------------*//*!
93 * \brief Test command line
94 *
95 * CommandLine handles argument parsing and provides convinience functions
96 * for querying test parameters.
97 *//*--------------------------------------------------------------------*/
98class CommandLine
99{
100public:
101									CommandLine					(void);
102									CommandLine					(int argc, const char* const* argv);
103	explicit						CommandLine					(const std::string& cmdLine);
104									~CommandLine				(void);
105
106	bool							parse						(int argc, const char* const* argv);
107	bool							parse						(const std::string& cmdLine);
108
109	//! Get log file name (--deqp-log-filename)
110	const char*						getLogFileName				(void) const;
111
112	//! Get logging flags
113	deUint32						getLogFlags					(void) const;
114
115	//! Get run mode (--deqp-runmode)
116	RunMode							getRunMode					(void) const;
117
118	//! Get caselist dump target file pattern (--deqp-caselist-export-file)
119	const char*						getCaseListExportFile		(void) const;
120
121	//! Get default window visibility (--deqp-visibility)
122	WindowVisibility				getVisibility				(void) const;
123
124	//! Get watchdog enable status (--deqp-watchdog)
125	bool							isWatchDogEnabled			(void) const;
126
127	//! Get crash handling enable status (--deqp-crashhandler)
128	bool							isCrashHandlingEnabled		(void) const;
129
130	//! Get base seed for randomization (--deqp-base-seed)
131	int								getBaseSeed					(void) const;
132
133	//! Get test iteration count (--deqp-test-iteration-count)
134	int								getTestIterationCount		(void) const;
135
136	//! Get rendering target width (--deqp-surface-width)
137	int								getSurfaceWidth				(void) const;
138
139	//! Get rendering target height (--deqp-surface-height)
140	int								getSurfaceHeight			(void) const;
141
142	//! Get rendering taget type (--deqp-surface-type)
143	SurfaceType						getSurfaceType				(void) const;
144
145	//! Get screen rotation (--deqp-screen-rotation)
146	ScreenRotation					getScreenRotation			(void) const;
147
148	//! Get GL context factory name (--deqp-gl-context-type)
149	const char*						getGLContextType			(void) const;
150
151	//! Get GL config ID (--deqp-gl-config-id)
152	int								getGLConfigId				(void) const;
153
154	//! Get GL config name (--deqp-gl-config-name)
155	const char*						getGLConfigName				(void) const;
156
157	//! Get GL context flags (--deqp-gl-context-flags)
158	const char*						getGLContextFlags			(void) const;
159
160	//! Get OpenCL platform ID (--deqp-cl-platform-id)
161	int								getCLPlatformId				(void) const;
162
163	//! Get OpenCL device IDs (--deqp-cl-device-ids)
164	void							getCLDeviceIds				(std::vector<int>& deviceIds) const	{ deviceIds = getCLDeviceIds(); }
165	const std::vector<int>&			getCLDeviceIds				(void) const;
166
167	//! Get extra OpenCL program build options (--deqp-cl-build-options)
168	const char*						getCLBuildOptions			(void) const;
169
170	//! Get EGL native display factory (--deqp-egl-display-type)
171	const char*						getEGLDisplayType			(void) const;
172
173	//! Get EGL native window factory (--deqp-egl-window-type)
174	const char*						getEGLWindowType			(void) const;
175
176	//! Get EGL native pixmap factory (--deqp-egl-pixmap-type)
177	const char*						getEGLPixmapType			(void) const;
178
179	//! Get Vulkan device ID (--deqp-vk-device-id)
180	int								getVKDeviceId				(void) const;
181
182	//! Enable development-time test case validation checks
183	bool							isValidationEnabled			(void) const;
184
185	//! Should we run tests that exhaust memory (--deqp-test-oom)
186	bool							isOutOfMemoryTestEnabled(void) const;
187
188	//! Check if test group is in supplied test case list.
189	bool							checkTestGroupName			(const char* groupName) const;
190
191	//! Check if test case is in supplied test case list.
192	bool							checkTestCaseName			(const char* caseName) const;
193
194protected:
195	const de::cmdline::CommandLine&	getCommandLine				(void) const;
196
197private:
198									CommandLine					(const CommandLine&);	// not allowed!
199	CommandLine&					operator=					(const CommandLine&);	// not allowed!
200
201	void							clear						(void);
202
203	virtual void					registerExtendedOptions		(de::cmdline::Parser& parser);
204
205	de::cmdline::CommandLine		m_cmdLine;
206	deUint32						m_logFlags;
207	CaseTreeNode*					m_caseTree;
208	de::MovePtr<const CasePaths>	m_casePaths;
209};
210
211} // tcu
212
213#endif // _TCUCOMMANDLINE_HPP
214