• 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 "tcuTestCase.hpp"
29 #include "deUniquePtr.hpp"
30 
31 #include <string>
32 #include <vector>
33 #include <istream>
34 
35 namespace tcu
36 {
37 
38 /*--------------------------------------------------------------------*//*!
39  * \brief Run mode tells whether the test program should run the tests or
40  *          dump out metadata about the tests.
41  *//*--------------------------------------------------------------------*/
42 enum RunMode
43 {
44     RUNMODE_EXECUTE = 0,        //! Test program executes the tests.
45     RUNMODE_DUMP_XML_CASELIST,  //! Test program dumps the list of contained test cases in XML format.
46     RUNMODE_DUMP_TEXT_CASELIST, //! Test program dumps the list of contained test cases in plain-text format.
47     RUNMODE_DUMP_STDOUT_CASELIST, //! Test program dumps the list of contained test cases in plain-text format into stdout.
48     RUNMODE_VERIFY_AMBER_COHERENCY, //! Test program verifies that amber tests have coherent capability requirements
49 
50     RUNMODE_LAST
51 };
52 
53 /*--------------------------------------------------------------------*//*!
54  * \brief Should graphical tests show rendering results on screen.
55  *//*--------------------------------------------------------------------*/
56 enum WindowVisibility
57 {
58     WINDOWVISIBILITY_WINDOWED = 0,
59     WINDOWVISIBILITY_FULLSCREEN,
60     WINDOWVISIBILITY_HIDDEN,
61 
62     WINDOWVISIBILITY_LAST
63 };
64 
65 /*--------------------------------------------------------------------*//*!
66  * \brief The type of rendering surface the tests should be executed on.
67  *//*--------------------------------------------------------------------*/
68 enum SurfaceType
69 {
70     SURFACETYPE_WINDOW = 0,        //!< Native window.
71     SURFACETYPE_OFFSCREEN_NATIVE,  //!< Native offscreen surface, such as pixmap.
72     SURFACETYPE_OFFSCREEN_GENERIC, //!< Generic offscreen surface, such as pbuffer.
73     SURFACETYPE_FBO,               //!< Framebuffer object.
74 
75     SURFACETYPE_LAST
76 };
77 
78 /*--------------------------------------------------------------------*//*!
79  * \brief Screen rotation, always to clockwise direction.
80  *//*--------------------------------------------------------------------*/
81 enum ScreenRotation
82 {
83     SCREENROTATION_UNSPECIFIED, //!< Use default / current orientation.
84     SCREENROTATION_0,           //!< Set rotation to 0 degrees from baseline.
85     SCREENROTATION_90,
86     SCREENROTATION_180,
87     SCREENROTATION_270,
88 
89     SCREENROTATION_LAST
90 };
91 
92 class CaseTreeNode;
93 class CasePaths;
94 class Archive;
95 
96 // Match a single path component against a pattern component that may contain *-wildcards.
97 bool matchWildcards(std::string::const_iterator patternStart, std::string::const_iterator patternEnd,
98                     std::string::const_iterator pathStart, std::string::const_iterator pathEnd, bool allowPrefix);
99 
100 class CaseListFilter
101 {
102 public:
103     CaseListFilter(const de::cmdline::CommandLine &cmdLine, const tcu::Archive &archive);
104     CaseListFilter(void);
105     ~CaseListFilter(void);
106 
107     //! Check if test group is in supplied test case list.
108     bool checkTestGroupName(const char *groupName) const;
109 
110     //! Check if test case is in supplied test case list.
111     bool checkTestCaseName(const char *caseName) const;
112 
113     //! Check if test group passes the case fraction filter.
114     bool checkCaseFraction(int i, const std::string &testCaseName) const;
115 
116     //! Check if test case runner is of supplied type
checkRunnerType(tcu::TestRunnerType type) const117     bool checkRunnerType(tcu::TestRunnerType type) const
118     {
119         return ((m_runnerType & type) == m_runnerType);
120     }
121 
122 private:
123     CaseListFilter(const CaseListFilter &);            // not allowed!
124     CaseListFilter &operator=(const CaseListFilter &); // not allowed!
125 
126     CaseTreeNode *m_caseTree;
127     de::MovePtr<const CasePaths> m_casePaths;
128     std::vector<int> m_caseFraction;
129     de::MovePtr<const CasePaths> m_caseFractionMandatoryTests;
130     tcu::TestRunnerType m_runnerType;
131 };
132 
133 /*--------------------------------------------------------------------*//*!
134  * \brief Test command line
135  *
136  * CommandLine handles argument parsing and provides convinience functions
137  * for querying test parameters.
138  *//*--------------------------------------------------------------------*/
139 class CommandLine
140 {
141 public:
142     CommandLine(void);
143     CommandLine(int argc, const char *const *argv);
144     explicit CommandLine(const std::string &cmdLine);
145     virtual ~CommandLine(void);
146 
147     bool parse(int argc, const char *const *argv);
148     bool parse(const std::string &cmdLine);
149 
150     const std::string &getApplicationName(void) const;
151     const std::string &getInitialCmdLine(void) const;
152 
153     //! Is quiet mode active?
154     bool quietMode(void) const;
155 
156     //! Get log file name (--deqp-log-filename)
157     const char *getLogFileName(void) const;
158 
159     //! Get logging flags
160     uint32_t getLogFlags(void) const;
161 
162     //! Get run mode (--deqp-runmode)
163     RunMode getRunMode(void) const;
164 
165     //! Get caselist dump target file pattern (--deqp-caselist-export-file)
166     const char *getCaseListExportFile(void) const;
167 
168     //! Get default window visibility (--deqp-visibility)
169     WindowVisibility getVisibility(void) const;
170 
171     //! Get watchdog enable status (--deqp-watchdog)
172     bool isWatchDogEnabled(void) const;
173 
174     //! Get crash handling enable status (--deqp-crashhandler)
175     bool isCrashHandlingEnabled(void) const;
176 
177     //! Get base seed for randomization (--deqp-base-seed)
178     int getBaseSeed(void) const;
179 
180     //! Get test iteration count (--deqp-test-iteration-count)
181     int getTestIterationCount(void) const;
182 
183     //! Get rendering target width (--deqp-surface-width)
184     int getSurfaceWidth(void) const;
185 
186     //! Get rendering target height (--deqp-surface-height)
187     int getSurfaceHeight(void) const;
188 
189     //! Get rendering taget type (--deqp-surface-type)
190     SurfaceType getSurfaceType(void) const;
191 
192     //! Get screen rotation (--deqp-screen-rotation)
193     ScreenRotation getScreenRotation(void) const;
194 
195     //! Get GL context factory name (--deqp-gl-context-type)
196     const char *getGLContextType(void) const;
197 
198     //! Get GL config ID (--deqp-gl-config-id)
199     int getGLConfigId(void) const;
200 
201     //! Get GL config name (--deqp-gl-config-name)
202     const char *getGLConfigName(void) const;
203 
204     //! Get GL context flags (--deqp-gl-context-flags)
205     const char *getGLContextFlags(void) const;
206 
207     //! Get OpenCL platform ID (--deqp-cl-platform-id)
208     int getCLPlatformId(void) const;
209 
210     //! Get OpenCL device IDs (--deqp-cl-device-ids)
getCLDeviceIds(std::vector<int> & deviceIds) const211     void getCLDeviceIds(std::vector<int> &deviceIds) const
212     {
213         deviceIds = getCLDeviceIds();
214     }
215     const std::vector<int> &getCLDeviceIds(void) const;
216 
217     //! Get extra OpenCL program build options (--deqp-cl-build-options)
218     const char *getCLBuildOptions(void) const;
219 
220     //! Get EGL native display factory (--deqp-egl-display-type)
221     const char *getEGLDisplayType(void) const;
222 
223     //! Get EGL native window factory (--deqp-egl-window-type)
224     const char *getEGLWindowType(void) const;
225 
226     //! Get EGL native pixmap factory (--deqp-egl-pixmap-type)
227     const char *getEGLPixmapType(void) const;
228 
229     //! Get Vulkan device ID (--deqp-vk-device-id)
230     int getVKDeviceId(void) const;
231 
232     //! Get Vulkan device group ID (--deqp-vk-device-group-id)
233     int getVKDeviceGroupId(void) const;
234 
235     //! Enable development-time test case validation checks
236     bool isValidationEnabled(void) const;
237 
238     //! Enable SPIRV validation checks (--deqp-spirv-validation)
239     bool isSpirvValidationEnabled(void) const;
240 
241     //! Print validation errors to standard error or keep them in the log only.
242     bool printValidationErrors(void) const;
243 
244     //! Enable runtime check for duplicate case names in test hierarchy
245     bool checkDuplicateCaseNames(void) const;
246 
247     //! Log of decompiled SPIR-V shader source (--deqp-log-decompiled-spirv)
248     bool isLogDecompiledSpirvEnabled(void) const;
249 
250     //! Should we run tests that exhaust memory (--deqp-test-oom)
251     bool isOutOfMemoryTestEnabled(void) const;
252 
253     //! Should the shader cache be enabled (--deqp-shadercache)
254     bool isShadercacheEnabled(void) const;
255 
256     //! Get the filename for shader cache (--deqp-shadercache-filename)
257     const char *getShaderCacheFilename(void) const;
258 
259     //! Should the shader cache be truncated before run (--deqp-shadercache-truncate)
260     bool isShaderCacheTruncateEnabled(void) const;
261 
262     //! Should the shader cache use inter process communication (IPC) (--deqp-shadercache-ipc)
263     bool isShaderCacheIPCEnabled(void) const;
264 
265     //! Get shader optimization recipe (--deqp-optimization-recipe)
266     int getOptimizationRecipe(void) const;
267 
268     //! Enable optimizing of spir-v (--deqp-optimize-spirv)
269     bool isSpirvOptimizationEnabled(void) const;
270 
271     //! Enable RenderDoc frame markers (--deqp-renderdoc)
272     bool isRenderDocEnabled(void) const;
273 
274     //! Get waiver file name (--deqp-waiver-file)
275     const char *getWaiverFileName(void) const;
276 
277     //! Get case list fraction
278     const std::vector<int> &getCaseFraction(void) const;
279 
280     //! Get must-list filename
281     const char *getCaseFractionMandatoryTests(void) const;
282 
283     //! Get archive directory path
284     const char *getArchiveDir(void) const;
285 
286     //! Get runner type (--deqp-runner-type)
287     tcu::TestRunnerType getRunnerType(void) const;
288 
289     //! Should the run be terminated on first failure (--deqp-terminate-on-fail)
290     bool isTerminateOnFailEnabled(void) const;
291 
292     //! Should the run be terminated on first device lost (--deqp-terminate-on-device-lost)
293     bool isTerminateOnDeviceLostEnabled(void) const;
294 
295     //! Start as subprocess ( Vulkan SC )
296     bool isSubProcess(void) const;
297 
298     //! Define default number of tests performed in main process ( Vulkan SC )
299     int getSubprocessTestCount(void) const;
300 
301     //! Config file defining number of tests performed in subprocess for specific test branches
302     const char *getSubprocessConfigFile(void) const;
303 
304     //! Optional server address that will be responsible for (among other things) compiling shaders ( Vulkan SC )
305     const char *getServerAddress(void) const;
306 
307     //! Define minimum size of a single command pool ( Vulkan SC )
308     int getCommandPoolMinSize(void) const;
309 
310     //! Define minimum size of a single command buffer ( Vulkan SC )
311     int getCommandBufferMinSize(void) const;
312 
313     //! Define default size for single command in command buffer ( Vulkan SC )
314     int getCommandDefaultSize(void) const;
315 
316     //! Define default size for single pipeline ( Vulkan SC )
317     int getPipelineDefaultSize(void) const;
318 
319     //! Path to offline pipeline compiler executable
320     const char *getPipelineCompilerPath(void) const;
321 
322     //! Directory containing input and output pipeline compiler files
323     const char *getPipelineCompilerDataDir(void) const;
324 
325     //! Additional args for offline pipeline compiler
326     const char *getPipelineCompilerArgs(void) const;
327 
328     //! Output pipeline cache file produced by offline pipeline compiler
329     const char *getPipelineCompilerOutputFile(void) const;
330 
331     //! Log file for offline pipeline compiler
332     const char *getPipelineCompilerLogFile(void) const;
333 
334     //! Prefix for offline pipeline compiler input files
335     const char *getPipelineCompilerFilePrefix(void) const;
336 
337     //! Path to Vulkan library (e.g. loader library vulkan-1.dll)
338     const char *getVkLibraryPath(void) const;
339 
340     //! File that provides a default set of application parameters
341     const char *getAppParamsInputFilePath(void) const;
342 
343     //! Perform tests for devices implementing compute-only functionality
344     bool isComputeOnly(void) const;
345 
346     /*--------------------------------------------------------------------*//*!
347      * \brief Creates case list filter
348      * \param archive Resources
349      *
350      * Creates case list filter based on one of the following parameters:
351      *
352      * --deqp-case
353      * --deqp-caselist
354      * --deqp-caselist-file
355      * --deqp-caselist-resource
356      * --deqp-stdin-caselist
357      *
358      * Throws std::invalid_argument if parsing fails.
359      *//*--------------------------------------------------------------------*/
360     de::MovePtr<CaseListFilter> createCaseListFilter(const tcu::Archive &archive) const;
361 
362 protected:
363     const de::cmdline::CommandLine &getCommandLine(void) const;
364 
365 private:
366     CommandLine(const CommandLine &);            // not allowed!
367     CommandLine &operator=(const CommandLine &); // not allowed!
368 
369     void clear(void);
370 
371     virtual void registerExtendedOptions(de::cmdline::Parser &parser);
372 
373     std::string m_appName;
374     de::cmdline::CommandLine m_cmdLine;
375     uint32_t m_logFlags;
376 
377     std::string m_initialCmdLine;
378     bool m_hadHelpSpecified;
379 };
380 
381 } // namespace tcu
382 
383 #endif // _TCUCOMMANDLINE_HPP
384