Touch watchdog before freeing objs in max_concurrent am: 815781b777 am: 6cbc014cfb
[platform/upstream/VK-GL-CTS.git] / framework / common / tcuCommandLine.hpp
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 private:
108         CaseListFilter                                                                                          (const CaseListFilter&);        // not allowed!
109         CaseListFilter&                                 operator=                                       (const CaseListFilter&);        // not allowed!
110
111         CaseTreeNode*                                   m_caseTree;
112         de::MovePtr<const CasePaths>    m_casePaths;
113 };
114
115 /*--------------------------------------------------------------------*//*!
116  * \brief Test command line
117  *
118  * CommandLine handles argument parsing and provides convinience functions
119  * for querying test parameters.
120  *//*--------------------------------------------------------------------*/
121 class CommandLine
122 {
123 public:
124                                                                         CommandLine                                     (void);
125                                                                         CommandLine                                     (int argc, const char* const* argv);
126         explicit                                                CommandLine                                     (const std::string& cmdLine);
127                                                                         ~CommandLine                            (void);
128
129         bool                                                    parse                                           (int argc, const char* const* argv);
130         bool                                                    parse                                           (const std::string& cmdLine);
131
132         //! Get log file name (--deqp-log-filename)
133         const char*                                             getLogFileName                          (void) const;
134
135         //! Get logging flags
136         deUint32                                                getLogFlags                                     (void) const;
137
138         //! Get run mode (--deqp-runmode)
139         RunMode                                                 getRunMode                                      (void) const;
140
141         //! Get caselist dump target file pattern (--deqp-caselist-export-file)
142         const char*                                             getCaseListExportFile           (void) const;
143
144         //! Get default window visibility (--deqp-visibility)
145         WindowVisibility                                getVisibility                           (void) const;
146
147         //! Get watchdog enable status (--deqp-watchdog)
148         bool                                                    isWatchDogEnabled                       (void) const;
149
150         //! Get crash handling enable status (--deqp-crashhandler)
151         bool                                                    isCrashHandlingEnabled          (void) const;
152
153         //! Get base seed for randomization (--deqp-base-seed)
154         int                                                             getBaseSeed                                     (void) const;
155
156         //! Get test iteration count (--deqp-test-iteration-count)
157         int                                                             getTestIterationCount           (void) const;
158
159         //! Get rendering target width (--deqp-surface-width)
160         int                                                             getSurfaceWidth                         (void) const;
161
162         //! Get rendering target height (--deqp-surface-height)
163         int                                                             getSurfaceHeight                        (void) const;
164
165         //! Get rendering taget type (--deqp-surface-type)
166         SurfaceType                                             getSurfaceType                          (void) const;
167
168         //! Get screen rotation (--deqp-screen-rotation)
169         ScreenRotation                                  getScreenRotation                       (void) const;
170
171         //! Get GL context factory name (--deqp-gl-context-type)
172         const char*                                             getGLContextType                        (void) const;
173
174         //! Get GL config ID (--deqp-gl-config-id)
175         int                                                             getGLConfigId                           (void) const;
176
177         //! Get GL config name (--deqp-gl-config-name)
178         const char*                                             getGLConfigName                         (void) const;
179
180         //! Get GL context flags (--deqp-gl-context-flags)
181         const char*                                             getGLContextFlags                       (void) const;
182
183         //! Get OpenCL platform ID (--deqp-cl-platform-id)
184         int                                                             getCLPlatformId                         (void) const;
185
186         //! Get OpenCL device IDs (--deqp-cl-device-ids)
187         void                                                    getCLDeviceIds                          (std::vector<int>& deviceIds) const     { deviceIds = getCLDeviceIds(); }
188         const std::vector<int>&                 getCLDeviceIds                          (void) const;
189
190         //! Get extra OpenCL program build options (--deqp-cl-build-options)
191         const char*                                             getCLBuildOptions                       (void) const;
192
193         //! Get EGL native display factory (--deqp-egl-display-type)
194         const char*                                             getEGLDisplayType                       (void) const;
195
196         //! Get EGL native window factory (--deqp-egl-window-type)
197         const char*                                             getEGLWindowType                        (void) const;
198
199         //! Get EGL native pixmap factory (--deqp-egl-pixmap-type)
200         const char*                                             getEGLPixmapType                        (void) const;
201
202         //! Get Vulkan device ID (--deqp-vk-device-id)
203         int                                                             getVKDeviceId                           (void) const;
204
205         //! Enable development-time test case validation checks
206         bool                                                    isValidationEnabled                     (void) const;
207
208         //! Should we run tests that exhaust memory (--deqp-test-oom)
209         bool                                                    isOutOfMemoryTestEnabled        (void) const;
210
211         /*--------------------------------------------------------------------*//*!
212          * \brief Creates case list filter
213          * \param archive Resources
214          *
215          * Creates case list filter based on one of the following parameters:
216          *
217          * --deqp-case
218          * --deqp-caselist
219          * --deqp-caselist-file
220          * --deqp-caselist-resource
221          * --deqp-stdin-caselist
222          *
223          * Throws std::invalid_argument if parsing fails.
224          *//*--------------------------------------------------------------------*/
225         de::MovePtr<CaseListFilter>             createCaseListFilter            (const tcu::Archive& archive) const;
226
227 protected:
228         const de::cmdline::CommandLine& getCommandLine                          (void) const;
229
230 private:
231                                                                         CommandLine                                     (const CommandLine&);   // not allowed!
232         CommandLine&                                    operator=                                       (const CommandLine&);   // not allowed!
233
234         void                                                    clear                                           (void);
235
236         virtual void                                    registerExtendedOptions         (de::cmdline::Parser& parser);
237
238         de::cmdline::CommandLine                m_cmdLine;
239         deUint32                                                m_logFlags;
240 };
241
242 } // tcu
243
244 #endif // _TCUCOMMANDLINE_HPP