• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <istream>
33 
34 namespace tcu
35 {
36 
37 /*--------------------------------------------------------------------*//*!
38  * \brief Run mode tells whether the test program should run the tests or
39  *		  dump out metadata about the tests.
40  *//*--------------------------------------------------------------------*/
41 enum RunMode
42 {
43 	RUNMODE_EXECUTE = 0,			//! Test program executes the tests.
44 	RUNMODE_DUMP_XML_CASELIST,		//! Test program dumps the list of contained test cases in XML format.
45 	RUNMODE_DUMP_TEXT_CASELIST,		//! Test program dumps the list of contained test cases in plain-text format.
46 	RUNMODE_DUMP_STDOUT_CASELIST,	//! Test program dumps the list of contained test cases in plain-text format into stdout.
47 
48 	RUNMODE_LAST
49 };
50 
51 /*--------------------------------------------------------------------*//*!
52  * \brief Should graphical tests show rendering results on screen.
53  *//*--------------------------------------------------------------------*/
54 enum WindowVisibility
55 {
56 	WINDOWVISIBILITY_WINDOWED = 0,
57 	WINDOWVISIBILITY_FULLSCREEN,
58 	WINDOWVISIBILITY_HIDDEN,
59 
60 	WINDOWVISIBILITY_LAST
61 };
62 
63 /*--------------------------------------------------------------------*//*!
64  * \brief The type of rendering surface the tests should be executed on.
65  *//*--------------------------------------------------------------------*/
66 enum SurfaceType
67 {
68 	SURFACETYPE_WINDOW = 0,			//!< Native window.
69 	SURFACETYPE_OFFSCREEN_NATIVE,	//!< Native offscreen surface, such as pixmap.
70 	SURFACETYPE_OFFSCREEN_GENERIC,	//!< Generic offscreen surface, such as pbuffer.
71 	SURFACETYPE_FBO,				//!< Framebuffer object.
72 
73 	SURFACETYPE_LAST
74 };
75 
76 /*--------------------------------------------------------------------*//*!
77  * \brief Screen rotation, always to clockwise direction.
78  *//*--------------------------------------------------------------------*/
79 enum ScreenRotation
80 {
81 	SCREENROTATION_UNSPECIFIED,		//!< Use default / current orientation.
82 	SCREENROTATION_0,				//!< Set rotation to 0 degrees from baseline.
83 	SCREENROTATION_90,
84 	SCREENROTATION_180,
85 	SCREENROTATION_270,
86 
87 	SCREENROTATION_LAST
88 };
89 
90 class CaseTreeNode;
91 class CasePaths;
92 class Archive;
93 
94 class CaseListFilter
95 {
96 public:
97 									CaseListFilter				(const de::cmdline::CommandLine& cmdLine, const tcu::Archive& archive);
98 									CaseListFilter				(void);
99 									~CaseListFilter				(void);
100 
101 	//! Check if test group is in supplied test case list.
102 	bool							checkTestGroupName			(const char* groupName) const;
103 
104 	//! Check if test case is in supplied test case list.
105 	bool							checkTestCaseName			(const char* caseName) const;
106 
107 	//! Check if test group passes the case fraction filter.
108 	bool							checkCaseFraction			(int i, const std::string& testCaseName) const;
109 
110 private:
111 	CaseListFilter												(const CaseListFilter&);	// not allowed!
112 	CaseListFilter&					operator=					(const CaseListFilter&);	// not allowed!
113 
114 	CaseTreeNode*					m_caseTree;
115 	de::MovePtr<const CasePaths>	m_casePaths;
116 	std::vector<int>				m_caseFraction;
117 	de::MovePtr<const CasePaths>	m_caseFractionMandatoryTests;
118 };
119 
120 /*--------------------------------------------------------------------*//*!
121  * \brief Test command line
122  *
123  * CommandLine handles argument parsing and provides convinience functions
124  * for querying test parameters.
125  *//*--------------------------------------------------------------------*/
126 class CommandLine
127 {
128 public:
129 									CommandLine						(void);
130 									CommandLine						(int argc, const char* const* argv);
131 	explicit						CommandLine						(const std::string& cmdLine);
132 									~CommandLine					(void);
133 
134 	bool							parse							(int argc, const char* const* argv);
135 	bool							parse							(const std::string& cmdLine);
136 
137 	//! Get log file name (--deqp-log-filename)
138 	const char*						getLogFileName					(void) const;
139 
140 	//! Get logging flags
141 	deUint32						getLogFlags						(void) const;
142 
143 	//! Get run mode (--deqp-runmode)
144 	RunMode							getRunMode						(void) const;
145 
146 	//! Get caselist dump target file pattern (--deqp-caselist-export-file)
147 	const char*						getCaseListExportFile			(void) const;
148 
149 	//! Get default window visibility (--deqp-visibility)
150 	WindowVisibility				getVisibility					(void) const;
151 
152 	//! Get watchdog enable status (--deqp-watchdog)
153 	bool							isWatchDogEnabled				(void) const;
154 
155 	//! Get crash handling enable status (--deqp-crashhandler)
156 	bool							isCrashHandlingEnabled			(void) const;
157 
158 	//! Get base seed for randomization (--deqp-base-seed)
159 	int								getBaseSeed						(void) const;
160 
161 	//! Get test iteration count (--deqp-test-iteration-count)
162 	int								getTestIterationCount			(void) const;
163 
164 	//! Get rendering target width (--deqp-surface-width)
165 	int								getSurfaceWidth					(void) const;
166 
167 	//! Get rendering target height (--deqp-surface-height)
168 	int								getSurfaceHeight				(void) const;
169 
170 	//! Get rendering taget type (--deqp-surface-type)
171 	SurfaceType						getSurfaceType					(void) const;
172 
173 	//! Get screen rotation (--deqp-screen-rotation)
174 	ScreenRotation					getScreenRotation				(void) const;
175 
176 	//! Get GL context factory name (--deqp-gl-context-type)
177 	const char*						getGLContextType				(void) const;
178 
179 	//! Get GL config ID (--deqp-gl-config-id)
180 	int								getGLConfigId					(void) const;
181 
182 	//! Get GL config name (--deqp-gl-config-name)
183 	const char*						getGLConfigName					(void) const;
184 
185 	//! Get GL context flags (--deqp-gl-context-flags)
186 	const char*						getGLContextFlags				(void) const;
187 
188 	//! Get OpenCL platform ID (--deqp-cl-platform-id)
189 	int								getCLPlatformId					(void) const;
190 
191 	//! Get OpenCL device IDs (--deqp-cl-device-ids)
getCLDeviceIds(std::vector<int> & deviceIds) const192 	void							getCLDeviceIds					(std::vector<int>& deviceIds) const	{ deviceIds = getCLDeviceIds(); }
193 	const std::vector<int>&			getCLDeviceIds					(void) const;
194 
195 	//! Get extra OpenCL program build options (--deqp-cl-build-options)
196 	const char*						getCLBuildOptions				(void) const;
197 
198 	//! Get EGL native display factory (--deqp-egl-display-type)
199 	const char*						getEGLDisplayType				(void) const;
200 
201 	//! Get EGL native window factory (--deqp-egl-window-type)
202 	const char*						getEGLWindowType				(void) const;
203 
204 	//! Get EGL native pixmap factory (--deqp-egl-pixmap-type)
205 	const char*						getEGLPixmapType				(void) const;
206 
207 	//! Get Vulkan device ID (--deqp-vk-device-id)
208 	int								getVKDeviceId					(void) const;
209 
210 	//! Get Vulkan device group ID (--deqp-vk-device-group-id)
211 	int								getVKDeviceGroupId				(void) const;
212 
213 	//! Enable development-time test case validation checks
214 	bool							isValidationEnabled				(void) const;
215 
216 	//! Should we run tests that exhaust memory (--deqp-test-oom)
217 	bool							isOutOfMemoryTestEnabled		(void) const;
218 
219 	//! Should the shader cache be enabled (--deqp-shadercache)
220 	bool							isShadercacheEnabled			(void) const;
221 
222 	//! Get the filename for shader cache (--deqp-shadercache-filename)
223 	const char*						getShaderCacheFilename			(void) const;
224 
225 	//! Should the shader cache be truncated before run (--deqp-shadercache-truncate)
226 	bool							isShaderCacheTruncateEnabled	(void) const;
227 
228 	//! Get shader optimization recipe (--deqp-optimization-recipe)
229 	int								getOptimizationRecipe		(void) const;
230 
231 	//! Enable optimizing of spir-v (--deqp-optimize-spirv)
232 	bool							isSpirvOptimizationEnabled	(void) const;
233 
234 	//! Enable RenderDoc frame markers (--deqp-renderdoc)
235 	bool							isRenderDocEnabled			(void) const;
236 
237 	//! Get case list fraction
238 	const std::vector<int>&			getCaseFraction				(void) const;
239 
240 	//! Get must-list filename
241 	const char*						getCaseFractionMandatoryTests(void) const;
242 
243 	//! Get archive directory path
244 	const char*						getArchiveDir				(void) const;
245 
246 	/*--------------------------------------------------------------------*//*!
247 	 * \brief Creates case list filter
248 	 * \param archive Resources
249 	 *
250 	 * Creates case list filter based on one of the following parameters:
251 	 *
252 	 * --deqp-case
253 	 * --deqp-caselist
254 	 * --deqp-caselist-file
255 	 * --deqp-caselist-resource
256 	 * --deqp-stdin-caselist
257 	 *
258 	 * Throws std::invalid_argument if parsing fails.
259 	 *//*--------------------------------------------------------------------*/
260 	de::MovePtr<CaseListFilter>		createCaseListFilter		(const tcu::Archive& archive) const;
261 
262 protected:
263 	const de::cmdline::CommandLine&	getCommandLine				(void) const;
264 
265 private:
266 									CommandLine					(const CommandLine&);	// not allowed!
267 	CommandLine&					operator=					(const CommandLine&);	// not allowed!
268 
269 	void							clear						(void);
270 
271 	virtual void					registerExtendedOptions		(de::cmdline::Parser& parser);
272 
273 	de::cmdline::CommandLine		m_cmdLine;
274 	deUint32						m_logFlags;
275 };
276 
277 } // tcu
278 
279 #endif // _TCUCOMMANDLINE_HPP
280