ctest.1.rst 66 KB

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