ctest.1.rst 68 KB

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