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