ctest.1.rst 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679
  1. .. cmake-manual-description: CTest Command-Line Reference
  2. ctest(1)
  3. ********
  4. .. contents::
  5. Synopsis
  6. ========
  7. .. parsed-literal::
  8. ctest [<options>]
  9. ctest --build-and-test <path-to-source> <path-to-build>
  10. --build-generator <generator> [<options>...]
  11. [--build-options <opts>...] [--test-command <command> [<args>...]]
  12. ctest {-D <dashboard> | -M <model> -T <action> | -S <script> | -SP <script>}
  13. [-- <dashboard-options>...]
  14. Description
  15. ===========
  16. The **ctest** executable is the CMake test driver program.
  17. CMake-generated build trees created for projects that use the
  18. :command:`enable_testing` and :command:`add_test` commands have testing support.
  19. This program will run the tests and report results.
  20. .. _`CTest Options`:
  21. Options
  22. =======
  23. ``--preset <preset>``, ``--preset=<preset>``
  24. Use a test preset to specify test options. The project binary directory
  25. is inferred from the ``configurePreset`` key. The current working directory
  26. must contain CMake preset files.
  27. See :manual:`preset <cmake-presets(7)>` for more details.
  28. ``--list-presets``
  29. Lists the available test presets. The current working directory must contain
  30. CMake preset files.
  31. ``-C <cfg>, --build-config <cfg>``
  32. Choose configuration to test.
  33. Some CMake-generated build trees can have multiple build
  34. configurations in the same tree. This option can be used to specify
  35. which one should be tested. Example configurations are ``Debug`` and
  36. ``Release``.
  37. ``--progress``
  38. Enable short progress output from tests.
  39. When the output of **ctest** is being sent directly to a terminal, the
  40. progress through the set of tests is reported by updating the same line
  41. rather than printing start and end messages for each test on new lines.
  42. This can significantly reduce the verbosity of the test output.
  43. Test completion messages are still output on their own line for failed
  44. tests and the final test summary will also still be logged.
  45. This option can also be enabled by setting the environment variable
  46. :envvar:`CTEST_PROGRESS_OUTPUT`.
  47. ``-V,--verbose``
  48. Enable verbose output from tests.
  49. Test output is normally suppressed and only summary information is
  50. displayed. This option will show all test output.
  51. ``-VV,--extra-verbose``
  52. Enable more verbose output from tests.
  53. Test output is normally suppressed and only summary information is
  54. displayed. This option will show even more test output.
  55. ``--debug``
  56. Displaying more verbose internals of CTest.
  57. This feature will result in a large number of output that is mostly
  58. useful for debugging dashboard problems.
  59. ``--output-on-failure``
  60. Output anything outputted by the test program if the test should fail.
  61. This option can also be enabled by setting the
  62. :envvar:`CTEST_OUTPUT_ON_FAILURE` environment variable
  63. ``--stop-on-failure``
  64. Stop running the tests when the first failure happens.
  65. ``-F``
  66. Enable failover.
  67. This option allows CTest to resume a test set execution that was
  68. previously interrupted. If no interruption occurred, the ``-F`` option
  69. will have no effect.
  70. ``-j <jobs>, --parallel <jobs>``
  71. Run the tests in parallel using the given number of jobs.
  72. This option tells CTest to run the tests in parallel using given
  73. number of jobs. This option can also be set by setting the
  74. :envvar:`CTEST_PARALLEL_LEVEL` environment variable.
  75. This option can be used with the :prop_test:`PROCESSORS` test property.
  76. See `Label and Subproject Summary`_.
  77. ``--resource-spec-file <file>``
  78. Run CTest with :ref:`resource allocation <ctest-resource-allocation>` enabled,
  79. using the
  80. :ref:`resource specification file <ctest-resource-specification-file>`
  81. specified in ``<file>``.
  82. When ``ctest`` is run as a `Dashboard Client`_ this sets the
  83. ``ResourceSpecFile`` option of the `CTest Test Step`_.
  84. ``--test-load <level>``
  85. While running tests in parallel (e.g. with ``-j``), try not to start
  86. tests when they may cause the CPU load to pass above a given threshold.
  87. When ``ctest`` is run as a `Dashboard Client`_ this sets the
  88. ``TestLoad`` option of the `CTest Test Step`_.
  89. ``-Q,--quiet``
  90. Make CTest quiet.
  91. This option will suppress all the output. The output log file will
  92. still be generated if the ``--output-log`` is specified. Options such
  93. as ``--verbose``, ``--extra-verbose``, and ``--debug`` are ignored
  94. if ``--quiet`` is specified.
  95. ``-O <file>, --output-log <file>``
  96. Output to log file.
  97. This option tells CTest to write all its output to a ``<file>`` log file.
  98. ``--output-junit <file>``
  99. Write test results in JUnit format.
  100. This option tells CTest to write test results to a ``<file>`` JUnit XML file.
  101. If ``<file>`` already exists it will be overwritten.
  102. ``-N,--show-only[=<format>]``
  103. Disable actual execution of tests.
  104. This option tells CTest to list the tests that would be run but not
  105. actually run them. Useful in conjunction with the ``-R`` and ``-E``
  106. options.
  107. ``<format>`` can be one of the following values.
  108. ``human``
  109. Human-friendly output. This is not guaranteed to be stable.
  110. This is the default.
  111. ``json-v1``
  112. Dump the test information in JSON format.
  113. See `Show as JSON Object Model`_.
  114. ``-L <regex>, --label-regex <regex>``
  115. Run tests with labels matching regular expression as described under
  116. :ref:`string(REGEX) <Regex Specification>`.
  117. This option tells CTest to run only the tests whose labels match the
  118. given regular expression. When more than one ``-L`` option is given,
  119. a test will only be run if each regular expression matches at least one
  120. of the test's labels (i.e. the multiple ``-L`` labels form an ``AND``
  121. relationship). See `Label Matching`_.
  122. ``-R <regex>, --tests-regex <regex>``
  123. Run tests matching regular expression.
  124. This option tells CTest to run only the tests whose names match the
  125. given regular expression.
  126. ``-E <regex>, --exclude-regex <regex>``
  127. Exclude tests matching regular expression.
  128. This option tells CTest to NOT run the tests whose names match the
  129. given regular expression.
  130. ``-LE <regex>, --label-exclude <regex>``
  131. Exclude tests with labels matching regular expression.
  132. This option tells CTest to NOT run the tests whose labels match the
  133. given regular expression. When more than one ``-LE`` option is given,
  134. a test will only be excluded if each regular expression matches at least one
  135. of the test's labels (i.e. the multiple ``-LE`` labels form an ``AND``
  136. relationship). See `Label Matching`_.
  137. ``-FA <regex>, --fixture-exclude-any <regex>``
  138. Exclude fixtures matching ``<regex>`` from automatically adding any tests to
  139. the test set.
  140. If a test in the set of tests to be executed requires a particular fixture,
  141. that fixture's setup and cleanup tests would normally be added to the test set
  142. automatically. This option prevents adding setup or cleanup tests for fixtures
  143. matching the ``<regex>``. Note that all other fixture behavior is retained,
  144. including test dependencies and skipping tests that have fixture setup tests
  145. that fail.
  146. ``-FS <regex>, --fixture-exclude-setup <regex>``
  147. Same as ``-FA`` except only matching setup tests are excluded.
  148. ``-FC <regex>, --fixture-exclude-cleanup <regex>``
  149. Same as ``-FA`` except only matching cleanup tests are excluded.
  150. ``-D <dashboard>, --dashboard <dashboard>``
  151. Execute dashboard test.
  152. This option tells CTest to act as a CDash client and perform a
  153. dashboard test. All tests are ``<Mode><Test>``, where ``<Mode>`` can be
  154. ``Experimental``, ``Nightly``, and ``Continuous``, and ``<Test>`` can be
  155. ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
  156. ``Coverage``, and ``Submit``.
  157. See `Dashboard Client`_.
  158. ``-D <var>:<type>=<value>``
  159. Define a variable for script mode.
  160. Pass in variable values on the command line. Use in conjunction
  161. with ``-S`` to pass variable values to a dashboard script. Parsing ``-D``
  162. arguments as variable values is only attempted if the value
  163. following ``-D`` does not match any of the known dashboard types.
  164. ``-M <model>, --test-model <model>``
  165. Sets the model for a dashboard.
  166. This option tells CTest to act as a CDash client where the ``<model>``
  167. can be ``Experimental``, ``Nightly``, and ``Continuous``.
  168. Combining ``-M`` and ``-T`` is similar to ``-D``.
  169. See `Dashboard Client`_.
  170. ``-T <action>, --test-action <action>``
  171. Sets the dashboard action to perform.
  172. This option tells CTest to act as a CDash client and perform some
  173. action such as ``start``, ``build``, ``test`` etc. See
  174. `Dashboard Client Steps`_ for the full list of actions.
  175. Combining ``-M`` and ``-T`` is similar to ``-D``.
  176. See `Dashboard Client`_.
  177. ``-S <script>, --script <script>``
  178. Execute a dashboard for a configuration.
  179. This option tells CTest to load in a configuration script which sets
  180. a number of parameters such as the binary and source directories.
  181. Then CTest will do what is required to create and run a dashboard.
  182. This option basically sets up a dashboard and then runs ``ctest -D``
  183. with the appropriate options.
  184. See `Dashboard Client`_.
  185. ``-SP <script>, --script-new-process <script>``
  186. Execute a dashboard for a configuration.
  187. This option does the same operations as ``-S`` but it will do them in a
  188. separate process. This is primarily useful in cases where the
  189. script may modify the environment and you do not want the modified
  190. environment to impact other ``-S`` scripts.
  191. See `Dashboard Client`_.
  192. ``-I [Start,End,Stride,test#,test#|Test file], --tests-information``
  193. Run a specific number of tests by number.
  194. This option causes CTest to run tests starting at number ``Start``,
  195. ending at number ``End``, and incrementing by ``Stride``. Any additional
  196. numbers after ``Stride`` are considered individual test numbers. ``Start``,
  197. ``End``, or ``Stride`` can be empty. Optionally a file can be given that
  198. contains the same syntax as the command line.
  199. ``-U, --union``
  200. Take the Union of ``-I`` and ``-R``.
  201. When both ``-R`` and ``-I`` are specified by default the intersection of
  202. tests are run. By specifying ``-U`` the union of tests is run instead.
  203. ``--rerun-failed``
  204. Run only the tests that failed previously.
  205. This option tells CTest to perform only the tests that failed during
  206. its previous run. When this option is specified, CTest ignores all
  207. other options intended to modify the list of tests to run (``-L``, ``-R``,
  208. ``-E``, ``-LE``, ``-I``, etc). In the event that CTest runs and no tests
  209. fail, subsequent calls to CTest with the ``--rerun-failed`` option will run
  210. the set of tests that most recently failed (if any).
  211. ``--repeat <mode>:<n>``
  212. Run tests repeatedly based on the given ``<mode>`` up to ``<n>`` times.
  213. The modes are:
  214. ``until-fail``
  215. Require each test to run ``<n>`` times without failing in order to pass.
  216. This is useful in finding sporadic failures in test cases.
  217. ``until-pass``
  218. Allow each test to run up to ``<n>`` times in order to pass.
  219. Repeats tests if they fail for any reason.
  220. This is useful in tolerating sporadic failures in test cases.
  221. ``after-timeout``
  222. Allow each test to run up to ``<n>`` times in order to pass.
  223. Repeats tests only if they timeout.
  224. This is useful in tolerating sporadic timeouts in test cases
  225. on busy machines.
  226. ``--repeat-until-fail <n>``
  227. Equivalent to ``--repeat until-fail:<n>``.
  228. ``--max-width <width>``
  229. Set the max width for a test name to output.
  230. Set the maximum width for each test name to show in the output.
  231. This allows the user to widen the output to avoid clipping the test
  232. name which can be very annoying.
  233. ``--interactive-debug-mode [0|1]``
  234. Set the interactive mode to ``0`` or ``1``.
  235. This option causes CTest to run tests in either an interactive mode
  236. or a non-interactive mode. In dashboard mode (``Experimental``, ``Nightly``,
  237. ``Continuous``), the default is non-interactive. In non-interactive mode,
  238. the environment variable :envvar:`DASHBOARD_TEST_FROM_CTEST` is set.
  239. Prior to CMake 3.11, interactive mode on Windows allowed system debug
  240. popup windows to appear. Now, due to CTest's use of ``libuv`` to launch
  241. test processes, all system debug popup windows are always blocked.
  242. ``--no-label-summary``
  243. Disable timing summary information for labels.
  244. This option tells CTest not to print summary information for each
  245. label associated with the tests run. If there are no labels on the
  246. tests, nothing extra is printed.
  247. See `Label and Subproject Summary`_.
  248. ``--no-subproject-summary``
  249. Disable timing summary information for subprojects.
  250. This option tells CTest not to print summary information for each
  251. subproject associated with the tests run. If there are no subprojects on the
  252. tests, nothing extra is printed.
  253. See `Label and Subproject Summary`_.
  254. ``--build-and-test``
  255. See `Build and Test Mode`_.
  256. ``--test-dir <dir>``
  257. Specify the directory in which to look for tests.
  258. ``--test-output-size-passed <size>``
  259. Limit the output for passed tests to ``<size>`` bytes.
  260. ``--test-output-size-failed <size>``
  261. Limit the output for failed tests to ``<size>`` bytes.
  262. ``--overwrite``
  263. Overwrite CTest configuration option.
  264. By default CTest uses configuration options from configuration file.
  265. This option will overwrite the configuration option.
  266. ``--force-new-ctest-process``
  267. Run child CTest instances as new processes.
  268. By default CTest will run child CTest instances within the same
  269. process. If this behavior is not desired, this argument will
  270. enforce new processes for child CTest processes.
  271. ``--schedule-random``
  272. Use a random order for scheduling tests.
  273. This option will run the tests in a random order. It is commonly
  274. used to detect implicit dependencies in a test suite.
  275. ``--submit-index``
  276. Legacy option for old Dart2 dashboard server feature.
  277. Do not use.
  278. ``--timeout <seconds>``
  279. Set the default test timeout.
  280. This option effectively sets a timeout on all tests that do not
  281. already have a timeout set on them via the :prop_test:`TIMEOUT`
  282. property.
  283. ``--stop-time <time>``
  284. Set a time at which all tests should stop running.
  285. Set a real time of day at which all tests should timeout. Example:
  286. ``7:00:00 -0400``. Any time format understood by the curl date parser
  287. is accepted. Local time is assumed if no timezone is specified.
  288. ``--print-labels``
  289. Print all available test labels.
  290. This option will not run any tests, it will simply print the list of
  291. all labels associated with the test set.
  292. ``--no-tests=<[error|ignore]>``
  293. Regard no tests found either as error or ignore it.
  294. If no tests were found, the default behavior of CTest is to always log an
  295. error message but to return an error code in script mode only. This option
  296. unifies the behavior of CTest by either returning an error code if no tests
  297. were found or by ignoring it.
  298. .. include:: OPTIONS_HELP.txt
  299. .. _`Label Matching`:
  300. Label Matching
  301. ==============
  302. Tests may have labels attached to them. Tests may be included
  303. or excluded from a test run by filtering on the labels.
  304. Each individual filter is a regular expression applied to
  305. the labels attached to a test.
  306. When ``-L`` is used, in order for a test to be included in a
  307. test run, each regular expression must match at least one
  308. label. Using more than one ``-L`` option means "match **all**
  309. of these".
  310. The ``-LE`` option works just like ``-L``, but excludes tests
  311. rather than including them. A test is excluded if each regular
  312. expression matches at least one label.
  313. If a test has no labels attached to it, then ``-L`` will never
  314. include that test, and ``-LE`` will never exclude that test.
  315. As an example of tests with labels, consider five tests,
  316. with the following labels:
  317. * *test1* has labels *tuesday* and *production*
  318. * *test2* has labels *tuesday* and *test*
  319. * *test3* has labels *wednesday* and *production*
  320. * *test4* has label *wednesday*
  321. * *test5* has labels *friday* and *test*
  322. Running ``ctest`` with ``-L tuesday -L test`` will select *test2*, which has
  323. both labels. Running CTest with ``-L test`` will select *test2* and
  324. *test5*, because both of them have a label that matches that regular
  325. expression.
  326. Because the matching works with regular expressions, take note that
  327. running CTest with ``-L es`` will match all five tests.
  328. To select the *tuesday* and *wednesday* tests together, use a single
  329. regular expression that matches either of them, like ``-L "tue|wed"``.
  330. .. _`Label and Subproject Summary`:
  331. Label and Subproject Summary
  332. ============================
  333. CTest prints timing summary information for each ``LABEL`` and subproject
  334. associated with the tests run. The label time summary will not include labels
  335. that are mapped to subprojects.
  336. When the :prop_test:`PROCESSORS` test property is set, CTest will display a
  337. weighted test timing result in label and subproject summaries. The time is
  338. reported with `sec*proc` instead of just `sec`.
  339. The weighted time summary reported for each label or subproject ``j``
  340. is computed as::
  341. Weighted Time Summary for Label/Subproject j =
  342. sum(raw_test_time[j,i] * num_processors[j,i], i=1...num_tests[j])
  343. for labels/subprojects j=1...total
  344. where:
  345. * ``raw_test_time[j,i]``: Wall-clock time for the ``i`` test
  346. for the ``j`` label or subproject
  347. * ``num_processors[j,i]``: Value of the CTest :prop_test:`PROCESSORS` property
  348. for the ``i`` test for the ``j`` label or subproject
  349. * ``num_tests[j]``: Number of tests associated with the ``j`` label or subproject
  350. * ``total``: Total number of labels or subprojects that have at least one test run
  351. Therefore, the weighted time summary for each label or subproject represents
  352. the amount of time that CTest gave to run the tests for each label or
  353. subproject and gives a good representation of the total expense of the tests
  354. for each label or subproject when compared to other labels or subprojects.
  355. For example, if ``SubprojectA`` showed ``100 sec*proc`` and ``SubprojectB`` showed
  356. ``10 sec*proc``, then CTest allocated approximately 10 times the CPU/core time
  357. to run the tests for ``SubprojectA`` than for ``SubprojectB`` (e.g. so if effort
  358. is going to be expended to reduce the cost of the test suite for the whole
  359. project, then reducing the cost of the test suite for ``SubprojectA`` would
  360. likely have a larger impact than effort to reduce the cost of the test suite
  361. for ``SubprojectB``).
  362. .. _`Build and Test Mode`:
  363. Build and Test Mode
  364. ===================
  365. CTest provides a command-line signature to configure (i.e. run cmake on),
  366. build, and/or execute a test::
  367. ctest --build-and-test <path-to-source> <path-to-build>
  368. --build-generator <generator>
  369. [<options>...]
  370. [--build-options <opts>...]
  371. [--test-command <command> [<args>...]]
  372. The configure and test steps are optional. The arguments to this command line
  373. are the source and binary directories. The ``--build-generator`` option *must*
  374. be provided to use ``--build-and-test``. If ``--test-command`` is specified
  375. then that will be run after the build is complete. Other options that affect
  376. this mode include:
  377. ``--build-target``
  378. Specify a specific target to build.
  379. If left out the ``all`` target is built.
  380. ``--build-nocmake``
  381. Run the build without running cmake first.
  382. Skip the cmake step.
  383. ``--build-run-dir``
  384. Specify directory to run programs from.
  385. Directory where programs will be after it has been compiled.
  386. ``--build-two-config``
  387. Run CMake twice.
  388. ``--build-exe-dir``
  389. Specify the directory for the executable.
  390. ``--build-generator``
  391. Specify the generator to use. See the :manual:`cmake-generators(7)` manual.
  392. ``--build-generator-platform``
  393. Specify the generator-specific platform.
  394. ``--build-generator-toolset``
  395. Specify the generator-specific toolset.
  396. ``--build-project``
  397. Specify the name of the project to build.
  398. ``--build-makeprogram``
  399. Specify the explicit make program to be used by CMake when configuring and
  400. building the project. Only applicable for Make and Ninja based generators.
  401. ``--build-noclean``
  402. Skip the make clean step.
  403. ``--build-config-sample``
  404. A sample executable to use to determine the configuration that
  405. should be used. e.g. ``Debug``, ``Release`` etc.
  406. ``--build-options``
  407. Additional options for configuring the build (i.e. for CMake, not for
  408. the build tool). Note that if this is specified, the ``--build-options``
  409. keyword and its arguments must be the last option given on the command
  410. line, with the possible exception of ``--test-command``.
  411. ``--test-command``
  412. The command to run as the test step with the ``--build-and-test`` option.
  413. All arguments following this keyword will be assumed to be part of the
  414. test command line, so it must be the last option given.
  415. ``--test-timeout``
  416. The time limit in seconds
  417. .. _`Dashboard Client`:
  418. Dashboard Client
  419. ================
  420. CTest can operate as a client for the `CDash`_ software quality dashboard
  421. application. As a dashboard client, CTest performs a sequence of steps
  422. to configure, build, and test software, and then submits the results to
  423. a `CDash`_ server. The command-line signature used to submit to `CDash`_ is::
  424. ctest (-D <dashboard> | -M <model> -T <action> | -S <script> | -SP <script>)
  425. [-- <dashboard-options>...]
  426. Options for Dashboard Client include:
  427. ``--group <group>``
  428. Specify what group you'd like to submit results to
  429. Submit dashboard to specified group instead of default one. By
  430. default, the dashboard is submitted to Nightly, Experimental, or
  431. Continuous group, but by specifying this option, the group can be
  432. arbitrary.
  433. This replaces the deprecated option ``--track``.
  434. Despite the name change its behavior is unchanged.
  435. ``-A <file>, --add-notes <file>``
  436. Add a notes file with submission.
  437. This option tells CTest to include a notes file when submitting
  438. dashboard.
  439. ``--tomorrow-tag``
  440. ``Nightly`` or ``Experimental`` starts with next day tag.
  441. This is useful if the build will not finish in one day.
  442. ``--extra-submit <file>[;<file>]``
  443. Submit extra files to the dashboard.
  444. This option will submit extra files to the dashboard.
  445. ``--http1.0``
  446. Submit using `HTTP 1.0`.
  447. This option will force CTest to use `HTTP 1.0` to submit files to the
  448. dashboard, instead of `HTTP 1.1`.
  449. ``--no-compress-output``
  450. Do not compress test output when submitting.
  451. This flag will turn off automatic compression of test output. Use
  452. this to maintain compatibility with an older version of CDash which
  453. doesn't support compressed test output.
  454. Dashboard Client Steps
  455. ----------------------
  456. CTest defines an ordered list of testing steps of which some or all may
  457. be run as a dashboard client:
  458. ``Start``
  459. Start a new dashboard submission to be composed of results recorded
  460. by the following steps.
  461. See the `CTest Start Step`_ section below.
  462. ``Update``
  463. Update the source tree from its version control repository.
  464. Record the old and new versions and the list of updated source files.
  465. See the `CTest Update Step`_ section below.
  466. ``Configure``
  467. Configure the software by running a command in the build tree.
  468. Record the configuration output log.
  469. See the `CTest Configure Step`_ section below.
  470. ``Build``
  471. Build the software by running a command in the build tree.
  472. Record the build output log and detect warnings and errors.
  473. See the `CTest Build Step`_ section below.
  474. ``Test``
  475. Test the software by loading a ``CTestTestfile.cmake``
  476. from the build tree and executing the defined tests.
  477. Record the output and result of each test.
  478. See the `CTest Test Step`_ section below.
  479. ``Coverage``
  480. Compute coverage of the source code by running a coverage
  481. analysis tool and recording its output.
  482. See the `CTest Coverage Step`_ section below.
  483. ``MemCheck``
  484. Run the software test suite through a memory check tool.
  485. Record the test output, results, and issues reported by the tool.
  486. See the `CTest MemCheck Step`_ section below.
  487. ``Submit``
  488. Submit results recorded from other testing steps to the
  489. software quality dashboard server.
  490. See the `CTest Submit Step`_ section below.
  491. Dashboard Client Modes
  492. ----------------------
  493. CTest defines three modes of operation as a dashboard client:
  494. ``Nightly``
  495. This mode is intended to be invoked once per day, typically at night.
  496. It enables the ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
  497. ``Coverage``, and ``Submit`` steps by default. Selected steps run even
  498. if the ``Update`` step reports no changes to the source tree.
  499. ``Continuous``
  500. This mode is intended to be invoked repeatedly throughout the day.
  501. It enables the ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
  502. ``Coverage``, and ``Submit`` steps by default, but exits after the
  503. ``Update`` step if it reports no changes to the source tree.
  504. ``Experimental``
  505. This mode is intended to be invoked by a developer to test local changes.
  506. It enables the ``Start``, ``Configure``, ``Build``, ``Test``, ``Coverage``,
  507. and ``Submit`` steps by default.
  508. Dashboard Client via CTest Command-Line
  509. ---------------------------------------
  510. CTest can perform testing on an already-generated build tree.
  511. Run the ``ctest`` command with the current working directory set
  512. to the build tree and use one of these signatures::
  513. ctest -D <mode>[<step>]
  514. ctest -M <mode> [ -T <step> ]...
  515. The ``<mode>`` must be one of the above `Dashboard Client Modes`_,
  516. and each ``<step>`` must be one of the above `Dashboard Client Steps`_.
  517. CTest reads the `Dashboard Client Configuration`_ settings from
  518. a file in the build tree called either ``CTestConfiguration.ini``
  519. or ``DartConfiguration.tcl`` (the names are historical). The format
  520. of the file is::
  521. # Lines starting in '#' are comments.
  522. # Other non-blank lines are key-value pairs.
  523. <setting>: <value>
  524. where ``<setting>`` is the setting name and ``<value>`` is the
  525. setting value.
  526. In build trees generated by CMake, this configuration file is
  527. generated by the :module:`CTest` module if included by the project.
  528. The module uses variables to obtain a value for each setting
  529. as documented with the settings below.
  530. .. _`CTest Script`:
  531. Dashboard Client via CTest Script
  532. ---------------------------------
  533. CTest can perform testing driven by a :manual:`cmake-language(7)`
  534. script that creates and maintains the source and build tree as
  535. well as performing the testing steps. Run the ``ctest`` command
  536. with the current working directory set outside of any build tree
  537. and use one of these signatures::
  538. ctest -S <script>
  539. ctest -SP <script>
  540. The ``<script>`` file must call :ref:`CTest Commands` commands
  541. to run testing steps explicitly as documented below. The commands
  542. obtain `Dashboard Client Configuration`_ settings from their
  543. arguments or from variables set in the script.
  544. Dashboard Client Configuration
  545. ==============================
  546. The `Dashboard Client Steps`_ may be configured by named
  547. settings as documented in the following sections.
  548. .. _`CTest Start Step`:
  549. CTest Start Step
  550. ----------------
  551. Start a new dashboard submission to be composed of results recorded
  552. by the following steps.
  553. In a `CTest Script`_, the :command:`ctest_start` command runs this step.
  554. Arguments to the command may specify some of the step settings.
  555. The command first runs the command-line specified by the
  556. ``CTEST_CHECKOUT_COMMAND`` variable, if set, to initialize the source
  557. directory.
  558. Configuration settings include:
  559. ``BuildDirectory``
  560. The full path to the project build tree.
  561. * `CTest Script`_ variable: :variable:`CTEST_BINARY_DIRECTORY`
  562. * :module:`CTest` module variable: :variable:`PROJECT_BINARY_DIR`
  563. ``SourceDirectory``
  564. The full path to the project source tree.
  565. * `CTest Script`_ variable: :variable:`CTEST_SOURCE_DIRECTORY`
  566. * :module:`CTest` module variable: :variable:`PROJECT_SOURCE_DIR`
  567. .. _`CTest Update Step`:
  568. CTest Update Step
  569. -----------------
  570. In a `CTest Script`_, the :command:`ctest_update` command runs this step.
  571. Arguments to the command may specify some of the step settings.
  572. Configuration settings to specify the version control tool include:
  573. ``BZRCommand``
  574. ``bzr`` command-line tool to use if source tree is managed by Bazaar.
  575. * `CTest Script`_ variable: :variable:`CTEST_BZR_COMMAND`
  576. * :module:`CTest` module variable: none
  577. ``BZRUpdateOptions``
  578. Command-line options to the ``BZRCommand`` when updating the source.
  579. * `CTest Script`_ variable: :variable:`CTEST_BZR_UPDATE_OPTIONS`
  580. * :module:`CTest` module variable: none
  581. ``CVSCommand``
  582. ``cvs`` command-line tool to use if source tree is managed by CVS.
  583. * `CTest Script`_ variable: :variable:`CTEST_CVS_COMMAND`
  584. * :module:`CTest` module variable: ``CVSCOMMAND``
  585. ``CVSUpdateOptions``
  586. Command-line options to the ``CVSCommand`` when updating the source.
  587. * `CTest Script`_ variable: :variable:`CTEST_CVS_UPDATE_OPTIONS`
  588. * :module:`CTest` module variable: ``CVS_UPDATE_OPTIONS``
  589. ``GITCommand``
  590. ``git`` command-line tool to use if source tree is managed by Git.
  591. * `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND`
  592. * :module:`CTest` module variable: ``GITCOMMAND``
  593. The source tree is updated by ``git fetch`` followed by
  594. ``git reset --hard`` to the ``FETCH_HEAD``. The result is the same
  595. as ``git pull`` except that any local modifications are overwritten.
  596. Use ``GITUpdateCustom`` to specify a different approach.
  597. ``GITInitSubmodules``
  598. If set, CTest will update the repository's submodules before updating.
  599. * `CTest Script`_ variable: :variable:`CTEST_GIT_INIT_SUBMODULES`
  600. * :module:`CTest` module variable: ``CTEST_GIT_INIT_SUBMODULES``
  601. ``GITUpdateCustom``
  602. Specify a custom command line (as a semicolon-separated list) to run
  603. in the source tree (Git work tree) to update it instead of running
  604. the ``GITCommand``.
  605. * `CTest Script`_ variable: :variable:`CTEST_GIT_UPDATE_CUSTOM`
  606. * :module:`CTest` module variable: ``CTEST_GIT_UPDATE_CUSTOM``
  607. ``GITUpdateOptions``
  608. Command-line options to the ``GITCommand`` when updating the source.
  609. * `CTest Script`_ variable: :variable:`CTEST_GIT_UPDATE_OPTIONS`
  610. * :module:`CTest` module variable: ``GIT_UPDATE_OPTIONS``
  611. ``HGCommand``
  612. ``hg`` command-line tool to use if source tree is managed by Mercurial.
  613. * `CTest Script`_ variable: :variable:`CTEST_HG_COMMAND`
  614. * :module:`CTest` module variable: none
  615. ``HGUpdateOptions``
  616. Command-line options to the ``HGCommand`` when updating the source.
  617. * `CTest Script`_ variable: :variable:`CTEST_HG_UPDATE_OPTIONS`
  618. * :module:`CTest` module variable: none
  619. ``P4Client``
  620. Value of the ``-c`` option to the ``P4Command``.
  621. * `CTest Script`_ variable: :variable:`CTEST_P4_CLIENT`
  622. * :module:`CTest` module variable: ``CTEST_P4_CLIENT``
  623. ``P4Command``
  624. ``p4`` command-line tool to use if source tree is managed by Perforce.
  625. * `CTest Script`_ variable: :variable:`CTEST_P4_COMMAND`
  626. * :module:`CTest` module variable: ``P4COMMAND``
  627. ``P4Options``
  628. Command-line options to the ``P4Command`` for all invocations.
  629. * `CTest Script`_ variable: :variable:`CTEST_P4_OPTIONS`
  630. * :module:`CTest` module variable: ``CTEST_P4_OPTIONS``
  631. ``P4UpdateCustom``
  632. Specify a custom command line (as a semicolon-separated list) to run
  633. in the source tree (Perforce tree) to update it instead of running
  634. the ``P4Command``.
  635. * `CTest Script`_ variable: none
  636. * :module:`CTest` module variable: ``CTEST_P4_UPDATE_CUSTOM``
  637. ``P4UpdateOptions``
  638. Command-line options to the ``P4Command`` when updating the source.
  639. * `CTest Script`_ variable: :variable:`CTEST_P4_UPDATE_OPTIONS`
  640. * :module:`CTest` module variable: ``CTEST_P4_UPDATE_OPTIONS``
  641. ``SVNCommand``
  642. ``svn`` command-line tool to use if source tree is managed by Subversion.
  643. * `CTest Script`_ variable: :variable:`CTEST_SVN_COMMAND`
  644. * :module:`CTest` module variable: ``SVNCOMMAND``
  645. ``SVNOptions``
  646. Command-line options to the ``SVNCommand`` for all invocations.
  647. * `CTest Script`_ variable: :variable:`CTEST_SVN_OPTIONS`
  648. * :module:`CTest` module variable: ``CTEST_SVN_OPTIONS``
  649. ``SVNUpdateOptions``
  650. Command-line options to the ``SVNCommand`` when updating the source.
  651. * `CTest Script`_ variable: :variable:`CTEST_SVN_UPDATE_OPTIONS`
  652. * :module:`CTest` module variable: ``SVN_UPDATE_OPTIONS``
  653. ``UpdateCommand``
  654. Specify the version-control command-line tool to use without
  655. detecting the VCS that manages the source tree.
  656. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_COMMAND`
  657. * :module:`CTest` module variable: ``<VCS>COMMAND``
  658. when ``UPDATE_TYPE`` is ``<vcs>``, else ``UPDATE_COMMAND``
  659. ``UpdateOptions``
  660. Command-line options to the ``UpdateCommand``.
  661. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_OPTIONS`
  662. * :module:`CTest` module variable: ``<VCS>_UPDATE_OPTIONS``
  663. when ``UPDATE_TYPE`` is ``<vcs>``, else ``UPDATE_OPTIONS``
  664. ``UpdateType``
  665. Specify the version-control system that manages the source
  666. tree if it cannot be detected automatically.
  667. The value may be ``bzr``, ``cvs``, ``git``, ``hg``,
  668. ``p4``, or ``svn``.
  669. * `CTest Script`_ variable: none, detected from source tree
  670. * :module:`CTest` module variable: ``UPDATE_TYPE`` if set,
  671. else ``CTEST_UPDATE_TYPE``
  672. .. _`UpdateVersionOnly`:
  673. ``UpdateVersionOnly``
  674. Specify that you want the version control update command to only
  675. discover the current version that is checked out, and not to update
  676. to a different version.
  677. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_VERSION_ONLY`
  678. .. _`UpdateVersionOverride`:
  679. ``UpdateVersionOverride``
  680. Specify the current version of your source tree.
  681. When this variable is set to a non-empty string, CTest will report the value
  682. you specified rather than using the update command to discover the current
  683. version that is checked out. Use of this variable supersedes
  684. ``UpdateVersionOnly``. Like ``UpdateVersionOnly``, using this variable tells
  685. CTest not to update the source tree to a different version.
  686. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_VERSION_OVERRIDE`
  687. Additional configuration settings include:
  688. ``NightlyStartTime``
  689. In the ``Nightly`` dashboard mode, specify the "nightly start time".
  690. With centralized version control systems (``cvs`` and ``svn``),
  691. the ``Update`` step checks out the version of the software as of
  692. this time so that multiple clients choose a common version to test.
  693. This is not well-defined in distributed version-control systems so
  694. the setting is ignored.
  695. * `CTest Script`_ variable: :variable:`CTEST_NIGHTLY_START_TIME`
  696. * :module:`CTest` module variable: ``NIGHTLY_START_TIME`` if set,
  697. else ``CTEST_NIGHTLY_START_TIME``
  698. .. _`CTest Configure Step`:
  699. CTest Configure Step
  700. --------------------
  701. In a `CTest Script`_, the :command:`ctest_configure` command runs this step.
  702. Arguments to the command may specify some of the step settings.
  703. Configuration settings include:
  704. ``ConfigureCommand``
  705. Command-line to launch the software configuration process.
  706. It will be executed in the location specified by the
  707. ``BuildDirectory`` setting.
  708. * `CTest Script`_ variable: :variable:`CTEST_CONFIGURE_COMMAND`
  709. * :module:`CTest` module variable: :variable:`CMAKE_COMMAND`
  710. followed by :variable:`PROJECT_SOURCE_DIR`
  711. ``LabelsForSubprojects``
  712. Specify a semicolon-separated list of labels that will be treated as
  713. subprojects. This mapping will be passed on to CDash when configure, test or
  714. build results are submitted.
  715. * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
  716. * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
  717. See `Label and Subproject Summary`_.
  718. .. _`CTest Build Step`:
  719. CTest Build Step
  720. ----------------
  721. In a `CTest Script`_, the :command:`ctest_build` command runs this step.
  722. Arguments to the command may specify some of the step settings.
  723. Configuration settings include:
  724. ``DefaultCTestConfigurationType``
  725. When the build system to be launched allows build-time selection
  726. of the configuration (e.g. ``Debug``, ``Release``), this specifies
  727. the default configuration to be built when no ``-C`` option is
  728. given to the ``ctest`` command. The value will be substituted into
  729. the value of ``MakeCommand`` to replace the literal string
  730. ``${CTEST_CONFIGURATION_TYPE}`` if it appears.
  731. * `CTest Script`_ variable: :variable:`CTEST_CONFIGURATION_TYPE`
  732. * :module:`CTest` module variable: ``DEFAULT_CTEST_CONFIGURATION_TYPE``,
  733. initialized by the :envvar:`CMAKE_CONFIG_TYPE` environment variable
  734. ``LabelsForSubprojects``
  735. Specify a semicolon-separated list of labels that will be treated as
  736. subprojects. This mapping will be passed on to CDash when configure, test or
  737. build results are submitted.
  738. * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
  739. * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
  740. See `Label and Subproject Summary`_.
  741. ``MakeCommand``
  742. Command-line to launch the software build process.
  743. It will be executed in the location specified by the
  744. ``BuildDirectory`` setting.
  745. * `CTest Script`_ variable: :variable:`CTEST_BUILD_COMMAND`
  746. * :module:`CTest` module variable: ``MAKECOMMAND``,
  747. initialized by the :command:`build_command` command
  748. ``UseLaunchers``
  749. For build trees generated by CMake using one of the
  750. :ref:`Makefile Generators` or the :generator:`Ninja`
  751. generator, specify whether the
  752. ``CTEST_USE_LAUNCHERS`` feature is enabled by the
  753. :module:`CTestUseLaunchers` module (also included by the
  754. :module:`CTest` module). When enabled, the generated build
  755. system wraps each invocation of the compiler, linker, or
  756. custom command line with a "launcher" that communicates
  757. with CTest via environment variables and files to report
  758. granular build warning and error information. Otherwise,
  759. CTest must "scrape" the build output log for diagnostics.
  760. * `CTest Script`_ variable: :variable:`CTEST_USE_LAUNCHERS`
  761. * :module:`CTest` module variable: ``CTEST_USE_LAUNCHERS``
  762. .. _`CTest Test Step`:
  763. CTest Test Step
  764. ---------------
  765. In a `CTest Script`_, the :command:`ctest_test` command runs this step.
  766. Arguments to the command may specify some of the step settings.
  767. Configuration settings include:
  768. ``ResourceSpecFile``
  769. Specify a
  770. :ref:`resource specification file <ctest-resource-specification-file>`.
  771. * `CTest Script`_ variable: :variable:`CTEST_RESOURCE_SPEC_FILE`
  772. * :module:`CTest` module variable: ``CTEST_RESOURCE_SPEC_FILE``
  773. See :ref:`ctest-resource-allocation` for more information.
  774. ``LabelsForSubprojects``
  775. Specify a semicolon-separated list of labels that will be treated as
  776. subprojects. This mapping will be passed on to CDash when configure, test or
  777. build results are submitted.
  778. * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
  779. * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
  780. See `Label and Subproject Summary`_.
  781. ``TestLoad``
  782. While running tests in parallel (e.g. with ``-j``), try not to start
  783. tests when they may cause the CPU load to pass above a given threshold.
  784. * `CTest Script`_ variable: :variable:`CTEST_TEST_LOAD`
  785. * :module:`CTest` module variable: ``CTEST_TEST_LOAD``
  786. ``TimeOut``
  787. The default timeout for each test if not specified by the
  788. :prop_test:`TIMEOUT` test property.
  789. * `CTest Script`_ variable: :variable:`CTEST_TEST_TIMEOUT`
  790. * :module:`CTest` module variable: ``DART_TESTING_TIMEOUT``
  791. To report extra test values to CDash, see :ref:`Additional Test Measurements`.
  792. .. _`CTest Coverage Step`:
  793. CTest Coverage Step
  794. -------------------
  795. In a `CTest Script`_, the :command:`ctest_coverage` command runs this step.
  796. Arguments to the command may specify some of the step settings.
  797. Configuration settings include:
  798. ``CoverageCommand``
  799. Command-line tool to perform software coverage analysis.
  800. It will be executed in the location specified by the
  801. ``BuildDirectory`` setting.
  802. * `CTest Script`_ variable: :variable:`CTEST_COVERAGE_COMMAND`
  803. * :module:`CTest` module variable: ``COVERAGE_COMMAND``
  804. ``CoverageExtraFlags``
  805. Specify command-line options to the ``CoverageCommand`` tool.
  806. * `CTest Script`_ variable: :variable:`CTEST_COVERAGE_EXTRA_FLAGS`
  807. * :module:`CTest` module variable: ``COVERAGE_EXTRA_FLAGS``
  808. These options are the first arguments passed to ``CoverageCommand``.
  809. .. _`CTest MemCheck Step`:
  810. CTest MemCheck Step
  811. -------------------
  812. In a `CTest Script`_, the :command:`ctest_memcheck` command runs this step.
  813. Arguments to the command may specify some of the step settings.
  814. Configuration settings include:
  815. ``MemoryCheckCommand``
  816. Command-line tool to perform dynamic analysis. Test command lines
  817. will be launched through this tool.
  818. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND`
  819. * :module:`CTest` module variable: ``MEMORYCHECK_COMMAND``
  820. ``MemoryCheckCommandOptions``
  821. Specify command-line options to the ``MemoryCheckCommand`` tool.
  822. They will be placed prior to the test command line.
  823. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND_OPTIONS`
  824. * :module:`CTest` module variable: ``MEMORYCHECK_COMMAND_OPTIONS``
  825. ``MemoryCheckType``
  826. Specify the type of memory checking to perform.
  827. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_TYPE`
  828. * :module:`CTest` module variable: ``MEMORYCHECK_TYPE``
  829. ``MemoryCheckSanitizerOptions``
  830. Specify options to sanitizers when running with a sanitize-enabled build.
  831. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_SANITIZER_OPTIONS`
  832. * :module:`CTest` module variable: ``MEMORYCHECK_SANITIZER_OPTIONS``
  833. ``MemoryCheckSuppressionFile``
  834. Specify a file containing suppression rules for the
  835. ``MemoryCheckCommand`` tool. It will be passed with options
  836. appropriate to the tool.
  837. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_SUPPRESSIONS_FILE`
  838. * :module:`CTest` module variable: ``MEMORYCHECK_SUPPRESSIONS_FILE``
  839. Additional configuration settings include:
  840. ``BoundsCheckerCommand``
  841. Specify a ``MemoryCheckCommand`` that is known to be command-line
  842. compatible with Bounds Checker.
  843. * `CTest Script`_ variable: none
  844. * :module:`CTest` module variable: none
  845. ``PurifyCommand``
  846. Specify a ``MemoryCheckCommand`` that is known to be command-line
  847. compatible with Purify.
  848. * `CTest Script`_ variable: none
  849. * :module:`CTest` module variable: ``PURIFYCOMMAND``
  850. ``ValgrindCommand``
  851. Specify a ``MemoryCheckCommand`` that is known to be command-line
  852. compatible with Valgrind.
  853. * `CTest Script`_ variable: none
  854. * :module:`CTest` module variable: ``VALGRIND_COMMAND``
  855. ``ValgrindCommandOptions``
  856. Specify command-line options to the ``ValgrindCommand`` tool.
  857. They will be placed prior to the test command line.
  858. * `CTest Script`_ variable: none
  859. * :module:`CTest` module variable: ``VALGRIND_COMMAND_OPTIONS``
  860. ``DrMemoryCommand``
  861. Specify a ``MemoryCheckCommand`` that is known to be a command-line
  862. compatible with DrMemory.
  863. * `CTest Script`_ variable: none
  864. * :module:`CTest` module variable: ``DRMEMORY_COMMAND``
  865. ``DrMemoryCommandOptions``
  866. Specify command-line options to the ``DrMemoryCommand`` tool.
  867. They will be placed prior to the test command line.
  868. * `CTest Script`_ variable: none
  869. * :module:`CTest` module variable: ``DRMEMORY_COMMAND_OPTIONS``
  870. ``CudaSanitizerCommand``
  871. Specify a ``MemoryCheckCommand`` that is known to be a command-line
  872. compatible with cuda-memcheck or compute-sanitizer.
  873. * `CTest Script`_ variable: none
  874. * :module:`CTest` module variable: ``CUDA_SANITIZER_COMMAND``
  875. ``CudaSanitizerCommandOptions``
  876. Specify command-line options to the ``CudaSanitizerCommand`` tool.
  877. They will be placed prior to the test command line.
  878. * `CTest Script`_ variable: none
  879. * :module:`CTest` module variable: ``CUDA_SANITIZER_COMMAND_OPTIONS``
  880. .. _`CTest Submit Step`:
  881. CTest Submit Step
  882. -----------------
  883. In a `CTest Script`_, the :command:`ctest_submit` command runs this step.
  884. Arguments to the command may specify some of the step settings.
  885. Configuration settings include:
  886. ``BuildName``
  887. Describe the dashboard client platform with a short string.
  888. (Operating system, compiler, etc.)
  889. * `CTest Script`_ variable: :variable:`CTEST_BUILD_NAME`
  890. * :module:`CTest` module variable: ``BUILDNAME``
  891. ``CDashVersion``
  892. Legacy option. Not used.
  893. * `CTest Script`_ variable: none, detected from server
  894. * :module:`CTest` module variable: ``CTEST_CDASH_VERSION``
  895. ``CTestSubmitRetryCount``
  896. Specify a number of attempts to retry submission on network failure.
  897. * `CTest Script`_ variable: none,
  898. use the :command:`ctest_submit` ``RETRY_COUNT`` option.
  899. * :module:`CTest` module variable: ``CTEST_SUBMIT_RETRY_COUNT``
  900. ``CTestSubmitRetryDelay``
  901. Specify a delay before retrying submission on network failure.
  902. * `CTest Script`_ variable: none,
  903. use the :command:`ctest_submit` ``RETRY_DELAY`` option.
  904. * :module:`CTest` module variable: ``CTEST_SUBMIT_RETRY_DELAY``
  905. ``CurlOptions``
  906. Specify a semicolon-separated list of options to control the
  907. Curl library that CTest uses internally to connect to the
  908. server. Possible options are ``CURLOPT_SSL_VERIFYPEER_OFF``
  909. and ``CURLOPT_SSL_VERIFYHOST_OFF``.
  910. * `CTest Script`_ variable: :variable:`CTEST_CURL_OPTIONS`
  911. * :module:`CTest` module variable: ``CTEST_CURL_OPTIONS``
  912. ``DropLocation``
  913. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  914. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  915. ``DropLocation``.
  916. * `CTest Script`_ variable: :variable:`CTEST_DROP_LOCATION`
  917. * :module:`CTest` module variable: ``DROP_LOCATION`` if set,
  918. else ``CTEST_DROP_LOCATION``
  919. ``DropMethod``
  920. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  921. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  922. ``DropLocation``.
  923. * `CTest Script`_ variable: :variable:`CTEST_DROP_METHOD`
  924. * :module:`CTest` module variable: ``DROP_METHOD`` if set,
  925. else ``CTEST_DROP_METHOD``
  926. ``DropSite``
  927. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  928. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  929. ``DropLocation``.
  930. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE`
  931. * :module:`CTest` module variable: ``DROP_SITE`` if set,
  932. else ``CTEST_DROP_SITE``
  933. ``DropSitePassword``
  934. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  935. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  936. ``DropLocation``.
  937. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_PASSWORD`
  938. * :module:`CTest` module variable: ``DROP_SITE_PASSWORD`` if set,
  939. else ``CTEST_DROP_SITE_PASWORD``
  940. ``DropSiteUser``
  941. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  942. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  943. ``DropLocation``.
  944. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_USER`
  945. * :module:`CTest` module variable: ``DROP_SITE_USER`` if set,
  946. else ``CTEST_DROP_SITE_USER``
  947. ``IsCDash``
  948. Legacy option. Not used.
  949. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_CDASH`
  950. * :module:`CTest` module variable: ``CTEST_DROP_SITE_CDASH``
  951. ``ScpCommand``
  952. Legacy option. Not used.
  953. * `CTest Script`_ variable: :variable:`CTEST_SCP_COMMAND`
  954. * :module:`CTest` module variable: ``SCPCOMMAND``
  955. ``Site``
  956. Describe the dashboard client host site with a short string.
  957. (Hostname, domain, etc.)
  958. * `CTest Script`_ variable: :variable:`CTEST_SITE`
  959. * :module:`CTest` module variable: ``SITE``,
  960. initialized by the :command:`site_name` command
  961. ``SubmitURL``
  962. The ``http`` or ``https`` URL of the dashboard server to send the submission
  963. to.
  964. * `CTest Script`_ variable: :variable:`CTEST_SUBMIT_URL`
  965. * :module:`CTest` module variable: ``SUBMIT_URL`` if set,
  966. else ``CTEST_SUBMIT_URL``
  967. ``TriggerSite``
  968. Legacy option. Not used.
  969. * `CTest Script`_ variable: :variable:`CTEST_TRIGGER_SITE`
  970. * :module:`CTest` module variable: ``TRIGGER_SITE`` if set,
  971. else ``CTEST_TRIGGER_SITE``
  972. .. _`Show as JSON Object Model`:
  973. Show as JSON Object Model
  974. =========================
  975. When the ``--show-only=json-v1`` command line option is given, the test
  976. information is output in JSON format. Version 1.0 of the JSON object
  977. model is defined as follows:
  978. ``kind``
  979. The string "ctestInfo".
  980. ``version``
  981. A JSON object specifying the version components. Its members are
  982. ``major``
  983. A non-negative integer specifying the major version component.
  984. ``minor``
  985. A non-negative integer specifying the minor version component.
  986. ``backtraceGraph``
  987. JSON object representing backtrace information with the
  988. following members:
  989. ``commands``
  990. List of command names.
  991. ``files``
  992. List of file names.
  993. ``nodes``
  994. List of node JSON objects with members:
  995. ``command``
  996. Index into the ``commands`` member of the ``backtraceGraph``.
  997. ``file``
  998. Index into the ``files`` member of the ``backtraceGraph``.
  999. ``line``
  1000. Line number in the file where the backtrace was added.
  1001. ``parent``
  1002. Index into the ``nodes`` member of the ``backtraceGraph``
  1003. representing the parent in the graph.
  1004. ``tests``
  1005. A JSON array listing information about each test. Each entry
  1006. is a JSON object with members:
  1007. ``name``
  1008. Test name.
  1009. ``config``
  1010. Configuration that the test can run on.
  1011. Empty string means any config.
  1012. ``command``
  1013. List where the first element is the test command and the
  1014. remaining elements are the command arguments.
  1015. ``backtrace``
  1016. Index into the ``nodes`` member of the ``backtraceGraph``.
  1017. ``properties``
  1018. Test properties.
  1019. Can contain keys for each of the supported test properties.
  1020. .. _`ctest-resource-allocation`:
  1021. Resource Allocation
  1022. ===================
  1023. CTest provides a mechanism for tests to specify the resources that they need
  1024. in a fine-grained way, and for users to specify the resources available on
  1025. the running machine. This allows CTest to internally keep track of which
  1026. resources are in use and which are free, scheduling tests in a way that
  1027. prevents them from trying to claim resources that are not available.
  1028. When the resource allocation feature is used, CTest will not oversubscribe
  1029. resources. For example, if a resource has 8 slots, CTest will not run tests
  1030. that collectively use more than 8 slots at a time. This has the effect of
  1031. limiting how many tests can run at any given time, even if a high ``-j``
  1032. argument is used, if those tests all use some slots from the same resource.
  1033. In addition, it means that a single test that uses more of a resource than is
  1034. available on a machine will not run at all (and will be reported as
  1035. ``Not Run``).
  1036. A common use case for this feature is for tests that require the use of a GPU.
  1037. Multiple tests can simultaneously allocate memory from a GPU, but if too many
  1038. tests try to do this at once, some of them will fail to allocate, resulting in
  1039. a failed test, even though the test would have succeeded if it had the memory
  1040. it needed. By using the resource allocation feature, each test can specify how
  1041. much memory it requires from a GPU, allowing CTest to schedule tests in a way
  1042. that running several of these tests at once does not exhaust the GPU's memory
  1043. pool.
  1044. Please note that CTest has no concept of what a GPU is or how much memory it
  1045. has, nor does it have any way of communicating with a GPU to retrieve this
  1046. information or perform any memory management. CTest simply keeps track of a
  1047. list of abstract resource types, each of which has a certain number of slots
  1048. available for tests to use. Each test specifies the number of slots that it
  1049. requires from a certain resource, and CTest then schedules them in a way that
  1050. prevents the total number of slots in use from exceeding the listed capacity.
  1051. When a test is executed, and slots from a resource are allocated to that test,
  1052. tests may assume that they have exclusive use of those slots for the duration
  1053. of the test's process.
  1054. The CTest resource allocation feature consists of two inputs:
  1055. * The :ref:`resource specification file <ctest-resource-specification-file>`,
  1056. described below, which describes the resources available on the system.
  1057. * The :prop_test:`RESOURCE_GROUPS` property of tests, which describes the
  1058. resources required by the test.
  1059. When CTest runs a test, the resources allocated to that test are passed in the
  1060. form of a set of
  1061. :ref:`environment variables <ctest-resource-environment-variables>` as
  1062. described below. Using this information to decide which resource to connect to
  1063. is left to the test writer.
  1064. The ``RESOURCE_GROUPS`` property tells CTest what resources a test expects
  1065. to use grouped in a way meaningful to the test. The test itself must read
  1066. the :ref:`environment variables <ctest-resource-environment-variables>` to
  1067. determine which resources have been allocated to each group. For example,
  1068. each group may correspond to a process the test will spawn when executed.
  1069. Note that even if a test specifies a ``RESOURCE_GROUPS`` property, it is still
  1070. possible for that to test to run without any resource allocation (and without
  1071. the corresponding
  1072. :ref:`environment variables <ctest-resource-environment-variables>`)
  1073. if the user does not pass a resource specification file. Passing this file,
  1074. either through the ``--resource-spec-file`` command-line argument or the
  1075. ``RESOURCE_SPEC_FILE`` argument to :command:`ctest_test`, is what activates the
  1076. resource allocation feature. Tests should check the
  1077. ``CTEST_RESOURCE_GROUP_COUNT`` environment variable to find out whether or not
  1078. resource allocation is activated. This variable will always (and only) be
  1079. defined if resource allocation is activated. If resource allocation is not
  1080. activated, then the ``CTEST_RESOURCE_GROUP_COUNT`` variable will not exist,
  1081. even if it exists for the parent ``ctest`` process. If a test absolutely must
  1082. have resource allocation, then it can return a failing exit code or use the
  1083. :prop_test:`SKIP_RETURN_CODE` or :prop_test:`SKIP_REGULAR_EXPRESSION`
  1084. properties to indicate a skipped test.
  1085. .. _`ctest-resource-specification-file`:
  1086. Resource Specification File
  1087. ---------------------------
  1088. The resource specification file is a JSON file which is passed to CTest, either
  1089. on the :manual:`ctest(1)` command line as ``--resource-spec-file``, or as the
  1090. ``RESOURCE_SPEC_FILE`` argument of :command:`ctest_test`. If a dashboard script
  1091. is used and ``RESOURCE_SPEC_FILE`` is not specified, the value of
  1092. :variable:`CTEST_RESOURCE_SPEC_FILE` in the dashboard script is used instead.
  1093. If ``--resource-spec-file``, ``RESOURCE_SPEC_FILE``, and
  1094. :variable:`CTEST_RESOURCE_SPEC_FILE` in the dashboard script are not specified,
  1095. the value of :variable:`CTEST_RESOURCE_SPEC_FILE` in the CMake build is used
  1096. instead. If none of these are specified, no resource spec file is used.
  1097. The resource specification file must be a JSON object. All examples in this
  1098. document assume the following resource specification file:
  1099. .. code-block:: json
  1100. {
  1101. "version": {
  1102. "major": 1,
  1103. "minor": 0
  1104. },
  1105. "local": [
  1106. {
  1107. "gpus": [
  1108. {
  1109. "id": "0",
  1110. "slots": 2
  1111. },
  1112. {
  1113. "id": "1",
  1114. "slots": 4
  1115. },
  1116. {
  1117. "id": "2",
  1118. "slots": 2
  1119. },
  1120. {
  1121. "id": "3"
  1122. }
  1123. ],
  1124. "crypto_chips": [
  1125. {
  1126. "id": "card0",
  1127. "slots": 4
  1128. }
  1129. ]
  1130. }
  1131. ]
  1132. }
  1133. The members are:
  1134. ``version``
  1135. An object containing a ``major`` integer field and a ``minor`` integer field.
  1136. Currently, the only supported version is major ``1``, minor ``0``. Any other
  1137. value is an error.
  1138. ``local``
  1139. A JSON array of resource sets present on the system. Currently, this array
  1140. is restricted to being of size 1.
  1141. Each array element is a JSON object with members whose names are equal to the
  1142. desired resource types, such as ``gpus``. These names must start with a
  1143. lowercase letter or an underscore, and subsequent characters can be a
  1144. lowercase letter, a digit, or an underscore. Uppercase letters are not
  1145. allowed, because certain platforms have case-insensitive environment
  1146. variables. See the `Environment Variables`_ section below for
  1147. more information. It is recommended that the resource type name be the plural
  1148. of a noun, such as ``gpus`` or ``crypto_chips`` (and not ``gpu`` or
  1149. ``crypto_chip``.)
  1150. Please note that the names ``gpus`` and ``crypto_chips`` are just examples,
  1151. and CTest does not interpret them in any way. You are free to make up any
  1152. resource type you want to meet your own requirements.
  1153. The value for each resource type is a JSON array consisting of JSON objects,
  1154. each of which describe a specific instance of the specified resource. These
  1155. objects have the following members:
  1156. ``id``
  1157. A string consisting of an identifier for the resource. Each character in
  1158. the identifier can be a lowercase letter, a digit, or an underscore.
  1159. Uppercase letters are not allowed.
  1160. Identifiers must be unique within a resource type. However, they do not
  1161. have to be unique across resource types. For example, it is valid to have a
  1162. ``gpus`` resource named ``0`` and a ``crypto_chips`` resource named ``0``,
  1163. but not two ``gpus`` resources both named ``0``.
  1164. Please note that the IDs ``0``, ``1``, ``2``, ``3``, and ``card0`` are just
  1165. examples, and CTest does not interpret them in any way. You are free to
  1166. make up any IDs you want to meet your own requirements.
  1167. ``slots``
  1168. An optional unsigned number specifying the number of slots available on the
  1169. resource. For example, this could be megabytes of RAM on a GPU, or
  1170. cryptography units available on a cryptography chip. If ``slots`` is not
  1171. specified, a default value of ``1`` is assumed.
  1172. In the example file above, there are four GPUs with ID's 0 through 3. GPU 0 has
  1173. 2 slots, GPU 1 has 4, GPU 2 has 2, and GPU 3 has a default of 1 slot. There is
  1174. also one cryptography chip with 4 slots.
  1175. ``RESOURCE_GROUPS`` Property
  1176. ----------------------------
  1177. See :prop_test:`RESOURCE_GROUPS` for a description of this property.
  1178. .. _`ctest-resource-environment-variables`:
  1179. Environment Variables
  1180. ---------------------
  1181. Once CTest has decided which resources to allocate to a test, it passes this
  1182. information to the test executable as a series of environment variables. For
  1183. each example below, we will assume that the test in question has a
  1184. :prop_test:`RESOURCE_GROUPS` property of
  1185. ``2,gpus:2;gpus:4,gpus:1,crypto_chips:2``.
  1186. The following variables are passed to the test process:
  1187. .. envvar:: CTEST_RESOURCE_GROUP_COUNT
  1188. The total number of groups specified by the :prop_test:`RESOURCE_GROUPS`
  1189. property. For example:
  1190. * ``CTEST_RESOURCE_GROUP_COUNT=3``
  1191. This variable will only be defined if :manual:`ctest(1)` has been given a
  1192. ``--resource-spec-file``, or if :command:`ctest_test` has been given a
  1193. ``RESOURCE_SPEC_FILE``. If no resource specification file has been given,
  1194. this variable will not be defined.
  1195. .. envvar:: CTEST_RESOURCE_GROUP_<num>
  1196. The list of resource types allocated to each group, with each item
  1197. separated by a comma. ``<num>`` is a number from zero to
  1198. ``CTEST_RESOURCE_GROUP_COUNT`` minus one. ``CTEST_RESOURCE_GROUP_<num>``
  1199. is defined for each ``<num>`` in this range. For example:
  1200. * ``CTEST_RESOURCE_GROUP_0=gpus``
  1201. * ``CTEST_RESOURCE_GROUP_1=gpus``
  1202. * ``CTEST_RESOURCE_GROUP_2=crypto_chips,gpus``
  1203. .. envvar:: CTEST_RESOURCE_GROUP_<num>_<resource-type>
  1204. The list of resource IDs and number of slots from each ID allocated to each
  1205. group for a given resource type. This variable consists of a series of
  1206. pairs, each pair separated by a semicolon, and with the two items in the pair
  1207. separated by a comma. The first item in each pair is ``id:`` followed by the
  1208. ID of a resource of type ``<resource-type>``, and the second item is
  1209. ``slots:`` followed by the number of slots from that resource allocated to
  1210. the given group. For example:
  1211. * ``CTEST_RESOURCE_GROUP_0_GPUS=id:0,slots:2``
  1212. * ``CTEST_RESOURCE_GROUP_1_GPUS=id:2,slots:2``
  1213. * ``CTEST_RESOURCE_GROUP_2_GPUS=id:1,slots:4;id:3,slots:1``
  1214. * ``CTEST_RESOURCE_GROUP_2_CRYPTO_CHIPS=id:card0,slots:2``
  1215. In this example, group 0 gets 2 slots from GPU ``0``, group 1 gets 2 slots
  1216. from GPU ``2``, and group 2 gets 4 slots from GPU ``1``, 1 slot from GPU
  1217. ``3``, and 2 slots from cryptography chip ``card0``.
  1218. ``<num>`` is a number from zero to ``CTEST_RESOURCE_GROUP_COUNT`` minus one.
  1219. ``<resource-type>`` is the name of a resource type, converted to uppercase.
  1220. ``CTEST_RESOURCE_GROUP_<num>_<resource-type>`` is defined for the product
  1221. of each ``<num>`` in the range listed above and each resource type listed in
  1222. ``CTEST_RESOURCE_GROUP_<num>``.
  1223. Because some platforms have case-insensitive names for environment variables,
  1224. the names of resource types may not clash in a case-insensitive environment.
  1225. Because of this, for the sake of simplicity, all resource types must be
  1226. listed in all lowercase in the
  1227. :ref:`resource specification file <ctest-resource-specification-file>` and
  1228. in the :prop_test:`RESOURCE_GROUPS` property, and they are converted to all
  1229. uppercase in the ``CTEST_RESOURCE_GROUP_<num>_<resource-type>`` environment
  1230. variable.
  1231. See Also
  1232. ========
  1233. .. include:: LINKS.txt
  1234. _`CDash`: https://cdash.org