Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 1 | lit - LLVM Integrated Tester |
| 2 | ============================ |
| 3 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 4 | SYNOPSIS |
| 5 | -------- |
| 6 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 7 | :program:`lit` [*options*] [*tests*] |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 8 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 9 | DESCRIPTION |
| 10 | ----------- |
| 11 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 12 | :program:`lit` is a portable tool for executing LLVM and Clang style test |
| 13 | suites, summarizing their results, and providing indication of failures. |
| 14 | :program:`lit` is designed to be a lightweight testing tool with as simple a |
| 15 | user interface as possible. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 16 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 17 | :program:`lit` should be run with one or more *tests* to run specified on the |
| 18 | command line. Tests can be either individual test files or directories to |
| 19 | search for tests (see :ref:`test-discovery`). |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 20 | |
| 21 | Each specified test will be executed (potentially in parallel) and once all |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 22 | tests have been run :program:`lit` will print summary information on the number |
| 23 | of 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 |
| 25 | fail. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 26 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 27 | By default :program:`lit` will use a succinct progress display and will only |
| 28 | print summary information for test failures. See :ref:`output-options` for |
| 29 | options controlling the :program:`lit` progress display and output. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 30 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 31 | :program:`lit` also includes a number of options for controlling how tests are |
| 32 | executed (specific features may depend on the particular test format). See |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 33 | :ref:`execution-options` for more information. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 34 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 35 | Finally, :program:`lit` also supports additional options for only running a |
| 36 | subset of the options specified on the command line, see |
| 37 | :ref:`selection-options` for more information. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 38 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 39 | Users interested in the :program:`lit` architecture or designing a |
| 40 | :program:`lit` testing implementation should see :ref:`lit-infrastructure`. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 41 | |
| 42 | GENERAL OPTIONS |
| 43 | --------------- |
| 44 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 45 | .. option:: -h, --help |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 46 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 47 | Show the :program:`lit` help message. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 48 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 49 | .. option:: -j N, --threads=N |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 50 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 51 | Run ``N`` tests in parallel. By default, this is automatically chosen to |
| 52 | match the number of detected available CPUs. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 53 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 54 | .. option:: --config-prefix=NAME |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 55 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 56 | 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 Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 58 | |
Matthias Braun | 9e6fc42 | 2017-02-09 23:03:22 +0000 | [diff] [blame] | 59 | .. option:: -D NAME[=VALUE], --param NAME[=VALUE] |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 60 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 61 | 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 Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 63 | dependent. |
| 64 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 65 | .. _output-options: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 66 | |
| 67 | OUTPUT OPTIONS |
| 68 | -------------- |
| 69 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 70 | .. option:: -q, --quiet |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 71 | |
| 72 | Suppress any output except for test failures. |
| 73 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 74 | .. option:: -s, --succinct |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 75 | |
| 76 | Show less output, for example don't show information on tests that pass. |
| 77 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 78 | .. option:: -v, --verbose |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 79 | |
| 80 | Show more information on test failures, for example the entire test output |
| 81 | instead of just the test result. |
| 82 | |
George Karpenkov | 92aa19c | 2017-07-13 19:26:27 +0000 | [diff] [blame] | 83 | .. 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. |
Joel E. Denny | 1d95844 | 2018-05-31 00:55:32 +0000 | [diff] [blame] | 88 | :program:`lit` normally inserts a no-op command (``:`` in the case of bash) |
| 89 | with argument ``'RUN: at line N'`` before each command pipeline, and this |
| 90 | option also causes those no-op commands to be echoed to stdout to help you |
| 91 | locate the source line of the failed command. |
George Karpenkov | 92aa19c | 2017-07-13 19:26:27 +0000 | [diff] [blame] | 92 | This option implies ``--verbose``. |
| 93 | |
Matthias Braun | ec61a6a | 2015-11-06 01:13:40 +0000 | [diff] [blame] | 94 | .. option:: -a, --show-all |
| 95 | |
| 96 | Show more information about all tests, for example the entire test |
| 97 | commandline and output. |
| 98 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 99 | .. option:: --no-progress-bar |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 100 | |
| 101 | Do not use curses based progress bar. |
| 102 | |
Eric Fiselier | 156ce6c | 2014-07-31 20:11:13 +0000 | [diff] [blame] | 103 | .. option:: --show-unsupported |
| 104 | |
| 105 | Show the names of unsupported tests. |
| 106 | |
Eric Fiselier | 2785e77 | 2014-08-02 01:29:52 +0000 | [diff] [blame] | 107 | .. option:: --show-xfail |
| 108 | |
| 109 | Show the names of tests that were expected to fail. |
| 110 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 111 | .. _execution-options: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 112 | |
| 113 | EXECUTION OPTIONS |
| 114 | ----------------- |
| 115 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 116 | .. option:: --path=PATH |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 117 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 118 | Specify an additional ``PATH`` to use when searching for executables in tests. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 119 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 120 | .. option:: --vg |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 121 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 122 | Run individual tests under valgrind (using the memcheck tool). The |
| 123 | ``--error-exitcode`` argument for valgrind is used so that valgrind failures |
| 124 | will cause the program to exit with a non-zero status. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 125 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 126 | When this option is enabled, :program:`lit` will also automatically provide a |
| 127 | "``valgrind``" feature that can be used to conditionally disable (or expect |
| 128 | failure in) certain tests. |
Daniel Dunbar | f854597 | 2012-10-19 20:12:00 +0000 | [diff] [blame] | 129 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 130 | .. option:: --vg-arg=ARG |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 131 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 132 | When :option:`--vg` is used, specify an additional argument to pass to |
| 133 | :program:`valgrind` itself. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 134 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 135 | .. option:: --vg-leak |
Daniel Dunbar | f854597 | 2012-10-19 20:12:00 +0000 | [diff] [blame] | 136 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 137 | When :option:`--vg` is used, enable memory leak checks. When this option is |
| 138 | enabled, :program:`lit` will also automatically provide a "``vg_leak``" |
| 139 | feature that can be used to conditionally disable (or expect failure in) |
| 140 | certain tests. |
Daniel Dunbar | f854597 | 2012-10-19 20:12:00 +0000 | [diff] [blame] | 141 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 142 | .. option:: --time-tests |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 143 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 144 | Track the wall time individual tests take to execute and includes the results |
| 145 | in the summary output. This is useful for determining which tests in a test |
| 146 | suite take the most time to execute. Note that this option is most useful |
| 147 | with ``-j 1``. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 148 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 149 | .. _selection-options: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 150 | |
| 151 | SELECTION OPTIONS |
| 152 | ----------------- |
| 153 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 154 | .. option:: --max-tests=N |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 155 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 156 | Run at most ``N`` tests and then terminate. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 157 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 158 | .. option:: --max-time=N |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 159 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 160 | Spend at most ``N`` seconds (approximately) running tests and then terminate. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 161 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 162 | .. option:: --shuffle |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 163 | |
| 164 | Run the tests in a random order. |
| 165 | |
Graydon Hoare | 57f557b | 2017-01-18 18:12:20 +0000 | [diff] [blame] | 166 | .. option:: --num-shards=M |
| 167 | |
| 168 | Divide the set of selected tests into ``M`` equal-sized subsets or |
| 169 | "shards", and run only one of them. Must be used with the |
| 170 | ``--run-shard=N`` option, which selects the shard to run. The environment |
| 171 | variable ``LIT_NUM_SHARDS`` can also be used in place of this |
| 172 | option. These two options provide a coarse mechanism for paritioning large |
| 173 | testsuites, for parallel execution on separate machines (say in a large |
| 174 | testing farm). |
| 175 | |
| 176 | .. option:: --run-shard=N |
| 177 | |
| 178 | Select which shard to run, assuming the ``--num-shards=M`` option was |
| 179 | provided. The two options must be used together, and the value of ``N`` |
| 180 | must be in the range ``1..M``. The environment variable |
| 181 | ``LIT_RUN_SHARD`` can also be used in place of this option. |
| 182 | |
George Karpenkov | 80c7e63 | 2017-07-07 00:22:11 +0000 | [diff] [blame] | 183 | .. option:: --filter=REGEXP |
| 184 | |
| 185 | Run only those tests whose name matches the regular expression specified in |
| 186 | ``REGEXP``. The environment variable ``LIT_FILTER`` can be also used in place |
| 187 | of this option, which is especially useful in environments where the call |
| 188 | to ``lit`` is issued indirectly. |
| 189 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 190 | ADDITIONAL OPTIONS |
| 191 | ------------------ |
| 192 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 193 | .. option:: --debug |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 194 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 195 | Run :program:`lit` in debug mode, for debugging configuration issues and |
| 196 | :program:`lit` itself. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 197 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 198 | .. option:: --show-suites |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 199 | |
Daniel Dunbar | abb9de5 | 2013-08-08 20:59:25 +0000 | [diff] [blame] | 200 | List the discovered test suites and exit. |
| 201 | |
| 202 | .. option:: --show-tests |
| 203 | |
Eric Christopher | 933d2bd | 2015-06-19 01:53:21 +0000 | [diff] [blame] | 204 | List all of the discovered tests and exit. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 205 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 206 | EXIT STATUS |
| 207 | ----------- |
| 208 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 209 | :program:`lit` will exit with an exit code of 1 if there are any FAIL or XPASS |
| 210 | results. Otherwise, it will exit with the status 0. Other exit codes are used |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 211 | for non-test related failures (for example a user error or an internal program |
| 212 | error). |
| 213 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 214 | .. _test-discovery: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 215 | |
| 216 | TEST DISCOVERY |
| 217 | -------------- |
| 218 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 219 | The inputs passed to :program:`lit` can be either individual tests, or entire |
| 220 | directories or hierarchies of tests to run. When :program:`lit` starts up, the |
| 221 | first thing it does is convert the inputs into a complete list of tests to run |
| 222 | as part of *test discovery*. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 223 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 224 | In the :program:`lit` model, every test must exist inside some *test suite*. |
| 225 | :program:`lit` resolves the inputs specified on the command line to test suites |
| 226 | by searching upwards from the input path until it finds a :file:`lit.cfg` or |
| 227 | :file:`lit.site.cfg` file. These files serve as both a marker of test suites |
| 228 | and as configuration files which :program:`lit` loads in order to understand |
| 229 | how to find and run the tests inside the test suite. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 230 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 231 | Once :program:`lit` has mapped the inputs into test suites it traverses the |
| 232 | list of inputs adding tests for individual files and recursively searching for |
| 233 | tests in directories. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 234 | |
| 235 | This behavior makes it easy to specify a subset of tests to run, while still |
| 236 | allowing the test suite configuration to control exactly how tests are |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 237 | interpreted. In addition, :program:`lit` always identifies tests by the test |
| 238 | suite they are in, and their relative path inside the test suite. For |
| 239 | appropriately configured projects, this allows :program:`lit` to provide |
| 240 | convenient and flexible support for out-of-tree builds. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 241 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 242 | .. _test-status-results: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 243 | |
| 244 | TEST STATUS RESULTS |
| 245 | ------------------- |
| 246 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 247 | Each test ultimately produces one of the following six results: |
| 248 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 249 | **PASS** |
| 250 | |
| 251 | The test succeeded. |
| 252 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 253 | **XFAIL** |
| 254 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 255 | The test failed, but that is expected. This is used for test formats which allow |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 256 | specifying that a test does not currently work, but wish to leave it in the test |
| 257 | suite. |
| 258 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 259 | **XPASS** |
| 260 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 261 | The test succeeded, but it was expected to fail. This is used for tests which |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 262 | were specified as expected to fail, but are now succeeding (generally because |
| 263 | the feature they test was broken and has been fixed). |
| 264 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 265 | **FAIL** |
| 266 | |
| 267 | The test failed. |
| 268 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 269 | **UNRESOLVED** |
| 270 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 271 | The test result could not be determined. For example, this occurs when the test |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 272 | could not be run, the test itself is invalid, or the test was interrupted. |
| 273 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 274 | **UNSUPPORTED** |
| 275 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 276 | The test is not supported in this environment. This is used by test formats |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 277 | which can report unsupported tests. |
| 278 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 279 | Depending on the test format tests may produce additional information about |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 280 | their status (generally only for failures). See the :ref:`output-options` |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 281 | section for more information. |
| 282 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 283 | .. _lit-infrastructure: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 284 | |
| 285 | LIT INFRASTRUCTURE |
| 286 | ------------------ |
| 287 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 288 | This section describes the :program:`lit` testing architecture for users interested in |
| 289 | creating a new :program:`lit` testing implementation, or extending an existing one. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 290 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 291 | :program:`lit` proper is primarily an infrastructure for discovering and running |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 292 | arbitrary tests, and to expose a single convenient interface to these |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 293 | tests. :program:`lit` itself doesn't know how to run tests, rather this logic is |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 294 | defined by *test suites*. |
| 295 | |
| 296 | TEST SUITES |
| 297 | ~~~~~~~~~~~ |
| 298 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 299 | As described in :ref:`test-discovery`, tests are always located inside a *test |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 300 | suite*. Test suites serve to define the format of the tests they contain, the |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 301 | logic for finding those tests, and any additional information to run the tests. |
| 302 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 303 | :program:`lit` identifies test suites as directories containing ``lit.cfg`` or |
| 304 | ``lit.site.cfg`` files (see also :option:`--config-prefix`). Test suites are |
| 305 | initially discovered by recursively searching up the directory hierarchy for |
| 306 | all the input files passed on the command line. You can use |
| 307 | :option:`--show-suites` to display the discovered test suites at startup. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 308 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 309 | Once a test suite is discovered, its config file is loaded. Config files |
| 310 | themselves are Python modules which will be executed. When the config file is |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 311 | executed, two important global variables are predefined: |
| 312 | |
Eric Fiselier | 407460e | 2014-08-15 05:54:19 +0000 | [diff] [blame] | 313 | **lit_config** |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 314 | |
| 315 | The global **lit** configuration object (a *LitConfig* instance), which defines |
| 316 | the builtin test formats, global configuration parameters, and other helper |
| 317 | routines for implementing test configurations. |
| 318 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 319 | **config** |
| 320 | |
| 321 | This is the config object (a *TestingConfig* instance) for the test suite, |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 322 | which the config file is expected to populate. The following variables are also |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 323 | available on the *config* object, some of which must be set by the config and |
| 324 | others are optional or predefined: |
| 325 | |
| 326 | **name** *[required]* The name of the test suite, for use in reports and |
| 327 | diagnostics. |
| 328 | |
| 329 | **test_format** *[required]* The test format object which will be used to |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 330 | discover and run tests in the test suite. Generally this will be a builtin test |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 331 | format available from the *lit.formats* module. |
| 332 | |
Sergey Matveev | 52d65ab | 2013-05-30 12:37:52 +0000 | [diff] [blame] | 333 | **test_source_root** The filesystem path to the test suite root. For out-of-dir |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 334 | builds this is the directory that will be scanned for tests. |
| 335 | |
| 336 | **test_exec_root** For out-of-dir builds, the path to the test suite root inside |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 337 | the object directory. This is where tests will be run and temporary output files |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 338 | placed. |
| 339 | |
| 340 | **environment** A dictionary representing the environment to use when executing |
| 341 | tests in the suite. |
| 342 | |
| 343 | **suffixes** For **lit** test formats which scan directories for tests, this |
Dmitri Gribenko | 35f63dd | 2013-01-19 20:35:18 +0000 | [diff] [blame] | 344 | variable is a list of suffixes to identify test files. Used by: *ShTest*. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 345 | |
| 346 | **substitutions** For **lit** test formats which substitute variables into a test |
Dmitri Gribenko | 35f63dd | 2013-01-19 20:35:18 +0000 | [diff] [blame] | 347 | script, the list of substitutions to perform. Used by: *ShTest*. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 348 | |
| 349 | **unsupported** Mark an unsupported directory, all tests within it will be |
Dmitri Gribenko | 35f63dd | 2013-01-19 20:35:18 +0000 | [diff] [blame] | 350 | reported as unsupported. Used by: *ShTest*. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 351 | |
| 352 | **parent** The parent configuration, this is the config object for the directory |
| 353 | containing the test suite, or None. |
| 354 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 355 | **root** The root configuration. This is the top-most :program:`lit` configuration in |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 356 | the project. |
| 357 | |
Rafael Espindola | c1bb2d4 | 2013-07-26 22:32:58 +0000 | [diff] [blame] | 358 | **pipefail** Normally a test using a shell pipe fails if any of the commands |
| 359 | on the pipe fail. If this is not desired, setting this variable to false |
| 360 | makes the test fail only if the last command in the pipe fails. |
| 361 | |
Daniel Sanders | 26a5022 | 2016-07-26 13:23:27 +0000 | [diff] [blame] | 362 | **available_features** A set of features that can be used in `XFAIL`, |
| 363 | `REQUIRES`, and `UNSUPPORTED` directives. |
| 364 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 365 | TEST DISCOVERY |
| 366 | ~~~~~~~~~~~~~~ |
| 367 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 368 | Once test suites are located, :program:`lit` recursively traverses the source |
Sergey Matveev | 52d65ab | 2013-05-30 12:37:52 +0000 | [diff] [blame] | 369 | directory (following *test_source_root*) looking for tests. When :program:`lit` |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 370 | enters a sub-directory, it first checks to see if a nested test suite is |
| 371 | defined in that directory. If so, it loads that test suite recursively, |
| 372 | otherwise it instantiates a local test config for the directory (see |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 373 | :ref:`local-configuration-files`). |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 374 | |
| 375 | Tests are identified by the test suite they are contained within, and the |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 376 | relative path inside that suite. Note that the relative path may not refer to |
| 377 | an actual file on disk; some test formats (such as *GoogleTest*) define |
| 378 | "virtual tests" which have a path that contains both the path to the actual |
| 379 | test file and a subpath to identify the virtual test. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 380 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 381 | .. _local-configuration-files: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 382 | |
| 383 | LOCAL CONFIGURATION FILES |
| 384 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 385 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 386 | When :program:`lit` loads a subdirectory in a test suite, it instantiates a |
Jonathan Roelofs | f516614 | 2015-02-07 17:18:26 +0000 | [diff] [blame] | 387 | local test configuration by cloning the configuration for the parent directory |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 388 | --- the root of this configuration chain will always be a test suite. Once the |
| 389 | test configuration is cloned :program:`lit` checks for a *lit.local.cfg* file |
| 390 | in the subdirectory. If present, this file will be loaded and can be used to |
| 391 | specialize the configuration for each individual directory. This facility can |
| 392 | be used to define subdirectories of optional tests, or to change other |
| 393 | configuration parameters --- for example, to change the test format, or the |
| 394 | suffixes which identify test files. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 395 | |
Paul Robinson | 0a27f40 | 2016-04-04 17:14:45 +0000 | [diff] [blame] | 396 | PRE-DEFINED SUBSTITUTIONS |
| 397 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 398 | |
| 399 | :program:`lit` provides various patterns that can be used with the RUN command. |
David Bozier | 56b920f | 2017-02-09 14:12:30 +0000 | [diff] [blame] | 400 | These are defined in TestRunner.py. The base set of substitutions are: |
Paul Robinson | 0a27f40 | 2016-04-04 17:14:45 +0000 | [diff] [blame] | 401 | |
Jordan Rose | a17d200 | 2017-10-14 04:01:27 +0000 | [diff] [blame] | 402 | ========== ============== |
| 403 | Macro Substitution |
| 404 | ========== ============== |
| 405 | %s source path (path to the file currently being run) |
| 406 | %S source dir (directory of the file currently being run) |
| 407 | %p same as %S |
| 408 | %{pathsep} path separator |
| 409 | %t temporary file name unique to the test |
Kuba Mracek | d41a545 | 2018-08-25 01:27:48 +0000 | [diff] [blame] | 410 | %T parent directory of %t (not unique, deprecated, do not use) |
Jordan Rose | a17d200 | 2017-10-14 04:01:27 +0000 | [diff] [blame] | 411 | %% % |
| 412 | ========== ============== |
Paul Robinson | 0a27f40 | 2016-04-04 17:14:45 +0000 | [diff] [blame] | 413 | |
David Bozier | 56b920f | 2017-02-09 14:12:30 +0000 | [diff] [blame] | 414 | Other substitutions are provided that are variations on this base set and |
| 415 | further substitution patterns can be defined by each test module. See the |
| 416 | modules :ref:`local-configuration-files`. |
Paul Robinson | 0a27f40 | 2016-04-04 17:14:45 +0000 | [diff] [blame] | 417 | |
David Bozier | 56b920f | 2017-02-09 14:12:30 +0000 | [diff] [blame] | 418 | More detailed information on substitutions can be found in the |
Paul Robinson | 0a27f40 | 2016-04-04 17:14:45 +0000 | [diff] [blame] | 419 | :doc:`../TestingGuide`. |
| 420 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 421 | TEST RUN OUTPUT FORMAT |
| 422 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 423 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 424 | The :program:`lit` output for a test run conforms to the following schema, in |
| 425 | both short and verbose modes (although in short mode no PASS lines will be |
| 426 | shown). This schema has been chosen to be relatively easy to reliably parse by |
| 427 | a machine (for example in buildbot log scraping), and for other tools to |
| 428 | generate. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 429 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 430 | Each test result is expected to appear on a line that matches: |
| 431 | |
| 432 | .. code-block:: none |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 433 | |
Eli Bendersky | 1f9f73a | 2012-11-20 00:26:08 +0000 | [diff] [blame] | 434 | <result code>: <test name> (<progress info>) |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 435 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 436 | where ``<result-code>`` is a standard test result such as PASS, FAIL, XFAIL, |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 437 | XPASS, UNRESOLVED, or UNSUPPORTED. The performance result codes of IMPROVED and |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 438 | REGRESSED are also allowed. |
| 439 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 440 | The ``<test name>`` field can consist of an arbitrary string containing no |
| 441 | newline. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 442 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 443 | The ``<progress info>`` field can be used to report progress information such |
| 444 | as (1/300) or can be empty, but even when empty the parentheses are required. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 445 | |
| 446 | Each test result may include additional (multiline) log information in the |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 447 | following format: |
| 448 | |
| 449 | .. code-block:: none |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 450 | |
Eli Bendersky | 1f9f73a | 2012-11-20 00:26:08 +0000 | [diff] [blame] | 451 | <log delineator> TEST '(<test name>)' <trailing delineator> |
| 452 | ... log message ... |
| 453 | <log delineator> |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 454 | |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 455 | where ``<test name>`` should be the name of a preceding reported test, ``<log |
| 456 | delineator>`` is a string of "*" characters *at least* four characters long |
| 457 | (the recommended length is 20), and ``<trailing delineator>`` is an arbitrary |
| 458 | (unparsed) string. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 459 | |
| 460 | The following is an example of a test run output which consists of four tests A, |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 461 | B, C, and D, and a log message for the failing test C: |
| 462 | |
| 463 | .. code-block:: none |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 464 | |
| 465 | PASS: A (1 of 4) |
| 466 | PASS: B (2 of 4) |
| 467 | FAIL: C (3 of 4) |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 468 | ******************** TEST 'C' FAILED ******************** |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 469 | Test 'C' failed as a result of exit code 1. |
Dmitri Gribenko | e26b62c | 2012-11-29 17:05:34 +0000 | [diff] [blame] | 470 | ******************** |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 471 | PASS: D (4 of 4) |
| 472 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 473 | LIT EXAMPLE TESTS |
| 474 | ~~~~~~~~~~~~~~~~~ |
| 475 | |
Dmitri Gribenko | bc5fb06 | 2012-11-29 18:03:08 +0000 | [diff] [blame] | 476 | The :program:`lit` distribution contains several example implementations of |
| 477 | test suites in the *ExampleTests* directory. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 478 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 479 | SEE ALSO |
| 480 | -------- |
| 481 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 482 | valgrind(1) |