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 //! Print validation errors to standard error or keep them in the log only. 239 bool printValidationErrors(void) const; 240 241 //! Log of decompiled SPIR-V shader source (--deqp-log-decompiled-spirv) 242 bool isLogDecompiledSpirvEnabled(void) const; 243 244 //! Should we run tests that exhaust memory (--deqp-test-oom) 245 bool isOutOfMemoryTestEnabled(void) const; 246 247 //! Should the shader cache be enabled (--deqp-shadercache) 248 bool isShadercacheEnabled(void) const; 249 250 //! Get the filename for shader cache (--deqp-shadercache-filename) 251 const char *getShaderCacheFilename(void) const; 252 253 //! Should the shader cache be truncated before run (--deqp-shadercache-truncate) 254 bool isShaderCacheTruncateEnabled(void) const; 255 256 //! Should the shader cache use inter process communication (IPC) (--deqp-shadercache-ipc) 257 bool isShaderCacheIPCEnabled(void) const; 258 259 //! Get shader optimization recipe (--deqp-optimization-recipe) 260 int getOptimizationRecipe(void) const; 261 262 //! Enable optimizing of spir-v (--deqp-optimize-spirv) 263 bool isSpirvOptimizationEnabled(void) const; 264 265 //! Enable RenderDoc frame markers (--deqp-renderdoc) 266 bool isRenderDocEnabled(void) const; 267 268 //! Get waiver file name (--deqp-waiver-file) 269 const char *getWaiverFileName(void) const; 270 271 //! Get case list fraction 272 const std::vector<int> &getCaseFraction(void) const; 273 274 //! Get must-list filename 275 const char *getCaseFractionMandatoryTests(void) const; 276 277 //! Get archive directory path 278 const char *getArchiveDir(void) const; 279 280 //! Get runner type (--deqp-runner-type) 281 tcu::TestRunnerType getRunnerType(void) const; 282 283 //! Should the run be terminated on first failure (--deqp-terminate-on-fail) 284 bool isTerminateOnFailEnabled(void) const; 285 286 //! Should the run be terminated on first device lost (--deqp-terminate-on-device-lost) 287 bool isTerminateOnDeviceLostEnabled(void) const; 288 289 //! Start as subprocess ( Vulkan SC ) 290 bool isSubProcess(void) const; 291 292 //! Define default number of tests performed in main process ( Vulkan SC ) 293 int getSubprocessTestCount(void) const; 294 295 //! Config file defining number of tests performed in subprocess for specific test branches 296 const char *getSubprocessConfigFile(void) const; 297 298 //! Optional server address that will be responsible for (among other things) compiling shaders ( Vulkan SC ) 299 const char *getServerAddress(void) const; 300 301 //! Define minimum size of a single command pool ( Vulkan SC ) 302 int getCommandPoolMinSize(void) const; 303 304 //! Define minimum size of a single command buffer ( Vulkan SC ) 305 int getCommandBufferMinSize(void) const; 306 307 //! Define default size for single command in command buffer ( Vulkan SC ) 308 int getCommandDefaultSize(void) const; 309 310 //! Define default size for single pipeline ( Vulkan SC ) 311 int getPipelineDefaultSize(void) const; 312 313 //! Path to offline pipeline compiler executable 314 const char *getPipelineCompilerPath(void) const; 315 316 //! Directory containing input and output pipeline compiler files 317 const char *getPipelineCompilerDataDir(void) const; 318 319 //! Additional args for offline pipeline compiler 320 const char *getPipelineCompilerArgs(void) const; 321 322 //! Output pipeline cache file produced by offline pipeline compiler 323 const char *getPipelineCompilerOutputFile(void) const; 324 325 //! Log file for offline pipeline compiler 326 const char *getPipelineCompilerLogFile(void) const; 327 328 //! Prefix for offline pipeline compiler input files 329 const char *getPipelineCompilerFilePrefix(void) const; 330 331 //! Path to Vulkan library (e.g. loader library vulkan-1.dll) 332 const char *getVkLibraryPath(void) const; 333 334 //! File that provides a default set of application parameters 335 const char *getAppParamsInputFilePath(void) const; 336 337 //! Perform tests for devices implementing compute-only functionality 338 bool isComputeOnly(void) const; 339 340 /*--------------------------------------------------------------------*//*! 341 * \brief Creates case list filter 342 * \param archive Resources 343 * 344 * Creates case list filter based on one of the following parameters: 345 * 346 * --deqp-case 347 * --deqp-caselist 348 * --deqp-caselist-file 349 * --deqp-caselist-resource 350 * --deqp-stdin-caselist 351 * 352 * Throws std::invalid_argument if parsing fails. 353 *//*--------------------------------------------------------------------*/ 354 de::MovePtr<CaseListFilter> createCaseListFilter(const tcu::Archive &archive) const; 355 356 protected: 357 const de::cmdline::CommandLine &getCommandLine(void) const; 358 359 private: 360 CommandLine(const CommandLine &); // not allowed! 361 CommandLine &operator=(const CommandLine &); // not allowed! 362 363 void clear(void); 364 365 virtual void registerExtendedOptions(de::cmdline::Parser &parser); 366 367 std::string m_appName; 368 de::cmdline::CommandLine m_cmdLine; 369 uint32_t m_logFlags; 370 371 std::string m_initialCmdLine; 372 bool m_hadHelpSpecified; 373 }; 374 375 } // namespace tcu 376 377 #endif // _TCUCOMMANDLINE_HPP 378