blob: 9e96cd2a4bfd15e0d41d615697ac7d6f8a380c86 [file] [log] [blame]
Daniel Dunbar3b709d52012-05-08 16:50:35 +00001lit - LLVM Integrated Tester
2============================
3
4
5SYNOPSIS
6--------
7
8
9**lit** [*options*] [*tests*]
10
11
12DESCRIPTION
13-----------
14
15
16**lit** is a portable tool for executing LLVM and Clang style test suites,
17summarizing their results, and providing indication of failures. **lit** is
18designed to be a lightweight testing tool with as simple a user interface as
19possible.
20
21**lit** should be run with one or more *tests* to run specified on the command
22line. Tests can be either individual test files or directories to search for
23tests (see "TEST DISCOVERY").
24
25Each specified test will be executed (potentially in parallel) and once all
26tests have been run **lit** will print summary information on the number of tests
27which passed or failed (see "TEST STATUS RESULTS"). The **lit** program will
28execute with a non-zero exit code if any tests fail.
29
30By default **lit** will use a succinct progress display and will only print
31summary information for test failures. See "OUTPUT OPTIONS" for options
32controlling the **lit** progress display and output.
33
34**lit** also includes a number of options for controlling how tests are executed
35(specific features may depend on the particular test format). See "EXECUTION
36OPTIONS" for more information.
37
38Finally, **lit** also supports additional options for only running a subset of
39the options specified on the command line, see "SELECTION OPTIONS" for
40more information.
41
42Users interested in the **lit** architecture or designing a **lit** testing
43implementation should see "LIT INFRASTRUCTURE"
44
45
46GENERAL OPTIONS
47---------------
48
49
50
51**-h**, **--help**
52
53 Show the **lit** help message.
54
55
56
57**-j** *N*, **--threads**\ =\ *N*
58
59 Run *N* tests in parallel. By default, this is automatically chosen to match
60 the number of detected available CPUs.
61
62
63
64**--config-prefix**\ =\ *NAME*
65
66 Search for *NAME.cfg* and *NAME.site.cfg* when searching for test suites,
67 instead of *lit.cfg* and *lit.site.cfg*.
68
69
70
71**--param** *NAME*, **--param** *NAME*\ =\ *VALUE*
72
73 Add a user defined parameter *NAME* with the given *VALUE* (or the empty
74 string if not given). The meaning and use of these parameters is test suite
75 dependent.
76
77
78
79
80OUTPUT OPTIONS
81--------------
82
83
84
85**-q**, **--quiet**
86
87 Suppress any output except for test failures.
88
89
90
91**-s**, **--succinct**
92
93 Show less output, for example don't show information on tests that pass.
94
95
96
97**-v**, **--verbose**
98
99 Show more information on test failures, for example the entire test output
100 instead of just the test result.
101
102
103
104**--no-progress-bar**
105
106 Do not use curses based progress bar.
107
108
109
110
111EXECUTION OPTIONS
112-----------------
113
114
115
116**--path**\ =\ *PATH*
117
118 Specify an addition *PATH* to use when searching for executables in tests.
119
120
121
122**--vg**
123
124 Run individual tests under valgrind (using the memcheck tool). The
125 *--error-exitcode* argument for valgrind is used so that valgrind failures will
126 cause the program to exit with a non-zero status.
127
Daniel Dunbarf8545972012-10-19 20:12:00 +0000128 When this option is enabled, **lit** will also automatically provide a
129 "valgrind" feature that can be used to conditionally disable (or expect failure
130 in) certain tests.
131
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000132
133
134**--vg-arg**\ =\ *ARG*
135
136 When *--vg* is used, specify an additional argument to pass to valgrind itself.
137
138
139
Daniel Dunbarf8545972012-10-19 20:12:00 +0000140**--vg-leak**
141
142 When *--vg* is used, enable memory leak checks. When this option is enabled,
Daniel Dunbar6b283ea2012-10-19 20:29:30 +0000143 **lit** will also automatically provide a "vg_leak" feature that can be
Daniel Dunbarf8545972012-10-19 20:12:00 +0000144 used to conditionally disable (or expect failure in) certain tests.
145
146
147
148
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000149**--time-tests**
150
151 Track the wall time individual tests take to execute and includes the results in
152 the summary output. This is useful for determining which tests in a test suite
153 take the most time to execute. Note that this option is most useful with *-j
154 1*.
155
156
157
158
159SELECTION OPTIONS
160-----------------
161
162
163
164**--max-tests**\ =\ *N*
165
166 Run at most *N* tests and then terminate.
167
168
169
170**--max-time**\ =\ *N*
171
172 Spend at most *N* seconds (approximately) running tests and then terminate.
173
174
175
176**--shuffle**
177
178 Run the tests in a random order.
179
180
181
182
183ADDITIONAL OPTIONS
184------------------
185
186
187
188**--debug**
189
190 Run **lit** in debug mode, for debugging configuration issues and **lit** itself.
191
192
193
194**--show-suites**
195
196 List the discovered test suites as part of the standard output.
197
198
199
200**--no-tcl-as-sh**
201
202 Run Tcl scripts internally (instead of converting to shell scripts).
203
204
205
206**--repeat**\ =\ *N*
207
208 Run each test *N* times. Currently this is primarily useful for timing tests,
209 other results are not collated in any reasonable fashion.
210
211
212
213
214EXIT STATUS
215-----------
216
217
218**lit** will exit with an exit code of 1 if there are any FAIL or XPASS
219results. Otherwise, it will exit with the status 0. Other exit codes are used
220for non-test related failures (for example a user error or an internal program
221error).
222
223
224TEST DISCOVERY
225--------------
226
227
228The inputs passed to **lit** can be either individual tests, or entire
229directories or hierarchies of tests to run. When **lit** starts up, the first
230thing it does is convert the inputs into a complete list of tests to run as part
231of *test discovery*.
232
233In the **lit** model, every test must exist inside some *test suite*. **lit**
234resolves the inputs specified on the command line to test suites by searching
235upwards from the input path until it finds a *lit.cfg* or *lit.site.cfg*
236file. These files serve as both a marker of test suites and as configuration
237files which **lit** loads in order to understand how to find and run the tests
238inside the test suite.
239
240Once **lit** has mapped the inputs into test suites it traverses the list of
241inputs adding tests for individual files and recursively searching for tests in
242directories.
243
244This behavior makes it easy to specify a subset of tests to run, while still
245allowing the test suite configuration to control exactly how tests are
246interpreted. In addition, **lit** always identifies tests by the test suite they
247are in, and their relative path inside the test suite. For appropriately
248configured projects, this allows **lit** to provide convenient and flexible
249support for out-of-tree builds.
250
251
252TEST STATUS RESULTS
253-------------------
254
255
256Each test ultimately produces one of the following six results:
257
258
259**PASS**
260
261 The test succeeded.
262
263
264
265**XFAIL**
266
267 The test failed, but that is expected. This is used for test formats which allow
268 specifying that a test does not currently work, but wish to leave it in the test
269 suite.
270
271
272
273**XPASS**
274
275 The test succeeded, but it was expected to fail. This is used for tests which
276 were specified as expected to fail, but are now succeeding (generally because
277 the feature they test was broken and has been fixed).
278
279
280
281**FAIL**
282
283 The test failed.
284
285
286
287**UNRESOLVED**
288
289 The test result could not be determined. For example, this occurs when the test
290 could not be run, the test itself is invalid, or the test was interrupted.
291
292
293
294**UNSUPPORTED**
295
296 The test is not supported in this environment. This is used by test formats
297 which can report unsupported tests.
298
299
300
301Depending on the test format tests may produce additional information about
302their status (generally only for failures). See the Output|"OUTPUT OPTIONS"
303section for more information.
304
305
306LIT INFRASTRUCTURE
307------------------
308
309
310This section describes the **lit** testing architecture for users interested in
311creating a new **lit** testing implementation, or extending an existing one.
312
313**lit** proper is primarily an infrastructure for discovering and running
314arbitrary tests, and to expose a single convenient interface to these
315tests. **lit** itself doesn't know how to run tests, rather this logic is
316defined by *test suites*.
317
318TEST SUITES
319~~~~~~~~~~~
320
321
322As described in "TEST DISCOVERY", tests are always located inside a *test
323suite*. Test suites serve to define the format of the tests they contain, the
324logic for finding those tests, and any additional information to run the tests.
325
326**lit** identifies test suites as directories containing *lit.cfg* or
327*lit.site.cfg* files (see also **--config-prefix**). Test suites are initially
328discovered by recursively searching up the directory hierarchy for all the input
329files passed on the command line. You can use **--show-suites** to display the
330discovered test suites at startup.
331
332Once a test suite is discovered, its config file is loaded. Config files
333themselves are Python modules which will be executed. When the config file is
334executed, two important global variables are predefined:
335
336
337**lit**
338
339 The global **lit** configuration object (a *LitConfig* instance), which defines
340 the builtin test formats, global configuration parameters, and other helper
341 routines for implementing test configurations.
342
343
344
345**config**
346
347 This is the config object (a *TestingConfig* instance) for the test suite,
348 which the config file is expected to populate. The following variables are also
349 available on the *config* object, some of which must be set by the config and
350 others are optional or predefined:
351
352 **name** *[required]* The name of the test suite, for use in reports and
353 diagnostics.
354
355 **test_format** *[required]* The test format object which will be used to
356 discover and run tests in the test suite. Generally this will be a builtin test
357 format available from the *lit.formats* module.
358
359 **test_src_root** The filesystem path to the test suite root. For out-of-dir
360 builds this is the directory that will be scanned for tests.
361
362 **test_exec_root** For out-of-dir builds, the path to the test suite root inside
363 the object directory. This is where tests will be run and temporary output files
364 placed.
365
366 **environment** A dictionary representing the environment to use when executing
367 tests in the suite.
368
369 **suffixes** For **lit** test formats which scan directories for tests, this
370 variable is a list of suffixes to identify test files. Used by: *ShTest*,
371 *TclTest*.
372
373 **substitutions** For **lit** test formats which substitute variables into a test
374 script, the list of substitutions to perform. Used by: *ShTest*, *TclTest*.
375
376 **unsupported** Mark an unsupported directory, all tests within it will be
377 reported as unsupported. Used by: *ShTest*, *TclTest*.
378
379 **parent** The parent configuration, this is the config object for the directory
380 containing the test suite, or None.
381
382 **root** The root configuration. This is the top-most **lit** configuration in
383 the project.
384
385 **on_clone** The config is actually cloned for every subdirectory inside a test
386 suite, to allow local configuration on a per-directory basis. The *on_clone*
387 variable can be set to a Python function which will be called whenever a
388 configuration is cloned (for a subdirectory). The function should takes three
389 arguments: (1) the parent configuration, (2) the new configuration (which the
390 *on_clone* function will generally modify), and (3) the test path to the new
391 directory being scanned.
392
393
394
395
396TEST DISCOVERY
397~~~~~~~~~~~~~~
398
399
400Once test suites are located, **lit** recursively traverses the source directory
401(following *test_src_root*) looking for tests. When **lit** enters a
402sub-directory, it first checks to see if a nested test suite is defined in that
403directory. If so, it loads that test suite recursively, otherwise it
404instantiates a local test config for the directory (see "LOCAL CONFIGURATION
405FILES").
406
407Tests are identified by the test suite they are contained within, and the
408relative path inside that suite. Note that the relative path may not refer to an
409actual file on disk; some test formats (such as *GoogleTest*) define "virtual
410tests" which have a path that contains both the path to the actual test file and
411a subpath to identify the virtual test.
412
413
414LOCAL CONFIGURATION FILES
415~~~~~~~~~~~~~~~~~~~~~~~~~
416
417
418When **lit** loads a subdirectory in a test suite, it instantiates a local test
419configuration by cloning the configuration for the parent direction -- the root
420of this configuration chain will always be a test suite. Once the test
421configuration is cloned **lit** checks for a *lit.local.cfg* file in the
422subdirectory. If present, this file will be loaded and can be used to specialize
423the configuration for each individual directory. This facility can be used to
424define subdirectories of optional tests, or to change other configuration
425parameters -- for example, to change the test format, or the suffixes which
426identify test files.
427
428
429TEST RUN OUTPUT FORMAT
430~~~~~~~~~~~~~~~~~~~~~~
431
432
433The b<lit> output for a test run conforms to the following schema, in both short
434and verbose modes (although in short mode no PASS lines will be shown). This
435schema has been chosen to be relatively easy to reliably parse by a machine (for
436example in buildbot log scraping), and for other tools to generate.
437
438Each test result is expected to appear on a line that matches:
439
440<result code>: <test name> (<progress info>)
441
442where <result-code> is a standard test result such as PASS, FAIL, XFAIL, XPASS,
443UNRESOLVED, or UNSUPPORTED. The performance result codes of IMPROVED and
444REGRESSED are also allowed.
445
446The <test name> field can consist of an arbitrary string containing no newline.
447
448The <progress info> field can be used to report progress information such as
449(1/300) or can be empty, but even when empty the parentheses are required.
450
451Each test result may include additional (multiline) log information in the
452following format.
453
454<log delineator> TEST '(<test name>)' <trailing delineator>
455... log message ...
456<log delineator>
457
Benjamin Kramerd9b0b022012-06-02 10:20:22 +0000458where <test name> should be the name of a preceding reported test, <log
Daniel Dunbar3b709d52012-05-08 16:50:35 +0000459delineator> is a string of '\*' characters *at least* four characters long (the
460recommended length is 20), and <trailing delineator> is an arbitrary (unparsed)
461string.
462
463The following is an example of a test run output which consists of four tests A,
464B, C, and D, and a log message for the failing test C::
465
466 PASS: A (1 of 4)
467 PASS: B (2 of 4)
468 FAIL: C (3 of 4)
469 \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* TEST 'C' FAILED \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
470 Test 'C' failed as a result of exit code 1.
471 \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
472 PASS: D (4 of 4)
473
474
475LIT EXAMPLE TESTS
476~~~~~~~~~~~~~~~~~
477
478
479The **lit** distribution contains several example implementations of test suites
480in the *ExampleTests* directory.
481
482
483SEE ALSO
484--------
485
486
487valgrind(1)