ctest.1.rst 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005
  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. Disable (``0``) or enable (``1``) interactive debug mode.
  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. Interactive Mode allows Windows Error Reporting (WER) to show debug popup
  242. windows and to create core dumps. To enable core dumps in tests,
  243. use interactive mode, and follow the Windows documentation
  244. on `Collecting User-Mode Dumps`_.
  245. .. versionchanged:: 4.0
  246. Windows Error Reporting (WER) is enabled in interactive mode, so
  247. test processes may show debug popup windows and create core dumps.
  248. This was made possible by updates to ``libuv``.
  249. .. versionchanged:: 3.11
  250. Windows Error Reporting (WER) is disabled in both interactive and
  251. non-interactive modes, so test processes do not show popup windows
  252. or create core dumps. This is due to launching test processes with
  253. ``libuv``.
  254. .. _`Collecting User-Mode Dumps`: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps
  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:: --test-dir <dir>
  268. .. versionadded:: 3.20
  269. Specify the directory in which to look for tests, typically a CMake project
  270. build directory. If not specified, the current directory is used.
  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. Ignored. This option once disabled a now-removed optimization
  287. for tests running ``ctest`` itself.
  288. .. option:: --schedule-random
  289. Use a random order for scheduling tests.
  290. This option will run the tests in a random order. It is commonly
  291. used to detect implicit dependencies in a test suite.
  292. .. option:: --schedule-random-seed
  293. .. versionadded:: 4.1
  294. Override the random order seed
  295. This option is used to allow recreating failures owing to
  296. random order of execution by ``--schedule-random``.
  297. .. option:: --submit-index
  298. Legacy option for old Dart2 dashboard server feature.
  299. Do not use.
  300. .. option:: --timeout <seconds>
  301. Set the default test timeout.
  302. This option effectively sets a timeout on all tests that do not
  303. already have a timeout set on them via the :prop_test:`TIMEOUT`
  304. property.
  305. .. option:: --stop-time <time>
  306. Set a time at which all tests should stop running.
  307. Set a real time of day at which all tests should timeout. Example:
  308. ``7:00:00 -0400``. Any time format understood by the curl date parser
  309. is accepted. Local time is assumed if no timezone is specified.
  310. .. option:: --print-labels
  311. Print all available test labels.
  312. This option will not run any tests, it will simply print the list of
  313. all labels associated with the test set.
  314. .. option:: --no-tests=<action>
  315. Regard no tests found either as error (when ``<action>`` is set to
  316. ``error``) or ignore it (when ``<action>`` is set to ``ignore``).
  317. If no tests were found, the default behavior of CTest is to always log an
  318. error message but to return an error code in script mode only. This option
  319. unifies the behavior of CTest by either returning an error code if no tests
  320. were found or by ignoring it.
  321. .. versionadded:: 3.26
  322. This option can also be set by setting the :envvar:`CTEST_NO_TESTS_ACTION`
  323. environment variable.
  324. View Help
  325. =========
  326. To print version details or selected pages from the CMake documentation,
  327. use one of the following options:
  328. .. include:: include/OPTIONS_HELP.rst
  329. .. _`Label Matching`:
  330. Label Matching
  331. ==============
  332. Tests may have labels attached to them. Tests may be included
  333. or excluded from a test run by filtering on the labels.
  334. Each individual filter is a regular expression applied to
  335. the labels attached to a test.
  336. When :option:`-L <ctest -L>` is used, in order for a test to be included in a
  337. test run, each regular expression must match at least one
  338. label. Using more than one :option:`-L <ctest -L>` option means "match **all**
  339. of these".
  340. The :option:`-LE <ctest -LE>` option works just like :option:`-L <ctest -L>`,
  341. but excludes tests rather than including them. A test is excluded if each
  342. regular expression matches at least one label.
  343. If a test has no labels attached to it, then :option:`-L <ctest -L>` will never
  344. include that test, and :option:`-LE <ctest -LE>` will never exclude that test.
  345. As an example of tests with labels, consider five tests,
  346. with the following labels:
  347. * *test1* has labels *tuesday* and *production*
  348. * *test2* has labels *tuesday* and *test*
  349. * *test3* has labels *wednesday* and *production*
  350. * *test4* has label *wednesday*
  351. * *test5* has labels *friday* and *test*
  352. Running :program:`ctest` with ``-L tuesday -L test`` will select *test2*, which has
  353. both labels. Running CTest with ``-L test`` will select *test2* and
  354. *test5*, because both of them have a label that matches that regular
  355. expression.
  356. Because the matching works with regular expressions, take note that
  357. running CTest with ``-L es`` will match all five tests.
  358. To select the *tuesday* and *wednesday* tests together, use a single
  359. regular expression that matches either of them, like ``-L "tue|wed"``.
  360. .. _`Label and Subproject Summary`:
  361. Label and Subproject Summary
  362. ============================
  363. CTest prints timing summary information for each ``LABEL`` and subproject
  364. associated with the tests run. The label time summary will not include labels
  365. that are mapped to subprojects.
  366. .. versionadded:: 3.22
  367. Labels added dynamically during test execution are also reported in the
  368. timing summary. See :ref:`Additional Labels`.
  369. When the :prop_test:`PROCESSORS` test property is set, CTest will display a
  370. weighted test timing result in label and subproject summaries. The time is
  371. reported with ``sec * proc`` instead of just ``sec``.
  372. The weighted time summary reported for each label or subproject ``j``
  373. is computed as::
  374. Weighted Time Summary for Label/Subproject j =
  375. sum(raw_test_time[j,i] * num_processors[j,i], i=1...num_tests[j])
  376. for labels/subprojects j=1...total
  377. where:
  378. * ``raw_test_time[j,i]``: Wall-clock time for the ``i`` test
  379. for the ``j`` label or subproject
  380. * ``num_processors[j,i]``: Value of the CTest :prop_test:`PROCESSORS` property
  381. for the ``i`` test for the ``j`` label or subproject
  382. * ``num_tests[j]``: Number of tests associated with the ``j`` label or subproject
  383. * ``total``: Total number of labels or subprojects that have at least one test run
  384. Therefore, the weighted time summary for each label or subproject represents
  385. the amount of time that CTest gave to run the tests for each label or
  386. subproject and gives a good representation of the total expense of the tests
  387. for each label or subproject when compared to other labels or subprojects.
  388. For example, if ``SubprojectA`` showed ``100 sec*proc`` and ``SubprojectB`` showed
  389. ``10 sec*proc``, then CTest allocated approximately 10 times the CPU/core time
  390. to run the tests for ``SubprojectA`` than for ``SubprojectB`` (e.g. so if effort
  391. is going to be expended to reduce the cost of the test suite for the whole
  392. project, then reducing the cost of the test suite for ``SubprojectA`` would
  393. likely have a larger impact than effort to reduce the cost of the test suite
  394. for ``SubprojectB``).
  395. .. _`Build and Test Mode`:
  396. Build and Test Mode
  397. ===================
  398. CTest provides a command-line signature to configure (i.e. run cmake on),
  399. build, and/or execute a test::
  400. ctest --build-and-test <path-to-source> <path-to-build>
  401. --build-generator <generator>
  402. [<options>...]
  403. [--build-options <opts>...]
  404. [--test-command <command> [<args>...]]
  405. The configure and test steps are optional. The arguments to this command line
  406. are the source and binary directories. The ``--build-generator`` option *must*
  407. be provided to use ``--build-and-test``. If ``--test-command`` is specified
  408. then that will be run after the build is complete. Other options that affect
  409. this mode include:
  410. .. option:: --build-and-test
  411. Switch into the build and test mode.
  412. .. option:: --build-target
  413. Specify a specific target to build. The option can be given multiple times
  414. with different targets, in which case each target is built in turn.
  415. A clean will be done before building each target unless the
  416. :option:`--build-noclean` option is given.
  417. If no ``--build-target`` is specified, the ``all`` target is built.
  418. .. option:: --build-nocmake
  419. Run the build without running cmake first.
  420. Skip the cmake step.
  421. .. option:: --build-run-dir
  422. Specify directory to run programs from.
  423. Directory where programs will be after it has been compiled.
  424. .. option:: --build-two-config
  425. Run CMake twice.
  426. .. option:: --build-exe-dir
  427. Specify the directory for the executable.
  428. .. option:: --build-generator
  429. Specify the generator to use. See the :manual:`cmake-generators(7)` manual.
  430. .. option:: --build-generator-platform
  431. Specify the generator-specific platform.
  432. .. option:: --build-generator-toolset
  433. Specify the generator-specific toolset.
  434. .. option:: --build-project
  435. Specify the name of the project to build.
  436. .. option:: --build-makeprogram
  437. Specify the explicit make program to be used by CMake when configuring and
  438. building the project. Only applicable for Make and Ninja based generators.
  439. .. option:: --build-noclean
  440. Skip the make clean step.
  441. .. option:: --build-config-sample
  442. A sample executable to use to determine the configuration that
  443. should be used. e.g. ``Debug``, ``Release`` etc.
  444. .. option:: --build-options
  445. Additional options for configuring the build (i.e. for CMake, not for
  446. the build tool). Note that if this is specified, the ``--build-options``
  447. keyword and its arguments must be the last option given on the command
  448. line, with the possible exception of ``--test-command``.
  449. .. option:: --test-command
  450. The command to run as the test step with the
  451. :option:`--build-and-test <ctest --build-and-test>` option.
  452. All arguments following this keyword will be assumed to be part of the
  453. test command line, so it must be the last option given.
  454. .. option:: --test-timeout
  455. The time limit in seconds
  456. .. _`Dashboard Client`:
  457. Dashboard Client
  458. ================
  459. CTest can operate as a client for the `CDash`_ software quality dashboard
  460. application. As a dashboard client, CTest performs a sequence of steps
  461. to configure, build, and test software, and then submits the results to
  462. a `CDash`_ server. The command-line signature used to submit to `CDash`_ is::
  463. ctest -D <dashboard> [-- <dashboard-options>...]
  464. ctest -M <model> -T <action> [-- <dashboard-options>...]
  465. ctest -S <script> [-- <dashboard-options>...]
  466. ctest -SP <script> [-- <dashboard-options>...]
  467. .. _`CDash`: https://www.cdash.org
  468. Options for Dashboard Client include:
  469. .. option:: -D <dashboard>, --dashboard <dashboard>
  470. Execute dashboard test.
  471. This option tells CTest to act as a CDash client and perform a
  472. dashboard test. All tests are ``<Mode><Test>``, where ``<Mode>`` can be
  473. ``Experimental``, ``Nightly``, and ``Continuous``, and ``<Test>`` can be
  474. ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
  475. ``Coverage``, and ``Submit``.
  476. If ``<dashboard>`` is not one of the recognized ``<Mode><Test>`` values,
  477. this will be treated as a variable definition instead (see the
  478. :ref:`dashboard-options <Dashboard Options>` further below).
  479. .. option:: -M <model>, --test-model <model>
  480. Sets the model for a dashboard.
  481. This option tells CTest to act as a CDash client where the ``<model>``
  482. can be ``Experimental``, ``Nightly``, and ``Continuous``.
  483. Combining ``-M`` and :option:`-T <ctest -T>` is similar to
  484. :option:`-D <ctest -D>`.
  485. .. option:: -T <action>, --test-action <action>
  486. Sets the dashboard action to perform.
  487. This option tells CTest to act as a CDash client and perform some
  488. action such as ``start``, ``build``, ``test`` etc. See
  489. `Dashboard Client Steps`_ for the full list of actions.
  490. Combining :option:`-M <ctest -M>` and ``-T`` is similar to
  491. :option:`-D <ctest -D>`.
  492. .. option:: -S <script>, --script <script>
  493. Execute a dashboard for a configuration.
  494. This option tells CTest to load in a configuration script which sets
  495. a number of parameters such as the binary and source directories.
  496. Then CTest will do what is required to create and run a dashboard.
  497. This option basically sets up a dashboard and then runs :option:`ctest -D`
  498. with the appropriate options.
  499. .. option:: -SP <script>, --script-new-process <script>
  500. Execute a dashboard for a configuration.
  501. This option does the same operations as :option:`-S <ctest -S>` but it
  502. will do them in a separate process. This is primarily useful in cases
  503. where the script may modify the environment and you do not want the modified
  504. environment to impact other :option:`-S <ctest -S>` scripts.
  505. .. _`Dashboard Options`:
  506. The available ``<dashboard-options>`` are the following:
  507. .. option:: -D <var>:<type>=<value>
  508. Define a variable for script mode.
  509. Pass in variable values on the command line. Use in conjunction
  510. with :option:`-S <ctest -S>` to pass variable values to a dashboard script.
  511. Parsing ``-D`` arguments as variable values is only attempted if the value
  512. following ``-D`` does not match any of the known dashboard types.
  513. .. option:: --group <group>
  514. Specify what group you'd like to submit results to
  515. Submit dashboard to specified group instead of default one. By
  516. default, the dashboard is submitted to Nightly, Experimental, or
  517. Continuous group, but by specifying this option, the group can be
  518. arbitrary.
  519. This replaces the deprecated option ``--track``.
  520. Despite the name change its behavior is unchanged.
  521. .. option:: -A <file>, --add-notes <file>
  522. Add a notes file with submission.
  523. This option tells CTest to include a notes file when submitting
  524. dashboard.
  525. .. option:: --tomorrow-tag
  526. ``Nightly`` or ``Experimental`` starts with next day tag.
  527. This is useful if the build will not finish in one day.
  528. .. option:: --extra-submit <file>[;<file>]
  529. Submit extra ``.xml`` part files to the dashboard.
  530. See the :command:`ctest_submit` command's ``PARTS ExtraFiles`` option.
  531. .. option:: --http-header <header>
  532. .. versionadded:: 3.29
  533. Append HTTP header when submitting to the dashboard.
  534. This option will cause CTest to append the specified header
  535. when submitting to the dashboard.
  536. This option may be specified more than once.
  537. .. option:: --http1.0
  538. Submit using ``HTTP 1.0``.
  539. This option will force CTest to use ``HTTP 1.0`` to submit files to the
  540. dashboard, instead of ``HTTP 1.1``.
  541. .. option:: --no-compress-output
  542. Do not compress test output when submitting.
  543. This flag will turn off automatic compression of test output. Use
  544. this to maintain compatibility with an older version of CDash which
  545. doesn't support compressed test output.
  546. Dashboard Client Steps
  547. ----------------------
  548. CTest defines an ordered list of testing steps of which some or all may
  549. be run as a dashboard client:
  550. ``Start``
  551. Start a new dashboard submission to be composed of results recorded
  552. by the following steps.
  553. See the `CTest Start Step`_ section below.
  554. ``Update``
  555. Update the source tree from its version control repository.
  556. Record the old and new versions and the list of updated source files.
  557. See the `CTest Update Step`_ section below.
  558. ``Configure``
  559. Configure the software by running a command in the build tree.
  560. Record the configuration output log.
  561. See the `CTest Configure Step`_ section below.
  562. ``Build``
  563. Build the software by running a command in the build tree.
  564. Record the build output log and detect warnings and errors.
  565. See the `CTest Build Step`_ section below.
  566. ``Test``
  567. Test the software by loading a ``CTestTestfile.cmake``
  568. from the build tree and executing the defined tests.
  569. Record the output and result of each test.
  570. See the `CTest Test Step`_ section below.
  571. ``Coverage``
  572. Compute coverage of the source code by running a coverage
  573. analysis tool and recording its output.
  574. See the `CTest Coverage Step`_ section below.
  575. ``MemCheck``
  576. Run the software test suite through a memory check tool.
  577. Record the test output, results, and issues reported by the tool.
  578. See the `CTest MemCheck Step`_ section below.
  579. ``Submit``
  580. Submit results recorded from other testing steps to the
  581. software quality dashboard server.
  582. See the `CTest Submit Step`_ section below.
  583. Dashboard Client Modes
  584. ----------------------
  585. CTest defines three modes of operation as a dashboard client:
  586. ``Nightly``
  587. This mode is intended to be invoked once per day, typically at night.
  588. It enables the ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
  589. ``Coverage``, and ``Submit`` steps by default. Selected steps run even
  590. if the ``Update`` step reports no changes to the source tree.
  591. ``Continuous``
  592. This mode is intended to be invoked repeatedly throughout the day.
  593. It enables the ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
  594. ``Coverage``, and ``Submit`` steps by default, but exits after the
  595. ``Update`` step if it reports no changes to the source tree.
  596. ``Experimental``
  597. This mode is intended to be invoked by a developer to test local changes.
  598. It enables the ``Start``, ``Configure``, ``Build``, ``Test``, ``Coverage``,
  599. and ``Submit`` steps by default.
  600. Dashboard Client via CTest Command-Line
  601. ---------------------------------------
  602. CTest can perform testing on an already-generated build tree.
  603. Run the :program:`ctest` command with the current working directory set
  604. to the build tree and use one of these signatures::
  605. ctest -D <mode>[<step>]
  606. ctest -M <mode> [-T <step>]...
  607. The ``<mode>`` must be one of the above `Dashboard Client Modes`_,
  608. and each ``<step>`` must be one of the above `Dashboard Client Steps`_.
  609. CTest reads the `Dashboard Client Configuration`_ settings from
  610. a file in the build tree called either ``CTestConfiguration.ini``
  611. or ``DartConfiguration.tcl`` (the names are historical). The format
  612. of the file is::
  613. # Lines starting in '#' are comments.
  614. # Other non-blank lines are key-value pairs.
  615. <setting>: <value>
  616. where ``<setting>`` is the setting name and ``<value>`` is the
  617. setting value.
  618. In build trees generated by CMake, this configuration file is
  619. generated by the :module:`CTest` module if included by the project.
  620. The module uses variables to obtain a value for each setting
  621. as documented with the settings below.
  622. .. _`CTest Script`:
  623. Dashboard Client via CTest Script
  624. ---------------------------------
  625. CTest can perform testing driven by a :manual:`cmake-language(7)`
  626. script that creates and maintains the source and build tree as
  627. well as performing the testing steps. Run the :program:`ctest` command
  628. with the current working directory set outside of any build tree
  629. and use one of these signatures::
  630. ctest -S <script>
  631. ctest -SP <script>
  632. The ``<script>`` file must call :ref:`CTest Commands` commands
  633. to run testing steps explicitly as documented below. The commands
  634. obtain `Dashboard Client Configuration`_ settings from their
  635. arguments or from variables set in the script.
  636. Dashboard Client Configuration
  637. ==============================
  638. The `Dashboard Client Steps`_ may be configured by named
  639. settings as documented in the following sections.
  640. .. _`CTest Start Step`:
  641. CTest Start Step
  642. ----------------
  643. Start a new dashboard submission to be composed of results recorded
  644. by the following steps.
  645. In a `CTest Script`_, the :command:`ctest_start` command runs this step.
  646. Arguments to the command may specify some of the step settings.
  647. The command first runs the command-line specified by the
  648. ``CTEST_CHECKOUT_COMMAND`` variable, if set, to initialize the source
  649. directory.
  650. Configuration settings include:
  651. ``BuildDirectory``
  652. The full path to the project build tree.
  653. * `CTest Script`_ variable: :variable:`CTEST_BINARY_DIRECTORY`
  654. * :module:`CTest` module variable: :variable:`PROJECT_BINARY_DIR`
  655. ``SourceDirectory``
  656. The full path to the project source tree.
  657. * `CTest Script`_ variable: :variable:`CTEST_SOURCE_DIRECTORY`
  658. * :module:`CTest` module variable: :variable:`PROJECT_SOURCE_DIR`
  659. .. _`CTest Update Step`:
  660. CTest Update Step
  661. -----------------
  662. In a `CTest Script`_, the :command:`ctest_update` command runs this step.
  663. Arguments to the command may specify some of the step settings.
  664. Configuration settings to specify the version control tool include:
  665. ``BZRCommand``
  666. ``bzr`` command-line tool to use if source tree is managed by Bazaar.
  667. * `CTest Script`_ variable: :variable:`CTEST_BZR_COMMAND`
  668. * :module:`CTest` module variable: none
  669. ``BZRUpdateOptions``
  670. Command-line options to the ``BZRCommand`` when updating the source.
  671. * `CTest Script`_ variable: :variable:`CTEST_BZR_UPDATE_OPTIONS`
  672. * :module:`CTest` module variable: none
  673. ``CVSCommand``
  674. ``cvs`` command-line tool to use if source tree is managed by CVS.
  675. * `CTest Script`_ variable: :variable:`CTEST_CVS_COMMAND`
  676. * :module:`CTest` module variable: ``CVSCOMMAND``
  677. ``CVSUpdateOptions``
  678. Command-line options to the ``CVSCommand`` when updating the source.
  679. * `CTest Script`_ variable: :variable:`CTEST_CVS_UPDATE_OPTIONS`
  680. * :module:`CTest` module variable: ``CVS_UPDATE_OPTIONS``
  681. ``GITCommand``
  682. ``git`` command-line tool to use if source tree is managed by Git.
  683. * `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND`
  684. * :module:`CTest` module variable: ``GITCOMMAND``
  685. The source tree is updated by ``git fetch`` followed by
  686. ``git reset --hard`` to the ``FETCH_HEAD``. The result is the same
  687. as ``git pull`` except that any local modifications are overwritten.
  688. Use ``GITUpdateCustom`` to specify a different approach.
  689. ``GITInitSubmodules``
  690. If set, CTest will update the repository's submodules before updating.
  691. * `CTest Script`_ variable: :variable:`CTEST_GIT_INIT_SUBMODULES`
  692. * :module:`CTest` module variable: ``CTEST_GIT_INIT_SUBMODULES``
  693. ``GITUpdateCustom``
  694. Specify a custom command line (as a semicolon-separated list) to run
  695. in the source tree (Git work tree) to update it instead of running
  696. the ``GITCommand``.
  697. * `CTest Script`_ variable: :variable:`CTEST_GIT_UPDATE_CUSTOM`
  698. * :module:`CTest` module variable: ``CTEST_GIT_UPDATE_CUSTOM``
  699. ``GITUpdateOptions``
  700. Command-line options to the ``GITCommand`` when updating the source.
  701. * `CTest Script`_ variable: :variable:`CTEST_GIT_UPDATE_OPTIONS`
  702. * :module:`CTest` module variable: ``GIT_UPDATE_OPTIONS``
  703. ``HGCommand``
  704. ``hg`` command-line tool to use if source tree is managed by Mercurial.
  705. * `CTest Script`_ variable: :variable:`CTEST_HG_COMMAND`
  706. * :module:`CTest` module variable: none
  707. ``HGUpdateOptions``
  708. Command-line options to the ``HGCommand`` when updating the source.
  709. * `CTest Script`_ variable: :variable:`CTEST_HG_UPDATE_OPTIONS`
  710. * :module:`CTest` module variable: none
  711. ``P4Client``
  712. Value of the ``-c`` option to the ``P4Command``.
  713. * `CTest Script`_ variable: :variable:`CTEST_P4_CLIENT`
  714. * :module:`CTest` module variable: ``CTEST_P4_CLIENT``
  715. ``P4Command``
  716. ``p4`` command-line tool to use if source tree is managed by Perforce.
  717. * `CTest Script`_ variable: :variable:`CTEST_P4_COMMAND`
  718. * :module:`CTest` module variable: ``P4COMMAND``
  719. ``P4Options``
  720. Command-line options to the ``P4Command`` for all invocations.
  721. * `CTest Script`_ variable: :variable:`CTEST_P4_OPTIONS`
  722. * :module:`CTest` module variable: ``CTEST_P4_OPTIONS``
  723. ``P4UpdateCustom``
  724. Specify a custom command line (as a semicolon-separated list) to run
  725. in the source tree (Perforce tree) to update it instead of running
  726. the ``P4Command``.
  727. * `CTest Script`_ variable: none
  728. * :module:`CTest` module variable: ``CTEST_P4_UPDATE_CUSTOM``
  729. ``P4UpdateOptions``
  730. Command-line options to the ``P4Command`` when updating the source.
  731. * `CTest Script`_ variable: :variable:`CTEST_P4_UPDATE_OPTIONS`
  732. * :module:`CTest` module variable: ``CTEST_P4_UPDATE_OPTIONS``
  733. ``SVNCommand``
  734. ``svn`` command-line tool to use if source tree is managed by Subversion.
  735. * `CTest Script`_ variable: :variable:`CTEST_SVN_COMMAND`
  736. * :module:`CTest` module variable: ``SVNCOMMAND``
  737. ``SVNOptions``
  738. Command-line options to the ``SVNCommand`` for all invocations.
  739. * `CTest Script`_ variable: :variable:`CTEST_SVN_OPTIONS`
  740. * :module:`CTest` module variable: ``CTEST_SVN_OPTIONS``
  741. ``SVNUpdateOptions``
  742. Command-line options to the ``SVNCommand`` when updating the source.
  743. * `CTest Script`_ variable: :variable:`CTEST_SVN_UPDATE_OPTIONS`
  744. * :module:`CTest` module variable: ``SVN_UPDATE_OPTIONS``
  745. ``UpdateCommand``
  746. Specify the version-control command-line tool to use without
  747. detecting the VCS that manages the source tree.
  748. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_COMMAND`
  749. * :module:`CTest` module variable: ``<VCS>COMMAND``
  750. when ``UPDATE_TYPE`` is ``<vcs>``, else ``UPDATE_COMMAND``
  751. ``UpdateOptions``
  752. Command-line options to the ``UpdateCommand``.
  753. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_OPTIONS`
  754. * :module:`CTest` module variable: ``<VCS>_UPDATE_OPTIONS``
  755. when ``UPDATE_TYPE`` is ``<vcs>``, else ``UPDATE_OPTIONS``
  756. ``UpdateType``
  757. Specify the version-control system that manages the source
  758. tree if it cannot be detected automatically.
  759. The value may be ``bzr``, ``cvs``, ``git``, ``hg``,
  760. ``p4``, or ``svn``.
  761. * `CTest Script`_ variable: none, detected from source tree
  762. * :module:`CTest` module variable: ``UPDATE_TYPE`` if set,
  763. else ``CTEST_UPDATE_TYPE``
  764. .. _`UpdateVersionOnly`:
  765. ``UpdateVersionOnly``
  766. Specify that you want the version control update command to only
  767. discover the current version that is checked out, and not to update
  768. to a different version.
  769. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_VERSION_ONLY`
  770. .. _`UpdateVersionOverride`:
  771. ``UpdateVersionOverride``
  772. Specify the current version of your source tree.
  773. When this variable is set to a non-empty string, CTest will report the value
  774. you specified rather than using the update command to discover the current
  775. version that is checked out. Use of this variable supersedes
  776. ``UpdateVersionOnly``. Like ``UpdateVersionOnly``, using this variable tells
  777. CTest not to update the source tree to a different version.
  778. * `CTest Script`_ variable: :variable:`CTEST_UPDATE_VERSION_OVERRIDE`
  779. Additional configuration settings include:
  780. ``NightlyStartTime``
  781. In the ``Nightly`` dashboard mode, specify the "nightly start time".
  782. With centralized version control systems (``cvs`` and ``svn``),
  783. the ``Update`` step checks out the version of the software as of
  784. this time so that multiple clients choose a common version to test.
  785. This is not well-defined in distributed version-control systems so
  786. the setting is ignored.
  787. * `CTest Script`_ variable: :variable:`CTEST_NIGHTLY_START_TIME`
  788. * :module:`CTest` module variable: ``NIGHTLY_START_TIME`` if set,
  789. else ``CTEST_NIGHTLY_START_TIME``
  790. .. _`CTest Configure Step`:
  791. CTest Configure Step
  792. --------------------
  793. In a `CTest Script`_, the :command:`ctest_configure` command runs this step.
  794. Arguments to the command may specify some of the step settings.
  795. Configuration settings include:
  796. ``ConfigureCommand``
  797. Command-line to launch the software configuration process.
  798. It will be executed in the location specified by the
  799. ``BuildDirectory`` setting.
  800. * `CTest Script`_ variable: :variable:`CTEST_CONFIGURE_COMMAND`
  801. * :module:`CTest` module variable: :variable:`CMAKE_COMMAND`
  802. followed by :variable:`PROJECT_SOURCE_DIR`
  803. ``LabelsForSubprojects``
  804. Specify a semicolon-separated list of labels that will be treated as
  805. subprojects. This mapping will be passed on to CDash when configure, test or
  806. build results are submitted.
  807. * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
  808. * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
  809. See `Label and Subproject Summary`_.
  810. .. _`CTest Build Step`:
  811. CTest Build Step
  812. ----------------
  813. In a `CTest Script`_, the :command:`ctest_build` command runs this step.
  814. Arguments to the command may specify some of the step settings.
  815. Configuration settings include:
  816. ``DefaultCTestConfigurationType``
  817. When the build system to be launched allows build-time selection
  818. of the configuration (e.g. ``Debug``, ``Release``), this specifies
  819. the default configuration to be built when no :option:`-C <ctest -C>`
  820. option is given to the :program:`ctest` command. The value will be substituted
  821. into the value of ``MakeCommand`` to replace the literal string
  822. ``${CTEST_CONFIGURATION_TYPE}`` if it appears.
  823. * `CTest Script`_ variable: :variable:`CTEST_CONFIGURATION_TYPE`
  824. * :module:`CTest` module variable: ``DEFAULT_CTEST_CONFIGURATION_TYPE``,
  825. initialized by the :envvar:`CMAKE_CONFIG_TYPE` environment variable
  826. ``LabelsForSubprojects``
  827. Specify a semicolon-separated list of labels that will be treated as
  828. subprojects. This mapping will be passed on to CDash when configure, test or
  829. build results are submitted.
  830. * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
  831. * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
  832. See `Label and Subproject Summary`_.
  833. ``MakeCommand``
  834. Command-line to launch the software build process.
  835. It will be executed in the location specified by the
  836. ``BuildDirectory`` setting.
  837. * `CTest Script`_ variable: :variable:`CTEST_BUILD_COMMAND`
  838. * :module:`CTest` module variable: ``MAKECOMMAND``,
  839. initialized by the :command:`build_command` command
  840. ``UseLaunchers``
  841. For build trees generated by CMake using one of the
  842. :ref:`Makefile Generators` or the :generator:`Ninja`
  843. generator, specify whether the
  844. ``CTEST_USE_LAUNCHERS`` feature is enabled by the
  845. :module:`CTestUseLaunchers` module (also included by the
  846. :module:`CTest` module). When enabled, the generated build
  847. system wraps each invocation of the compiler, linker, or
  848. custom command line with a "launcher" that communicates
  849. with CTest via environment variables and files to report
  850. granular build warning and error information. Otherwise,
  851. CTest must "scrape" the build output log for diagnostics.
  852. * `CTest Script`_ variable: :variable:`CTEST_USE_LAUNCHERS`
  853. * :module:`CTest` module variable: ``CTEST_USE_LAUNCHERS``
  854. .. _`CTest Test Step`:
  855. CTest Test Step
  856. ---------------
  857. In a `CTest Script`_, the :command:`ctest_test` command runs this step.
  858. Arguments to the command may specify some of the step settings.
  859. Configuration settings include:
  860. ``ResourceSpecFile``
  861. Specify a
  862. :ref:`resource specification file <ctest-resource-specification-file>`.
  863. * `CTest Script`_ variable: :variable:`CTEST_RESOURCE_SPEC_FILE`
  864. * :module:`CTest` module variable: ``CTEST_RESOURCE_SPEC_FILE``
  865. See :ref:`ctest-resource-allocation` for more information.
  866. ``LabelsForSubprojects``
  867. Specify a semicolon-separated list of labels that will be treated as
  868. subprojects. This mapping will be passed on to CDash when configure, test or
  869. build results are submitted.
  870. * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
  871. * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
  872. See `Label and Subproject Summary`_.
  873. ``TestLoad``
  874. While running tests in parallel (e.g. with :option:`-j <ctest -j>`),
  875. try not to start tests when they may cause the CPU load to pass above
  876. a given threshold.
  877. * `CTest Script`_ variable: :variable:`CTEST_TEST_LOAD`
  878. * :module:`CTest` module variable: ``CTEST_TEST_LOAD``
  879. ``TimeOut``
  880. The default timeout for each test if not specified by the
  881. :prop_test:`TIMEOUT` test property or the
  882. :option:`--timeout <ctest --timeout>` flag.
  883. * `CTest Script`_ variable: :variable:`CTEST_TEST_TIMEOUT`
  884. * :module:`CTest` module variable: ``DART_TESTING_TIMEOUT``
  885. To report extra test values to CDash, see :ref:`Additional Test Measurements`.
  886. .. _`CTest Coverage Step`:
  887. CTest Coverage Step
  888. -------------------
  889. In a `CTest Script`_, the :command:`ctest_coverage` command runs this step.
  890. Arguments to the command may specify some of the step settings.
  891. Configuration settings include:
  892. ``CoverageCommand``
  893. Command-line tool to perform software coverage analysis.
  894. It will be executed in the location specified by the
  895. ``BuildDirectory`` setting.
  896. * `CTest Script`_ variable: :variable:`CTEST_COVERAGE_COMMAND`
  897. * :module:`CTest` module variable: ``COVERAGE_COMMAND``
  898. ``CoverageExtraFlags``
  899. Specify command-line options to the ``CoverageCommand`` tool.
  900. * `CTest Script`_ variable: :variable:`CTEST_COVERAGE_EXTRA_FLAGS`
  901. * :module:`CTest` module variable: ``COVERAGE_EXTRA_FLAGS``
  902. These options are the first arguments passed to ``CoverageCommand``.
  903. .. _`CTest MemCheck Step`:
  904. CTest MemCheck Step
  905. -------------------
  906. In a `CTest Script`_, the :command:`ctest_memcheck` command runs this step.
  907. Arguments to the command may specify some of the step settings.
  908. Configuration settings include:
  909. ``MemoryCheckCommand``
  910. Command-line tool to perform dynamic analysis. Test command lines
  911. will be launched through this tool.
  912. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND`
  913. * :module:`CTest` module variable: ``MEMORYCHECK_COMMAND``
  914. ``MemoryCheckCommandOptions``
  915. Specify command-line options to the ``MemoryCheckCommand`` tool.
  916. They will be placed prior to the test command line.
  917. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND_OPTIONS`
  918. * :module:`CTest` module variable: ``MEMORYCHECK_COMMAND_OPTIONS``
  919. ``MemoryCheckType``
  920. Specify the type of memory checking to perform.
  921. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_TYPE`
  922. * :module:`CTest` module variable: ``MEMORYCHECK_TYPE``
  923. ``MemoryCheckSanitizerOptions``
  924. Specify options to sanitizers when running with a sanitize-enabled build.
  925. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_SANITIZER_OPTIONS`
  926. * :module:`CTest` module variable: ``MEMORYCHECK_SANITIZER_OPTIONS``
  927. ``MemoryCheckSuppressionFile``
  928. Specify a file containing suppression rules for the
  929. ``MemoryCheckCommand`` tool. It will be passed with options
  930. appropriate to the tool.
  931. * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_SUPPRESSIONS_FILE`
  932. * :module:`CTest` module variable: ``MEMORYCHECK_SUPPRESSIONS_FILE``
  933. Additional configuration settings include:
  934. ``BoundsCheckerCommand``
  935. Specify a ``MemoryCheckCommand`` that is known to be command-line
  936. compatible with Bounds Checker.
  937. * `CTest Script`_ variable: none
  938. * :module:`CTest` module variable: none
  939. ``PurifyCommand``
  940. Specify a ``MemoryCheckCommand`` that is known to be command-line
  941. compatible with Purify.
  942. * `CTest Script`_ variable: none
  943. * :module:`CTest` module variable: ``PURIFYCOMMAND``
  944. ``ValgrindCommand``
  945. Specify a ``MemoryCheckCommand`` that is known to be command-line
  946. compatible with Valgrind.
  947. * `CTest Script`_ variable: none
  948. * :module:`CTest` module variable: ``VALGRIND_COMMAND``
  949. ``ValgrindCommandOptions``
  950. Specify command-line options to the ``ValgrindCommand`` tool.
  951. They will be placed prior to the test command line.
  952. * `CTest Script`_ variable: none
  953. * :module:`CTest` module variable: ``VALGRIND_COMMAND_OPTIONS``
  954. ``DrMemoryCommand``
  955. Specify a ``MemoryCheckCommand`` that is known to be a command-line
  956. compatible with DrMemory.
  957. * `CTest Script`_ variable: none
  958. * :module:`CTest` module variable: ``DRMEMORY_COMMAND``
  959. ``DrMemoryCommandOptions``
  960. Specify command-line options to the ``DrMemoryCommand`` tool.
  961. They will be placed prior to the test command line.
  962. * `CTest Script`_ variable: none
  963. * :module:`CTest` module variable: ``DRMEMORY_COMMAND_OPTIONS``
  964. ``CudaSanitizerCommand``
  965. Specify a ``MemoryCheckCommand`` that is known to be a command-line
  966. compatible with cuda-memcheck or compute-sanitizer.
  967. * `CTest Script`_ variable: none
  968. * :module:`CTest` module variable: ``CUDA_SANITIZER_COMMAND``
  969. ``CudaSanitizerCommandOptions``
  970. Specify command-line options to the ``CudaSanitizerCommand`` tool.
  971. They will be placed prior to the test command line.
  972. * `CTest Script`_ variable: none
  973. * :module:`CTest` module variable: ``CUDA_SANITIZER_COMMAND_OPTIONS``
  974. .. _`CTest Submit Step`:
  975. CTest Submit Step
  976. -----------------
  977. In a `CTest Script`_, the :command:`ctest_submit` command runs this step.
  978. Arguments to the command may specify some of the step settings.
  979. Configuration settings include:
  980. ``BuildName``
  981. Describe the dashboard client platform with a short string.
  982. (Operating system, compiler, etc.)
  983. * `CTest Script`_ variable: :variable:`CTEST_BUILD_NAME`
  984. * :module:`CTest` module variable: ``BUILDNAME``
  985. ``CDashVersion``
  986. Legacy option. Not used.
  987. * `CTest Script`_ variable: none, detected from server
  988. * :module:`CTest` module variable: ``CTEST_CDASH_VERSION``
  989. ``CTestSubmitRetryCount``
  990. Specify a number of attempts to retry submission on network failure.
  991. * `CTest Script`_ variable: none,
  992. use the :command:`ctest_submit` ``RETRY_COUNT`` option.
  993. * :module:`CTest` module variable: ``CTEST_SUBMIT_RETRY_COUNT``
  994. ``CTestSubmitRetryDelay``
  995. Specify a delay before retrying submission on network failure.
  996. * `CTest Script`_ variable: none,
  997. use the :command:`ctest_submit` ``RETRY_DELAY`` option.
  998. * :module:`CTest` module variable: ``CTEST_SUBMIT_RETRY_DELAY``
  999. ``CurlOptions``
  1000. .. deprecated:: 3.30
  1001. Use ``TLSVerify`` instead.
  1002. Specify a semicolon-separated list of options to control the
  1003. Curl library that CTest uses internally to connect to the
  1004. server.
  1005. * `CTest Script`_ variable: :variable:`CTEST_CURL_OPTIONS`
  1006. * :module:`CTest` module variable: ``CTEST_CURL_OPTIONS``
  1007. Possible options are:
  1008. ``CURLOPT_SSL_VERIFYPEER_OFF``
  1009. Disable the ``CURLOPT_SSL_VERIFYPEER`` curl option.
  1010. ``CURLOPT_SSL_VERIFYHOST_OFF``
  1011. Disable the ``CURLOPT_SSL_VERIFYHOST`` curl option.
  1012. ``DropLocation``
  1013. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  1014. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  1015. ``DropLocation``.
  1016. * `CTest Script`_ variable: :variable:`CTEST_DROP_LOCATION`
  1017. * :module:`CTest` module variable: ``DROP_LOCATION`` if set,
  1018. else ``CTEST_DROP_LOCATION``
  1019. ``DropMethod``
  1020. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  1021. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  1022. ``DropLocation``.
  1023. * `CTest Script`_ variable: :variable:`CTEST_DROP_METHOD`
  1024. * :module:`CTest` module variable: ``DROP_METHOD`` if set,
  1025. else ``CTEST_DROP_METHOD``
  1026. ``DropSite``
  1027. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  1028. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  1029. ``DropLocation``.
  1030. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE`
  1031. * :module:`CTest` module variable: ``DROP_SITE`` if set,
  1032. else ``CTEST_DROP_SITE``
  1033. ``DropSitePassword``
  1034. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  1035. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  1036. ``DropLocation``.
  1037. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_PASSWORD`
  1038. * :module:`CTest` module variable: ``DROP_SITE_PASSWORD`` if set,
  1039. else ``CTEST_DROP_SITE_PASSWORD``
  1040. ``DropSiteUser``
  1041. Legacy option. When ``SubmitURL`` is not set, it is constructed from
  1042. ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
  1043. ``DropLocation``.
  1044. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_USER`
  1045. * :module:`CTest` module variable: ``DROP_SITE_USER`` if set,
  1046. else ``CTEST_DROP_SITE_USER``
  1047. ``IsCDash``
  1048. Legacy option. Not used.
  1049. * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_CDASH`
  1050. * :module:`CTest` module variable: ``CTEST_DROP_SITE_CDASH``
  1051. ``ScpCommand``
  1052. Legacy option. Not used.
  1053. * `CTest Script`_ variable: :variable:`CTEST_SCP_COMMAND`
  1054. * :module:`CTest` module variable: ``SCPCOMMAND``
  1055. ``Site``
  1056. Describe the dashboard client host site with a short string.
  1057. (Hostname, domain, etc.)
  1058. * `CTest Script`_ variable: :variable:`CTEST_SITE`
  1059. * :module:`CTest` module variable: ``SITE``,
  1060. initialized by the :command:`site_name` command
  1061. ``SubmitURL``
  1062. The ``http`` or ``https`` URL of the dashboard server to send the submission
  1063. to.
  1064. * `CTest Script`_ variable: :variable:`CTEST_SUBMIT_URL`
  1065. * :module:`CTest` module variable: ``SUBMIT_URL`` if set,
  1066. else ``CTEST_SUBMIT_URL``
  1067. ``SubmitInactivityTimeout``
  1068. The time to wait for the submission after which it is canceled
  1069. if not completed. Specify a zero value to disable timeout.
  1070. * `CTest Script`_ variable: :variable:`CTEST_SUBMIT_INACTIVITY_TIMEOUT`
  1071. * :module:`CTest` module variable: ``CTEST_SUBMIT_INACTIVITY_TIMEOUT``
  1072. ``TLSVersion``
  1073. .. versionadded:: 3.30
  1074. Specify a minimum TLS version allowed when submitting to a dashboard
  1075. via ``https://`` URLs.
  1076. * `CTest Script`_ variable: :variable:`CTEST_TLS_VERSION`
  1077. * :module:`CTest` module variable: ``CTEST_TLS_VERSION``
  1078. .. versionchanged:: 3.31
  1079. The default is TLS 1.2.
  1080. Previously, no minimum version was enforced by default.
  1081. ``TLSVerify``
  1082. .. versionadded:: 3.30
  1083. Specify a boolean value indicating whether to verify the server
  1084. certificate when submitting to a dashboard via ``https://`` URLs.
  1085. * `CTest Script`_ variable: :variable:`CTEST_TLS_VERIFY`
  1086. * :module:`CTest` module variable: ``CTEST_TLS_VERIFY``
  1087. .. versionchanged:: 3.31
  1088. The default is on. Previously, the default was off.
  1089. Users may set the :envvar:`CMAKE_TLS_VERIFY` environment
  1090. variable to ``0`` to restore the old default.
  1091. ``TriggerSite``
  1092. Legacy option. Not used.
  1093. * `CTest Script`_ variable: :variable:`CTEST_TRIGGER_SITE`
  1094. * :module:`CTest` module variable: ``TRIGGER_SITE`` if set,
  1095. else ``CTEST_TRIGGER_SITE``
  1096. .. _`Show as JSON Object Model`:
  1097. Show as JSON Object Model
  1098. =========================
  1099. .. versionadded:: 3.14
  1100. When the ``--show-only=json-v1`` command line option is given, the test
  1101. information is output in JSON format. Version 1.0 of the JSON object
  1102. model is defined as follows:
  1103. ``kind``
  1104. The string "ctestInfo".
  1105. ``version``
  1106. A JSON object specifying the version components. Its members are:
  1107. ``major``
  1108. A positive integer specifying the major version component
  1109. of the JSON object model.
  1110. ``minor``
  1111. A non-negative integer specifying the minor version component
  1112. of the JSON object model.
  1113. ``backtraceGraph``
  1114. JSON object representing backtrace information with the
  1115. following members:
  1116. ``commands``
  1117. List of command names.
  1118. ``files``
  1119. List of file names.
  1120. ``nodes``
  1121. List of node JSON objects with members:
  1122. ``command``
  1123. An optional member present when the node represents a command
  1124. invocation within the file. The value is an unsigned integer 0-based
  1125. index into the ``commands`` member of the ``backtraceGraph``.
  1126. ``file``
  1127. An unsigned integer 0-based index into the ``files`` member of the
  1128. ``backtraceGraph``.
  1129. ``line``
  1130. An optional member present when the node represents a line within
  1131. the file. The value is an unsigned integer 1-based line number
  1132. in the file where the backtrace was added.
  1133. ``parent``
  1134. An optional member present when the node is not the bottom of the
  1135. call stack. The value is an unsigned integer 0-based index into the
  1136. ``nodes`` member of the ``backtraceGraph`` representing the parent
  1137. in the graph.
  1138. ``tests``
  1139. A JSON array listing information about each test. Each entry
  1140. is a JSON object with members:
  1141. ``name``
  1142. Test name. This cannot be empty.
  1143. ``config``
  1144. Optional field specifying the configuration for which the test will run.
  1145. This will always match the :option:`-C <ctest -C>` option specified on the
  1146. ``ctest`` command line. If no such option was given, this field will not
  1147. be present.
  1148. ``command``
  1149. Optional array where the first element is the test command and the
  1150. remaining elements are the command arguments. Normally, this field should
  1151. be present and non-empty, but in certain corner cases involving generator
  1152. expressions, it is possible for a test to have no command and therefore
  1153. this field can be missing.
  1154. ``backtrace``
  1155. Index into the ``nodes`` member of the ``backtraceGraph``.
  1156. ``properties``
  1157. Optional array of test properties.
  1158. Each array item will be a JSON object with the following members:
  1159. ``name``
  1160. The name of the test property. This cannot be empty.
  1161. ``value``
  1162. The property value, which can be a string, a number, a boolean, or an
  1163. array of strings.
  1164. .. versionadded:: 4.1
  1165. The JSON output format is described in machine-readable form by
  1166. :download:`this JSON schema </manual/ctest/show-only-schema.json>`.
  1167. .. _`ctest-resource-allocation`:
  1168. Resource Allocation
  1169. ===================
  1170. CTest provides a mechanism for tests to specify the resources that they need
  1171. in a fine-grained way, and for users to specify the resources available on
  1172. the running machine. This allows CTest to internally keep track of which
  1173. resources are in use and which are free, scheduling tests in a way that
  1174. prevents them from trying to claim resources that are not available.
  1175. When the resource allocation feature is used, CTest will not oversubscribe
  1176. resources. For example, if a resource has 8 slots, CTest will not run tests
  1177. that collectively use more than 8 slots at a time. This has the effect of
  1178. limiting how many tests can run at any given time, even if a high ``-j``
  1179. argument is used, if those tests all use some slots from the same resource.
  1180. In addition, it means that a single test that uses more of a resource than is
  1181. available on a machine will not run at all (and will be reported as
  1182. ``Not Run``).
  1183. A common use case for this feature is for tests that require the use of a GPU.
  1184. Multiple tests can simultaneously allocate memory from a GPU, but if too many
  1185. tests try to do this at once, some of them will fail to allocate, resulting in
  1186. a failed test, even though the test would have succeeded if it had the memory
  1187. it needed. By using the resource allocation feature, each test can specify how
  1188. much memory it requires from a GPU, allowing CTest to schedule tests in a way
  1189. that running several of these tests at once does not exhaust the GPU's memory
  1190. pool.
  1191. Please note that CTest has no concept of what a GPU is or how much memory it
  1192. has. It does not have any way of communicating with a GPU to retrieve this
  1193. information or perform any memory management, although the project can define
  1194. a test that provides details about the test machine (see
  1195. :ref:`ctest-resource-dynamically-generated-spec-file`).
  1196. CTest keeps track of a list of abstract resource types, each of which has a
  1197. certain number of slots available for tests to use. Each test specifies the
  1198. number of slots that it requires from a certain resource, and CTest then
  1199. schedules them in a way that prevents the total number of slots in use from
  1200. exceeding the listed capacity. When a test is executed, and slots from a
  1201. resource are allocated to that test, tests may assume that they have exclusive
  1202. use of those slots for the duration of the test's process.
  1203. The CTest resource allocation feature consists of at least two inputs:
  1204. * The :ref:`resource specification file <ctest-resource-specification-file>`,
  1205. described below, which describes the resources available on the system.
  1206. * The :prop_test:`RESOURCE_GROUPS` property of tests, which describes the
  1207. resources required by the test.
  1208. When CTest runs a test, the resources allocated to that test are passed in the
  1209. form of a set of
  1210. :ref:`environment variables <ctest-resource-environment-variables>` as
  1211. described below. Using this information to decide which resource to connect to
  1212. is left to the test writer.
  1213. The ``RESOURCE_GROUPS`` property tells CTest what resources a test expects
  1214. to use grouped in a way meaningful to the test. The test itself must read
  1215. the :ref:`environment variables <ctest-resource-environment-variables>` to
  1216. determine which resources have been allocated to each group. For example,
  1217. each group may correspond to a process the test will spawn when executed.
  1218. Note that even if a test specifies a ``RESOURCE_GROUPS`` property, it is still
  1219. possible for that to test to run without any resource allocation (and without
  1220. the corresponding
  1221. :ref:`environment variables <ctest-resource-environment-variables>`)
  1222. if the user does not pass a resource specification file. Passing this file,
  1223. either through the ``--resource-spec-file`` command-line argument or the
  1224. ``RESOURCE_SPEC_FILE`` argument to :command:`ctest_test`, is what activates the
  1225. resource allocation feature. Tests should check the
  1226. ``CTEST_RESOURCE_GROUP_COUNT`` environment variable to find out whether or not
  1227. resource allocation is activated. This variable will always (and only) be
  1228. defined if resource allocation is activated. If resource allocation is not
  1229. activated, then the ``CTEST_RESOURCE_GROUP_COUNT`` variable will not exist,
  1230. even if it exists for the parent :program:`ctest` process. If a test absolutely must
  1231. have resource allocation, then it can return a failing exit code or use the
  1232. :prop_test:`SKIP_RETURN_CODE` or :prop_test:`SKIP_REGULAR_EXPRESSION`
  1233. properties to indicate a skipped test.
  1234. .. _`ctest-resource-specification-file`:
  1235. Resource Specification File
  1236. ---------------------------
  1237. The resource specification file is a JSON file which is passed to CTest in one
  1238. of a number of ways. It can be specified on the command line with the
  1239. :option:`ctest --resource-spec-file` option, it can be given using the
  1240. ``RESOURCE_SPEC_FILE`` argument of :command:`ctest_test`, or it can be
  1241. generated dynamically as part of test execution (see
  1242. :ref:`ctest-resource-dynamically-generated-spec-file`).
  1243. If a dashboard script is used and ``RESOURCE_SPEC_FILE`` is not specified, the
  1244. value of :variable:`CTEST_RESOURCE_SPEC_FILE` in the dashboard script is used
  1245. instead. If :option:`--resource-spec-file <ctest --resource-spec-file>`,
  1246. ``RESOURCE_SPEC_FILE``, and :variable:`CTEST_RESOURCE_SPEC_FILE` in the
  1247. dashboard script are not specified, the value of
  1248. :variable:`CTEST_RESOURCE_SPEC_FILE` in the CMake build is used instead.
  1249. If none of these are specified, no resource spec file is used.
  1250. The resource specification file must be a JSON object. All examples in this
  1251. document assume the following resource specification file:
  1252. .. code-block:: json
  1253. {
  1254. "version": {
  1255. "major": 1,
  1256. "minor": 0
  1257. },
  1258. "local": [
  1259. {
  1260. "gpus": [
  1261. {
  1262. "id": "0",
  1263. "slots": 2
  1264. },
  1265. {
  1266. "id": "1",
  1267. "slots": 4
  1268. },
  1269. {
  1270. "id": "2",
  1271. "slots": 2
  1272. },
  1273. {
  1274. "id": "3"
  1275. }
  1276. ],
  1277. "crypto_chips": [
  1278. {
  1279. "id": "card0",
  1280. "slots": 4
  1281. }
  1282. ]
  1283. }
  1284. ]
  1285. }
  1286. The members are:
  1287. ``version``
  1288. An object containing a ``major`` integer field and a ``minor`` integer field.
  1289. Currently, the only supported version is major ``1``, minor ``0``. Any other
  1290. value is an error.
  1291. ``local``
  1292. A JSON array of resource sets present on the system. Currently, this array
  1293. is restricted to being of size 1.
  1294. Each array element is a JSON object with members whose names are equal to the
  1295. desired resource types, such as ``gpus``. These names must start with a
  1296. lowercase letter or an underscore, and subsequent characters can be a
  1297. lowercase letter, a digit, or an underscore. Uppercase letters are not
  1298. allowed, because certain platforms have case-insensitive environment
  1299. variables. See the `Environment Variables`_ section below for
  1300. more information. It is recommended that the resource type name be the plural
  1301. of a noun, such as ``gpus`` or ``crypto_chips`` (and not ``gpu`` or
  1302. ``crypto_chip``.)
  1303. Please note that the names ``gpus`` and ``crypto_chips`` are just examples,
  1304. and CTest does not interpret them in any way. You are free to make up any
  1305. resource type you want to meet your own requirements.
  1306. The value for each resource type is a JSON array consisting of JSON objects,
  1307. each of which describe a specific instance of the specified resource. These
  1308. objects have the following members:
  1309. ``id``
  1310. A string consisting of an identifier for the resource. Each character in
  1311. the identifier can be a lowercase letter, a digit, or an underscore.
  1312. Uppercase letters are not allowed.
  1313. Identifiers must be unique within a resource type. However, they do not
  1314. have to be unique across resource types. For example, it is valid to have a
  1315. ``gpus`` resource named ``0`` and a ``crypto_chips`` resource named ``0``,
  1316. but not two ``gpus`` resources both named ``0``.
  1317. Please note that the IDs ``0``, ``1``, ``2``, ``3``, and ``card0`` are just
  1318. examples, and CTest does not interpret them in any way. You are free to
  1319. make up any IDs you want to meet your own requirements.
  1320. ``slots``
  1321. An optional unsigned number specifying the number of slots available on the
  1322. resource. For example, this could be megabytes of RAM on a GPU, or
  1323. cryptography units available on a cryptography chip. If ``slots`` is not
  1324. specified, a default value of ``1`` is assumed.
  1325. In the example file above, there are four GPUs with ID's 0 through 3. GPU 0 has
  1326. 2 slots, GPU 1 has 4, GPU 2 has 2, and GPU 3 has a default of 1 slot. There is
  1327. also one cryptography chip with 4 slots.
  1328. ``RESOURCE_GROUPS`` Property
  1329. ----------------------------
  1330. See :prop_test:`RESOURCE_GROUPS` for a description of this property.
  1331. .. _`ctest-resource-environment-variables`:
  1332. Environment Variables
  1333. ---------------------
  1334. Once CTest has decided which resources to allocate to a test, it passes this
  1335. information to the test executable as a series of environment variables. For
  1336. each example below, we will assume that the test in question has a
  1337. :prop_test:`RESOURCE_GROUPS` property of
  1338. ``2,gpus:2;gpus:4,gpus:1,crypto_chips:2``.
  1339. The following variables are passed to the test process:
  1340. .. envvar:: CTEST_RESOURCE_GROUP_COUNT
  1341. The total number of groups specified by the :prop_test:`RESOURCE_GROUPS`
  1342. property. For example:
  1343. * ``CTEST_RESOURCE_GROUP_COUNT=3``
  1344. This variable will only be defined if :manual:`ctest(1)` has been given a
  1345. ``--resource-spec-file``, or if :command:`ctest_test` has been given a
  1346. ``RESOURCE_SPEC_FILE``. If no resource specification file has been given,
  1347. this variable will not be defined.
  1348. .. envvar:: CTEST_RESOURCE_GROUP_<num>
  1349. The list of resource types allocated to each group, with each item
  1350. separated by a comma. ``<num>`` is a number from zero to
  1351. ``CTEST_RESOURCE_GROUP_COUNT`` minus one. ``CTEST_RESOURCE_GROUP_<num>``
  1352. is defined for each ``<num>`` in this range. For example:
  1353. * ``CTEST_RESOURCE_GROUP_0=gpus``
  1354. * ``CTEST_RESOURCE_GROUP_1=gpus``
  1355. * ``CTEST_RESOURCE_GROUP_2=crypto_chips,gpus``
  1356. .. envvar:: CTEST_RESOURCE_GROUP_<num>_<resource-type>
  1357. The list of resource IDs and number of slots from each ID allocated to each
  1358. group for a given resource type. This variable consists of a series of
  1359. pairs, each pair separated by a semicolon, and with the two items in the pair
  1360. separated by a comma. The first item in each pair is ``id:`` followed by the
  1361. ID of a resource of type ``<resource-type>``, and the second item is
  1362. ``slots:`` followed by the number of slots from that resource allocated to
  1363. the given group. For example:
  1364. * ``CTEST_RESOURCE_GROUP_0_GPUS=id:0,slots:2``
  1365. * ``CTEST_RESOURCE_GROUP_1_GPUS=id:2,slots:2``
  1366. * ``CTEST_RESOURCE_GROUP_2_GPUS=id:1,slots:4;id:3,slots:1``
  1367. * ``CTEST_RESOURCE_GROUP_2_CRYPTO_CHIPS=id:card0,slots:2``
  1368. In this example, group 0 gets 2 slots from GPU ``0``, group 1 gets 2 slots
  1369. from GPU ``2``, and group 2 gets 4 slots from GPU ``1``, 1 slot from GPU
  1370. ``3``, and 2 slots from cryptography chip ``card0``.
  1371. ``<num>`` is a number from zero to ``CTEST_RESOURCE_GROUP_COUNT`` minus one.
  1372. ``<resource-type>`` is the name of a resource type, converted to uppercase.
  1373. ``CTEST_RESOURCE_GROUP_<num>_<resource-type>`` is defined for the product
  1374. of each ``<num>`` in the range listed above and each resource type listed in
  1375. ``CTEST_RESOURCE_GROUP_<num>``.
  1376. Because some platforms have case-insensitive names for environment variables,
  1377. the names of resource types may not clash in a case-insensitive environment.
  1378. Because of this, for the sake of simplicity, all resource types must be
  1379. listed in all lowercase in the
  1380. :ref:`resource specification file <ctest-resource-specification-file>` and
  1381. in the :prop_test:`RESOURCE_GROUPS` property, and they are converted to all
  1382. uppercase in the ``CTEST_RESOURCE_GROUP_<num>_<resource-type>`` environment
  1383. variable.
  1384. .. _`ctest-resource-dynamically-generated-spec-file`:
  1385. Dynamically-Generated Resource Specification File
  1386. -------------------------------------------------
  1387. .. versionadded:: 3.28
  1388. A project may optionally specify a single test which will be used to
  1389. dynamically generate the resource specification file that CTest will use for
  1390. scheduling tests that use resources. The test that generates the file must
  1391. have the :prop_test:`GENERATED_RESOURCE_SPEC_FILE` property set, and must have
  1392. exactly one fixture in its :prop_test:`FIXTURES_SETUP` property. This fixture
  1393. is considered by CTest to have special meaning: it's the fixture that generates
  1394. the resource spec file. The fixture may have any name. If such a fixture
  1395. exists, all tests that have :prop_test:`RESOURCE_GROUPS` set must have the
  1396. fixture in their :prop_test:`FIXTURES_REQUIRED`, and a resource spec file may
  1397. not be specified with the ``--resource-spec-file`` argument or the
  1398. :variable:`CTEST_RESOURCE_SPEC_FILE` variable.
  1399. .. _`ctest-job-server-integration`:
  1400. Job Server Integration
  1401. ======================
  1402. .. versionadded:: 3.29
  1403. On POSIX systems, when running under the context of a `Job Server`_,
  1404. CTest shares its job slots. This is independent of the :prop_test:`PROCESSORS`
  1405. test property, which still counts against CTest's :option:`-j <ctest -j>`
  1406. parallel level. CTest acquires exactly one token from the job server before
  1407. running each test, and returns it when the test finishes.
  1408. For example, consider the ``Makefile``:
  1409. .. literalinclude:: CTEST_EXAMPLE_MAKEFILE_JOB_SERVER.make
  1410. :language: make
  1411. When invoked via ``make -j 2 test``, ``ctest`` connects to the job server,
  1412. acquires a token for each test, and runs at most 2 tests concurrently.
  1413. On Windows systems, job server integration is not yet implemented.
  1414. .. _`Job Server`: https://www.gnu.org/software/make/manual/html_node/Job-Slots.html
  1415. See Also
  1416. ========
  1417. .. include:: include/LINKS.rst