ctest.1.rst 62 KB

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