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