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, 98 std::string::const_iterator patternEnd, 99 std::string::const_iterator pathStart, 100 std::string::const_iterator pathEnd, 101 bool allowPrefix); 102 103 class CaseListFilter 104 { 105 public: 106 CaseListFilter (const de::cmdline::CommandLine& cmdLine, const tcu::Archive& archive); 107 CaseListFilter (void); 108 ~CaseListFilter (void); 109 110 //! Check if test group is in supplied test case list. 111 bool checkTestGroupName (const char* groupName) const; 112 113 //! Check if test case is in supplied test case list. 114 bool checkTestCaseName (const char* caseName) const; 115 116 //! Check if test group passes the case fraction filter. 117 bool checkCaseFraction (int i, const std::string& testCaseName) const; 118 119 //! Check if test case runner is of supplied type checkRunnerType(tcu::TestRunnerType type) const120 bool checkRunnerType (tcu::TestRunnerType type) const { return ((m_runnerType & type) == m_runnerType); } 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 ~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 //! Get log file name (--deqp-log-filename) 154 const char* getLogFileName (void) const; 155 156 //! Get logging flags 157 deUint32 getLogFlags (void) const; 158 159 //! Get run mode (--deqp-runmode) 160 RunMode getRunMode (void) const; 161 162 //! Get caselist dump target file pattern (--deqp-caselist-export-file) 163 const char* getCaseListExportFile (void) const; 164 165 //! Get default window visibility (--deqp-visibility) 166 WindowVisibility getVisibility (void) const; 167 168 //! Get watchdog enable status (--deqp-watchdog) 169 bool isWatchDogEnabled (void) const; 170 171 //! Get crash handling enable status (--deqp-crashhandler) 172 bool isCrashHandlingEnabled (void) const; 173 174 //! Get base seed for randomization (--deqp-base-seed) 175 int getBaseSeed (void) const; 176 177 //! Get test iteration count (--deqp-test-iteration-count) 178 int getTestIterationCount (void) const; 179 180 //! Get rendering target width (--deqp-surface-width) 181 int getSurfaceWidth (void) const; 182 183 //! Get rendering target height (--deqp-surface-height) 184 int getSurfaceHeight (void) const; 185 186 //! Get rendering taget type (--deqp-surface-type) 187 SurfaceType getSurfaceType (void) const; 188 189 //! Get screen rotation (--deqp-screen-rotation) 190 ScreenRotation getScreenRotation (void) const; 191 192 //! Get GL context factory name (--deqp-gl-context-type) 193 const char* getGLContextType (void) const; 194 195 //! Get GL config ID (--deqp-gl-config-id) 196 int getGLConfigId (void) const; 197 198 //! Get GL config name (--deqp-gl-config-name) 199 const char* getGLConfigName (void) const; 200 201 //! Get GL context flags (--deqp-gl-context-flags) 202 const char* getGLContextFlags (void) const; 203 204 //! Get OpenCL platform ID (--deqp-cl-platform-id) 205 int getCLPlatformId (void) const; 206 207 //! Get OpenCL device IDs (--deqp-cl-device-ids) getCLDeviceIds(std::vector<int> & deviceIds) const208 void getCLDeviceIds (std::vector<int>& deviceIds) const { deviceIds = getCLDeviceIds(); } 209 const std::vector<int>& getCLDeviceIds (void) const; 210 211 //! Get extra OpenCL program build options (--deqp-cl-build-options) 212 const char* getCLBuildOptions (void) const; 213 214 //! Get EGL native display factory (--deqp-egl-display-type) 215 const char* getEGLDisplayType (void) const; 216 217 //! Get EGL native window factory (--deqp-egl-window-type) 218 const char* getEGLWindowType (void) const; 219 220 //! Get EGL native pixmap factory (--deqp-egl-pixmap-type) 221 const char* getEGLPixmapType (void) const; 222 223 //! Get Vulkan device ID (--deqp-vk-device-id) 224 int getVKDeviceId (void) const; 225 226 //! Get Vulkan device group ID (--deqp-vk-device-group-id) 227 int getVKDeviceGroupId (void) const; 228 229 //! Enable development-time test case validation checks 230 bool isValidationEnabled (void) const; 231 232 //! Print validation errors to standard error or keep them in the log only. 233 bool printValidationErrors (void) const; 234 235 //! Log of decompiled SPIR-V shader source (--deqp-log-decompiled-spirv) 236 bool isLogDecompiledSpirvEnabled (void) const; 237 238 //! Should we run tests that exhaust memory (--deqp-test-oom) 239 bool isOutOfMemoryTestEnabled (void) const; 240 241 //! Should the shader cache be enabled (--deqp-shadercache) 242 bool isShadercacheEnabled (void) const; 243 244 //! Get the filename for shader cache (--deqp-shadercache-filename) 245 const char* getShaderCacheFilename (void) const; 246 247 //! Should the shader cache be truncated before run (--deqp-shadercache-truncate) 248 bool isShaderCacheTruncateEnabled (void) const; 249 250 //! Should the shader cache use inter process communication (IPC) (--deqp-shadercache-ipc) 251 bool isShaderCacheIPCEnabled (void) const; 252 253 //! Get shader optimization recipe (--deqp-optimization-recipe) 254 int getOptimizationRecipe (void) const; 255 256 //! Enable optimizing of spir-v (--deqp-optimize-spirv) 257 bool isSpirvOptimizationEnabled (void) const; 258 259 //! Enable RenderDoc frame markers (--deqp-renderdoc) 260 bool isRenderDocEnabled (void) const; 261 262 //! Get waiver file name (--deqp-waiver-file) 263 const char* getWaiverFileName (void) const; 264 265 //! Get case list fraction 266 const std::vector<int>& getCaseFraction (void) const; 267 268 //! Get must-list filename 269 const char* getCaseFractionMandatoryTests(void) const; 270 271 //! Get archive directory path 272 const char* getArchiveDir (void) const; 273 274 //! Get runner type (--deqp-runner-type) 275 tcu::TestRunnerType getRunnerType (void) const; 276 277 //! Should the run be terminated on first failure (--deqp-terminate-on-fail) 278 bool isTerminateOnFailEnabled (void) const; 279 280 //! Start as subprocess ( Vulkan SC ) 281 bool isSubProcess (void) const; 282 283 //! Define default number of tests performed in main process ( Vulkan SC ) 284 int getSubprocessTestCount (void) const; 285 286 //! Config file defining number of tests performed in subprocess for specific test branches 287 const char* getSubprocessConfigFile (void) const; 288 289 //! Optional server address that will be responsible for (among other things) compiling shaders ( Vulkan SC ) 290 const char* getServerAddress (void) const; 291 292 //! Define minimum size of a single command pool ( Vulkan SC ) 293 int getCommandPoolMinSize(void) const; 294 295 //! Define minimum size of a single command buffer ( Vulkan SC ) 296 int getCommandBufferMinSize(void) const; 297 298 //! Define default size for single command in command buffer ( Vulkan SC ) 299 int getCommandDefaultSize(void) const; 300 301 //! Define default size for single pipeline ( Vulkan SC ) 302 int getPipelineDefaultSize(void) const; 303 304 //! Path to offline pipeline compiler executable 305 const char* getPipelineCompilerPath (void) const; 306 307 //! Directory containing input and output pipeline compiler files 308 const char* getPipelineCompilerDataDir (void) const; 309 310 //! Additional args for offline pipeline compiler 311 const char* getPipelineCompilerArgs (void) const; 312 313 //! Output pipeline cache file produced by offline pipeline compiler 314 const char* getPipelineCompilerOutputFile(void) const; 315 316 //! Log file for offline pipeline compiler 317 const char* getPipelineCompilerLogFile (void) const; 318 319 //! Prefix for offline pipeline compiler input files 320 const char* getPipelineCompilerFilePrefix(void) const; 321 322 //! Path to Vulkan library (e.g. loader library vulkan-1.dll) 323 const char* getVkLibraryPath (void) const; 324 325 //! File that provides a default set of application parameters 326 const char* getAppParamsInputFilePath(void) const; 327 328 /*--------------------------------------------------------------------*//*! 329 * \brief Creates case list filter 330 * \param archive Resources 331 * 332 * Creates case list filter based on one of the following parameters: 333 * 334 * --deqp-case 335 * --deqp-caselist 336 * --deqp-caselist-file 337 * --deqp-caselist-resource 338 * --deqp-stdin-caselist 339 * 340 * Throws std::invalid_argument if parsing fails. 341 *//*--------------------------------------------------------------------*/ 342 de::MovePtr<CaseListFilter> createCaseListFilter (const tcu::Archive& archive) const; 343 344 protected: 345 const de::cmdline::CommandLine& getCommandLine (void) const; 346 347 private: 348 CommandLine (const CommandLine&); // not allowed! 349 CommandLine& operator= (const CommandLine&); // not allowed! 350 351 void clear (void); 352 353 virtual void registerExtendedOptions (de::cmdline::Parser& parser); 354 355 std::string m_appName; 356 de::cmdline::CommandLine m_cmdLine; 357 deUint32 m_logFlags; 358 359 std::string m_initialCmdLine; 360 }; 361 362 } // tcu 363 364 #endif // _TCUCOMMANDLINE_HPP 365