5 lit - LLVM Integrated Tester
9 B<lit> [I<options>] [I<tests>]
13 B<lit> is a portable tool for executing LLVM and Clang style test suites,
14 summarizing their results, and providing indication of failures. B<lit> is
15 designed to be a lightweight testing tool with as simple a user interface as
18 B<lit> should be run with one or more I<tests> to run specified on the command
19 line. Tests can be either individual test files or directories to search for
20 tests (see L<"TEST DISCOVERY">).
22 Each specified test will be executed (potentially in parallel) and once all
23 tests have been run B<lit> will print summary information on the number of tests
24 which passed or failed (see L<"TEST STATUS RESULTS">). The B<lit> program will
25 execute with a non-zero exit code if any tests fail.
27 By default B<lit> will use a succinct progress display and will only print
28 summary information for test failures. See L<"OUTPUT OPTIONS"> for options
29 controlling the B<lit> progress display and output.
31 B<lit> also includes a number of options for controlling how tests are exected
32 (specific features may depend on the particular test format). See L<"EXECUTION
33 OPTIONS"> for more information.
35 Finally, B<lit> also supports additional options for only running a subset of
36 the options specified on the command line, see L<"SELECTION OPTIONS"> for
39 Users interested in the B<lit> architecture or designing a B<lit> testing
40 implementation should see L<"LIT ARCHITECTURE">
42 =head1 GENERAL OPTIONS
46 =item B<-h>, B<--help>
48 Show the B<lit> help message.
50 =item B<-j> I<N>, B<--threads>=I<N>
52 Run I<N> tests in parallel. By default, this is automatically chose to match the
53 number of detected available CPUs.
55 =item B<--config-prefix>=I<NAME>
57 Search for I<NAME.cfg> and I<NAME.site.cfg> when searching for test suites,
58 instead I<lit.cfg> and I<lit.site.cfg>.
60 =item B<--param> I<NAME>, B<--param> I<NAME>=I<VALUE>
62 Add a user defined parameter I<NAME> with the given I<VALUE> (or the empty
63 string if not given). The meaning and use of these parameters is test suite
72 =item B<-q>, B<--quiet>
74 Suppress any output except for test failures.
76 =item B<-s>, B<--succinct>
78 Show less output, for example don't show information on tests that pass.
80 =item B<-v>, B<--verbose>
82 Show more information on test failures, for example the entire test output
83 instead of just the test result.
85 =item B<--no-progress-bar>
87 Do not use curses based progress bar.
91 =head1 EXECUTION OPTIONS
95 =item B<--path>=I<PATH>
97 Specify an addition I<PATH> to use when searching for executables in tests.
101 Run individual tests under valgrind (using the memcheck tool). The
102 I<--error-exitcode> argument for valgrind is used so that valgrind failures will
103 cause the program to exit with a non-zero status.
105 =item B<--vg-arg>=I<ARG>
107 When I<--vg> is used, specify an additional argument to pass to valgrind itself.
109 =item B<--time-tests>
111 Track the wall time individual tests take to execute and includes the results in
112 the summary output. This is useful for determining which tests in a test suite
113 take the most time to execute. Note that this option is most useful with I<-j
118 =head1 SELECTION OPTIONS
122 =item B<--max-tests>=I<N>
124 Run at most I<N> tests and then terminate.
126 =item B<--max-time>=I<N>
128 Spend at most I<N> seconds (approximately) running tests and then terminate.
132 Run the tests in a random order.
136 =head1 ADDITIONAL OPTIONS
142 Run B<lit> in debug mode, for debugging configuration issues and B<lit> itself.
144 =item B<--show-suites>
146 List the discovered test suites as part of the standard output.
148 =item B<--no-tcl-as-sh>
150 Run Tcl scripts internally (instead of converting to shell scripts).
156 B<lit> will exit with an exit code of 1 if there are any FAIL or XPASS
157 results. Otherwise, it will exit with the status 0. Other exit codes used for
158 non-test related failures (for example a user error or an internal program
161 =head1 TEST DISCOVERY
163 The inputs passed to B<lit> can be either individual tests, or entire
164 directories or hierarchies of tests to run. When B<lit> starts up, the first
165 thing it does is convert the inputs into a complete list of tests to run as part
166 of I<test discovery>.
168 In the B<lit> model, every test must exist inside some I<test suite>. B<lit>
169 resolves the inputs specified on the command line to test suites by searching
170 upwards from the input path until it finds a I<lit.cfg> or I<lit.site.cfg>
171 file. These files serve as both a marker of test suites and as configuration
172 files which B<lit> loads in order to understand how to find and run the tests
173 inside the test suite.
175 Once B<lit> has mapped the inputs into test suites it traverses the list of
176 inputs adding tests for individual files and recursively searching for tests in
179 This behavior makes it easy to specify a subset of tests to run, while still
180 allowing the test suite configuration to control exactly how tests are
181 interpreted. In addition, B<lit> always identifies tests by the test suite they
182 are in, and their relative path inside the test suite. For appropriately
183 configured projects, this allows B<lit> to provide convenient and flexible
184 support for out-of-tree builds.
186 =head1 TEST STATUS RESULTS
188 Each test ultimately produces one of the following six results:
198 The test failed, but that is expected. This is used for test formats which allow
199 specifying that a test does not currently work, but wish to leave it in the test
204 The test succeeded, but it was expected to fail. This is used for tests which
205 were specified as expected to fail, but are now succeeding (generally because
206 the feautre they test was broken and has been fixed).
214 The test result could not be determined. For example, this occurs when the test
215 could not be run, the test itself is invalid, or the test was interrupted.
219 The test is not supported in this environment. This is used by test formats
220 which can report unsupported tests.
224 Depending on the test format tests may produce additional information about
225 their status (generally only for failures). See the L<Output|"LIT OUTPUT">
226 section for more information.
228 =head1 LIT INFRASTRUCTURE
230 This section describes the B<lit> testing architecture for users interested in
231 creating a new B<lit> testing implementation, or extending an existing one.
233 B<lit> proper is primarily an infrastructure for discovering and running
234 arbitrary tests, and to expose a single convenient interface to these
235 tests. B<lit> itself doesn't contain know how to run tests, rather this logic is
236 defined by I<test suites>.
240 As described in L<"TEST DISCOVERY">, tests are always located inside a I<test
241 suite>. Test suites serve to define the format of the tests they contain, the
242 logic for finding those tests, and any additional information to run the tests.
244 B<lit> identifies test suites as directories containing I<lit.cfg> or
245 I<lit.site.cfg> files (see also B<--config-prefix>. Test suites are initially
246 discovered by recursively searching up the directory hierarchy for all the input
247 files passed on the command line. You can use B<--show-suites> to display the
248 discovered test suites at startup.
250 Once a test suite is discovered, its config file is loaded. Config files
251 themselves are just Python modules which will be executed. When the config file
252 is executed, two important global variables are predefined:
258 The global B<lit> configuration object (a I<LitConfig> instance), which defines
259 the builtin test formats, global configuration parameters, and other helper
260 routines for implementing test configurations.
264 This is the config object (a I<TestingConfig> instance) for the test suite,
265 which the config file is expected to populate. The following variables are also
266 available on the I<config> object, some of which must be set by the config and
267 others are optional or predefined:
269 B<name> I<[required]> The name of the test suite, for use in reports and
272 B<test_format> I<[required]> The test format object which will be used to
273 discover and run tests in the test suite. Generally this will be a builtin test
274 format available from the I<lit.formats> module.
276 B<test_src_root> The filesystem path to the test suite root. For out-of-dir
277 builds this is the directory that will be scanned for tests.
279 B<test_exec_root> For out-of-dir builds, the path to the test suite root inside
280 the object directory. This is where tests will be run and temporary output files
283 B<environment> A dictionary representing the environment to use when executing
286 B<suffixes> For B<lit> test formats which scan directories for tests, this
287 variable as a list of suffixes to identify test files. Used by: I<ShTest>,
290 B<substitutions> For B<lit> test formats which substitute variables into a test
291 script, the list of substitutions to perform. Used by: I<ShTest>, I<TclTest>.
293 B<unsupported> Mark an unsupported directory, all tests within it will be
294 reported as unsupported. Used by: I<ShTest>, I<TclTest>.
296 B<parent> The parent configuration, this is the config object for the directory
297 containing the test suite, or None.
299 B<on_clone> The config is actually cloned for every subdirectory inside a test
300 suite, to allow local configuration on a per-directory basis. The I<on_clone>
301 variable can be set to a Python function which will be called whenever a
302 configuration is cloned (for a subdirectory). The function should takes three
303 arguments: (1) the parent configuration, (2) the new configuration (which the
304 I<on_clone> function will generally modify), and (3) the test path to the new
305 directory being scanned.
309 =head2 TEST DISCOVERY
311 Once test suites are located, B<lit> recursively traverses the source directory
312 (following I<test_src_root>) looking for tests. When B<lit> enters a
313 sub-directory, it first checks to see if a nest test suite is defined in that
314 directory. If so, it loads that test suite recursively, otherwise it
315 instantiates a local test config for the directory (see L<"LOCAL CONFIGURATION
318 Tests are identified by the test suite they are contained within, and the
319 relative path inside that suite. Note that the relative path may not refer to an
320 actual file on disk; some test formats (such as I<GoogleTest>) define "virtual
321 tests" which have a path that contains both the path to the actual test file and
322 a subpath to identify the virtual test.
324 =head2 LOCAL CONFIGURATION FILES
326 When B<lit> loads a subdirectory in a test suite, it instantiates a local test
327 configuration by cloning the configuration for the parent direction -- the root
328 of this configuration chain will always be a test suite. Once the test
329 configuration is cloned B<lit> checks for a I<lit.local.cfg> file in the
330 subdirectory. If present, this file will be loaded and can be used to specialize
331 the configuration for each individual directory. This facility can be used to
332 define subdirectories of optional tests, or to change other configuration
333 parameters -- for example, to change the test format, or the suffixes which
336 =head2 LIT EXAMPLE TESTS
338 The B<lit> distribution contains several example implementations of test suites
339 in the I<ExampleTests> directory.
347 Written by Daniel Dunbar and maintained by the LLVM Team (L<http://llvm.org>).