blob: fbe1a9ab1843f950fd61efe4b20da40862f4e6f7 [file] [log] [blame]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00001lit - LLVM Integrated Tester
2============================
3
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00004SYNOPSIS
5--------
6
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +00007:program:`lit` [*options*] [*tests*]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00008
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00009DESCRIPTION
10-----------
11
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000012:program:`lit` is a portable tool for executing LLVM and Clang style test
13suites, summarizing their results, and providing indication of failures.
14:program:`lit` is designed to be a lightweight testing tool with as simple a
15user interface as possible.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000016
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000017:program:`lit` should be run with one or more *tests* to run specified on the
18command line. Tests can be either individual test files or directories to
19search for tests (see :ref:`test-discovery`).
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000020
21Each specified test will be executed (potentially in parallel) and once all
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000022tests have been run :program:`lit` will print summary information on the number
23of tests which passed or failed (see :ref:`test-status-results`). The
24:program:`lit` program will execute with a non-zero exit code if any tests
25fail.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000026
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000027By default :program:`lit` will use a succinct progress display and will only
28print summary information for test failures. See :ref:`output-options` for
29options controlling the :program:`lit` progress display and output.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000030
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000031:program:`lit` also includes a number of options for controlling how tests are
32executed (specific features may depend on the particular test format). See
Dmitri Gribenko6e303f72012-11-29 17:05:34 +000033:ref:`execution-options` for more information.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000034
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000035Finally, :program:`lit` also supports additional options for only running a
36subset of the options specified on the command line, see
37:ref:`selection-options` for more information.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000038
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000039Users interested in the :program:`lit` architecture or designing a
40:program:`lit` testing implementation should see :ref:`lit-infrastructure`.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000041
42GENERAL OPTIONS
43---------------
44
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000045.. option:: -h, --help
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000046
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000047 Show the :program:`lit` help message.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000048
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000049.. option:: -j N, --threads=N
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000050
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000051 Run ``N`` tests in parallel. By default, this is automatically chosen to
52 match the number of detected available CPUs.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000053
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000054.. option:: --config-prefix=NAME
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000055
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000056 Search for :file:`{NAME}.cfg` and :file:`{NAME}.site.cfg` when searching for
57 test suites, instead of :file:`lit.cfg` and :file:`lit.site.cfg`.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000058
Matthias Braun6717a0b2017-02-09 23:03:22 +000059.. option:: -D NAME[=VALUE], --param NAME[=VALUE]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000060
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000061 Add a user defined parameter ``NAME`` with the given ``VALUE`` (or the empty
62 string if not given). The meaning and use of these parameters is test suite
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000063 dependent.
64
Dmitri Gribenko6e303f72012-11-29 17:05:34 +000065.. _output-options:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000066
67OUTPUT OPTIONS
68--------------
69
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000070.. option:: -q, --quiet
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000071
72 Suppress any output except for test failures.
73
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000074.. option:: -s, --succinct
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000075
76 Show less output, for example don't show information on tests that pass.
77
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000078.. option:: -v, --verbose
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000079
80 Show more information on test failures, for example the entire test output
81 instead of just the test result.
82
George Karpenkovdfa6c202017-07-13 19:26:27 +000083.. option:: -vv, --echo-all-commands
84
85 Echo all commands to stdout, as they are being executed.
86 This can be valuable for debugging test failures, as the last echoed command
87 will be the one which has failed.
88 This option implies ``--verbose``.
89
Matthias Braunf5e2b8f2015-11-06 01:13:40 +000090.. option:: -a, --show-all
91
92 Show more information about all tests, for example the entire test
93 commandline and output.
94
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000095.. option:: --no-progress-bar
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000096
97 Do not use curses based progress bar.
98
Eric Fiselier18fab462014-07-31 20:11:13 +000099.. option:: --show-unsupported
100
101 Show the names of unsupported tests.
102
Eric Fiselierc85f00a2014-08-02 01:29:52 +0000103.. option:: --show-xfail
104
105 Show the names of tests that were expected to fail.
106
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000107.. _execution-options:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000108
109EXECUTION OPTIONS
110-----------------
111
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000112.. option:: --path=PATH
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000113
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000114 Specify an additional ``PATH`` to use when searching for executables in tests.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000115
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000116.. option:: --vg
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000117
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000118 Run individual tests under valgrind (using the memcheck tool). The
119 ``--error-exitcode`` argument for valgrind is used so that valgrind failures
120 will cause the program to exit with a non-zero status.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000121
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000122 When this option is enabled, :program:`lit` will also automatically provide a
123 "``valgrind``" feature that can be used to conditionally disable (or expect
124 failure in) certain tests.
Daniel Dunbar519a3492012-10-19 20:12:00 +0000125
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000126.. option:: --vg-arg=ARG
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000127
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000128 When :option:`--vg` is used, specify an additional argument to pass to
129 :program:`valgrind` itself.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000130
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000131.. option:: --vg-leak
Daniel Dunbar519a3492012-10-19 20:12:00 +0000132
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000133 When :option:`--vg` is used, enable memory leak checks. When this option is
134 enabled, :program:`lit` will also automatically provide a "``vg_leak``"
135 feature that can be used to conditionally disable (or expect failure in)
136 certain tests.
Daniel Dunbar519a3492012-10-19 20:12:00 +0000137
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000138.. option:: --time-tests
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000139
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000140 Track the wall time individual tests take to execute and includes the results
141 in the summary output. This is useful for determining which tests in a test
142 suite take the most time to execute. Note that this option is most useful
143 with ``-j 1``.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000144
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000145.. _selection-options:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000146
147SELECTION OPTIONS
148-----------------
149
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000150.. option:: --max-tests=N
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000151
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000152 Run at most ``N`` tests and then terminate.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000153
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000154.. option:: --max-time=N
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000155
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000156 Spend at most ``N`` seconds (approximately) running tests and then terminate.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000157
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000158.. option:: --shuffle
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000159
160 Run the tests in a random order.
161
Graydon Hoareae5d7bb2017-01-18 18:12:20 +0000162.. option:: --num-shards=M
163
164 Divide the set of selected tests into ``M`` equal-sized subsets or
165 "shards", and run only one of them. Must be used with the
166 ``--run-shard=N`` option, which selects the shard to run. The environment
167 variable ``LIT_NUM_SHARDS`` can also be used in place of this
168 option. These two options provide a coarse mechanism for paritioning large
169 testsuites, for parallel execution on separate machines (say in a large
170 testing farm).
171
172.. option:: --run-shard=N
173
174 Select which shard to run, assuming the ``--num-shards=M`` option was
175 provided. The two options must be used together, and the value of ``N``
176 must be in the range ``1..M``. The environment variable
177 ``LIT_RUN_SHARD`` can also be used in place of this option.
178
George Karpenkov22a402f2017-07-07 00:22:11 +0000179.. option:: --filter=REGEXP
180
181 Run only those tests whose name matches the regular expression specified in
182 ``REGEXP``. The environment variable ``LIT_FILTER`` can be also used in place
183 of this option, which is especially useful in environments where the call
184 to ``lit`` is issued indirectly.
185
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000186ADDITIONAL OPTIONS
187------------------
188
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000189.. option:: --debug
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000190
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000191 Run :program:`lit` in debug mode, for debugging configuration issues and
192 :program:`lit` itself.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000193
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000194.. option:: --show-suites
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000195
Daniel Dunbarc4477df2013-08-08 20:59:25 +0000196 List the discovered test suites and exit.
197
198.. option:: --show-tests
199
Eric Christopher572e03a2015-06-19 01:53:21 +0000200 List all of the discovered tests and exit.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000201
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000202EXIT STATUS
203-----------
204
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000205:program:`lit` will exit with an exit code of 1 if there are any FAIL or XPASS
206results. Otherwise, it will exit with the status 0. Other exit codes are used
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000207for non-test related failures (for example a user error or an internal program
208error).
209
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000210.. _test-discovery:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000211
212TEST DISCOVERY
213--------------
214
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000215The inputs passed to :program:`lit` can be either individual tests, or entire
216directories or hierarchies of tests to run. When :program:`lit` starts up, the
217first thing it does is convert the inputs into a complete list of tests to run
218as part of *test discovery*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000219
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000220In the :program:`lit` model, every test must exist inside some *test suite*.
221:program:`lit` resolves the inputs specified on the command line to test suites
222by searching upwards from the input path until it finds a :file:`lit.cfg` or
223:file:`lit.site.cfg` file. These files serve as both a marker of test suites
224and as configuration files which :program:`lit` loads in order to understand
225how to find and run the tests inside the test suite.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000226
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000227Once :program:`lit` has mapped the inputs into test suites it traverses the
228list of inputs adding tests for individual files and recursively searching for
229tests in directories.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000230
231This behavior makes it easy to specify a subset of tests to run, while still
232allowing the test suite configuration to control exactly how tests are
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000233interpreted. In addition, :program:`lit` always identifies tests by the test
234suite they are in, and their relative path inside the test suite. For
235appropriately configured projects, this allows :program:`lit` to provide
236convenient and flexible support for out-of-tree builds.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000237
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000238.. _test-status-results:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000239
240TEST STATUS RESULTS
241-------------------
242
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000243Each test ultimately produces one of the following six results:
244
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000245**PASS**
246
247 The test succeeded.
248
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000249**XFAIL**
250
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000251 The test failed, but that is expected. This is used for test formats which allow
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000252 specifying that a test does not currently work, but wish to leave it in the test
253 suite.
254
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000255**XPASS**
256
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000257 The test succeeded, but it was expected to fail. This is used for tests which
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000258 were specified as expected to fail, but are now succeeding (generally because
259 the feature they test was broken and has been fixed).
260
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000261**FAIL**
262
263 The test failed.
264
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000265**UNRESOLVED**
266
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000267 The test result could not be determined. For example, this occurs when the test
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000268 could not be run, the test itself is invalid, or the test was interrupted.
269
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000270**UNSUPPORTED**
271
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000272 The test is not supported in this environment. This is used by test formats
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000273 which can report unsupported tests.
274
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000275Depending on the test format tests may produce additional information about
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000276their status (generally only for failures). See the :ref:`output-options`
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000277section for more information.
278
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000279.. _lit-infrastructure:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000280
281LIT INFRASTRUCTURE
282------------------
283
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000284This section describes the :program:`lit` testing architecture for users interested in
285creating a new :program:`lit` testing implementation, or extending an existing one.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000286
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000287:program:`lit` proper is primarily an infrastructure for discovering and running
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000288arbitrary tests, and to expose a single convenient interface to these
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000289tests. :program:`lit` itself doesn't know how to run tests, rather this logic is
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000290defined by *test suites*.
291
292TEST SUITES
293~~~~~~~~~~~
294
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000295As described in :ref:`test-discovery`, tests are always located inside a *test
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000296suite*. Test suites serve to define the format of the tests they contain, the
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000297logic for finding those tests, and any additional information to run the tests.
298
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000299:program:`lit` identifies test suites as directories containing ``lit.cfg`` or
300``lit.site.cfg`` files (see also :option:`--config-prefix`). Test suites are
301initially discovered by recursively searching up the directory hierarchy for
302all the input files passed on the command line. You can use
303:option:`--show-suites` to display the discovered test suites at startup.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000304
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000305Once a test suite is discovered, its config file is loaded. Config files
306themselves are Python modules which will be executed. When the config file is
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000307executed, two important global variables are predefined:
308
Eric Fiselier6c53c862014-08-15 05:54:19 +0000309**lit_config**
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000310
311 The global **lit** configuration object (a *LitConfig* instance), which defines
312 the builtin test formats, global configuration parameters, and other helper
313 routines for implementing test configurations.
314
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000315**config**
316
317 This is the config object (a *TestingConfig* instance) for the test suite,
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000318 which the config file is expected to populate. The following variables are also
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000319 available on the *config* object, some of which must be set by the config and
320 others are optional or predefined:
321
322 **name** *[required]* The name of the test suite, for use in reports and
323 diagnostics.
324
325 **test_format** *[required]* The test format object which will be used to
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000326 discover and run tests in the test suite. Generally this will be a builtin test
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000327 format available from the *lit.formats* module.
328
Sergey Matveev8dbcb352013-05-30 12:37:52 +0000329 **test_source_root** The filesystem path to the test suite root. For out-of-dir
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000330 builds this is the directory that will be scanned for tests.
331
332 **test_exec_root** For out-of-dir builds, the path to the test suite root inside
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000333 the object directory. This is where tests will be run and temporary output files
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000334 placed.
335
336 **environment** A dictionary representing the environment to use when executing
337 tests in the suite.
338
339 **suffixes** For **lit** test formats which scan directories for tests, this
Dmitri Gribenko9e4fc282013-01-19 20:35:18 +0000340 variable is a list of suffixes to identify test files. Used by: *ShTest*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000341
342 **substitutions** For **lit** test formats which substitute variables into a test
Dmitri Gribenko9e4fc282013-01-19 20:35:18 +0000343 script, the list of substitutions to perform. Used by: *ShTest*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000344
345 **unsupported** Mark an unsupported directory, all tests within it will be
Dmitri Gribenko9e4fc282013-01-19 20:35:18 +0000346 reported as unsupported. Used by: *ShTest*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000347
348 **parent** The parent configuration, this is the config object for the directory
349 containing the test suite, or None.
350
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000351 **root** The root configuration. This is the top-most :program:`lit` configuration in
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000352 the project.
353
Rafael Espindola2a2a0972013-07-26 22:32:58 +0000354 **pipefail** Normally a test using a shell pipe fails if any of the commands
355 on the pipe fail. If this is not desired, setting this variable to false
356 makes the test fail only if the last command in the pipe fails.
357
Daniel Sanders61516992016-07-26 13:23:27 +0000358 **available_features** A set of features that can be used in `XFAIL`,
359 `REQUIRES`, and `UNSUPPORTED` directives.
360
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000361TEST DISCOVERY
362~~~~~~~~~~~~~~
363
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000364Once test suites are located, :program:`lit` recursively traverses the source
Sergey Matveev8dbcb352013-05-30 12:37:52 +0000365directory (following *test_source_root*) looking for tests. When :program:`lit`
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000366enters a sub-directory, it first checks to see if a nested test suite is
367defined in that directory. If so, it loads that test suite recursively,
368otherwise it instantiates a local test config for the directory (see
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000369:ref:`local-configuration-files`).
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000370
371Tests are identified by the test suite they are contained within, and the
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000372relative path inside that suite. Note that the relative path may not refer to
373an actual file on disk; some test formats (such as *GoogleTest*) define
374"virtual tests" which have a path that contains both the path to the actual
375test file and a subpath to identify the virtual test.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000376
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000377.. _local-configuration-files:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000378
379LOCAL CONFIGURATION FILES
380~~~~~~~~~~~~~~~~~~~~~~~~~
381
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000382When :program:`lit` loads a subdirectory in a test suite, it instantiates a
Jonathan Roelofsc9904592015-02-07 17:18:26 +0000383local test configuration by cloning the configuration for the parent directory
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000384--- the root of this configuration chain will always be a test suite. Once the
385test configuration is cloned :program:`lit` checks for a *lit.local.cfg* file
386in the subdirectory. If present, this file will be loaded and can be used to
387specialize the configuration for each individual directory. This facility can
388be used to define subdirectories of optional tests, or to change other
389configuration parameters --- for example, to change the test format, or the
390suffixes which identify test files.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000391
Paul Robinsonf88cc142016-04-04 17:14:45 +0000392PRE-DEFINED SUBSTITUTIONS
393~~~~~~~~~~~~~~~~~~~~~~~~~~
394
395:program:`lit` provides various patterns that can be used with the RUN command.
David Bozier9126f542017-02-09 14:12:30 +0000396These are defined in TestRunner.py. The base set of substitutions are:
Paul Robinsonf88cc142016-04-04 17:14:45 +0000397
Jordan Rosee55d9a12017-10-14 04:01:27 +0000398 ========== ==============
399 Macro Substitution
400 ========== ==============
401 %s source path (path to the file currently being run)
402 %S source dir (directory of the file currently being run)
403 %p same as %S
404 %{pathsep} path separator
405 %t temporary file name unique to the test
406 %T temporary directory unique to the test
407 %% %
408 ========== ==============
Paul Robinsonf88cc142016-04-04 17:14:45 +0000409
David Bozier9126f542017-02-09 14:12:30 +0000410Other substitutions are provided that are variations on this base set and
411further substitution patterns can be defined by each test module. See the
412modules :ref:`local-configuration-files`.
Paul Robinsonf88cc142016-04-04 17:14:45 +0000413
David Bozier9126f542017-02-09 14:12:30 +0000414More detailed information on substitutions can be found in the
Paul Robinsonf88cc142016-04-04 17:14:45 +0000415:doc:`../TestingGuide`.
416
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000417TEST RUN OUTPUT FORMAT
418~~~~~~~~~~~~~~~~~~~~~~
419
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000420The :program:`lit` output for a test run conforms to the following schema, in
421both short and verbose modes (although in short mode no PASS lines will be
422shown). This schema has been chosen to be relatively easy to reliably parse by
423a machine (for example in buildbot log scraping), and for other tools to
424generate.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000425
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000426Each test result is expected to appear on a line that matches:
427
428.. code-block:: none
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000429
Eli Bendersky9d07f942012-11-20 00:26:08 +0000430 <result code>: <test name> (<progress info>)
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000431
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000432where ``<result-code>`` is a standard test result such as PASS, FAIL, XFAIL,
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000433XPASS, UNRESOLVED, or UNSUPPORTED. The performance result codes of IMPROVED and
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000434REGRESSED are also allowed.
435
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000436The ``<test name>`` field can consist of an arbitrary string containing no
437newline.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000438
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000439The ``<progress info>`` field can be used to report progress information such
440as (1/300) or can be empty, but even when empty the parentheses are required.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000441
442Each test result may include additional (multiline) log information in the
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000443following format:
444
445.. code-block:: none
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000446
Eli Bendersky9d07f942012-11-20 00:26:08 +0000447 <log delineator> TEST '(<test name>)' <trailing delineator>
448 ... log message ...
449 <log delineator>
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000450
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000451where ``<test name>`` should be the name of a preceding reported test, ``<log
452delineator>`` is a string of "*" characters *at least* four characters long
453(the recommended length is 20), and ``<trailing delineator>`` is an arbitrary
454(unparsed) string.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000455
456The following is an example of a test run output which consists of four tests A,
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000457B, C, and D, and a log message for the failing test C:
458
459.. code-block:: none
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000460
461 PASS: A (1 of 4)
462 PASS: B (2 of 4)
463 FAIL: C (3 of 4)
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000464 ******************** TEST 'C' FAILED ********************
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000465 Test 'C' failed as a result of exit code 1.
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000466 ********************
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000467 PASS: D (4 of 4)
468
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000469LIT EXAMPLE TESTS
470~~~~~~~~~~~~~~~~~
471
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000472The :program:`lit` distribution contains several example implementations of
473test suites in the *ExampleTests* directory.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000474
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000475SEE ALSO
476--------
477
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000478valgrind(1)