LIT(1)
๐ lit(1) โ LLVM Integrated Tester ๐
Okay bestie, meet lit(1), aka the LLVM Integrated Tester โ the portable tool for executing LLVM and Clang style test suites, summarizing their results, and giving you a heads-up when stuff fails. No cap, it's designed to be a lightweight testing tool with as simple a user interface as possible. ๐
โจ NAME โจ
lit โ LLVM Integrated Tester ๐
๐ SYNOPSIS ๐
lit [options] [tests]
๐ธ DESCRIPTION ๐ธ
You should run lit with one or more tests to run specified on the command line. Tests can be either individual test files or directories to search for tests (see TEST DISCOVERY). ๐
Each specified test will be executed (potentially concurrently), and once all tests have been run, lit will print summary information on the number of tests which passed or failed (see TEST STATUS RESULTS). The lit program will execute with a non-zero exit code if any tests fail. Periodt. ๐
By default, lit will use a succinct progress display and will only print summary information for test failures. See OUTPUT OPTIONS for options controlling the lit progress display and output. โจ
lit also includes a number of options for controlling how tests are executed (specific features may depend on the particular test format). See EXECUTION OPTIONS for more information. ๐ฆ
Finally, lit also supports additional options for only running a subset of the options specified on the command line โ see SELECTION OPTIONS for more information. ๐
lit parses options from the environment variable LIT_OPTS after parsing options from the command line. LIT_OPTS is primarily useful for supplementing or overriding the command-line options supplied to lit by check targets defined by a projectโs build system. ๐ซถ
lit can also read options from response files which are specified as inputs using the @path/to/file.rsp syntax. Arguments read from a file must be one per line and are treated as if they were in the same place as the original file referencing argument on the command line. A response file can reference other response files. ๐ง
Users interested in the lit architecture or designing a lit testing implementation should see LIT INFRASTRUCTURE. ๐
๐ GENERAL OPTIONS ๐
-h,--helpโ Show thelithelp message. ๐-j N,--workers=Nโ RunNtests in parallel. By default, this is automatically chosen to match the number of detected available CPUs. โก--config-prefix=NAMEโ Search forNAME.cfgandNAME.site.cfgwhen searching for test suites, instead oflit.cfgandlit.site.cfg. ๐-D NAME[=VALUE],--param NAME[=VALUE]โ Add a user defined parameterNAMEwith the givenVALUE(or the empty string if not given). The meaning and use of these parameters is test suite dependent. ๐๏ธ
๐ฆ OUTPUT OPTIONS ๐ฆ
-q,--quietโ Suppress any output except for test failures. ๐คซ-s,--succinctโ Show less output, for example donโt show information on tests that pass. Also show a progress bar, unless--no-progress-baris specified. ๐-v,--verboseโ Show more information on test failures, for example the entire test output instead of just the test result. ๐-vv,--echo-all-commandsโ On test failure, echo all commands to stdout as they are being executed. This can be valuable for debugging test failures, as the last echoed command will be the one which has failed.litnormally inserts a no-op command (:in the case of bash) with argument'RUN: at line N'before each command pipeline, and this option also causes those no-op commands to be echoed to stdout to help you locate the source line of the failed command. This option implies--verbose. ๐-a,--show-allโ Show more information about all tests, for example the entire test commandline and output. ๐--no-progress-barโ Do not use curses based progress bar. ๐ซ--show-unsupportedโ Show the names of unsupported tests. ๐--show-xfailโ Show the names of tests that were expected to fail. ๐
๐ฅ EXECUTION OPTIONS ๐ฅ
--path=PATHโ Specify an additionalPATHto use when searching for executables in tests. ๐ฃ๏ธ--vgโ Run individual tests under valgrind (using the memcheck tool). The--error-exitcodeargument for valgrind is used so that valgrind failures will cause the program to exit with a non-zero status.
When this option is enabled, lit will also automatically provide a โvalgrindโ feature that can be used to conditionally disable (or expect failure in) certain tests. ๐งช
--vg-arg=ARGโ When--vgis used, specify an additional argument to pass to valgrind itself. ๐งฐ--vg-leakโ When--vgis used, enable memory leak checks. When this option is enabled,litwill also automatically provide avg_leakfeature that can be used to conditionally disable (or expect failure in) certain tests. ๐ง--time-testsโ Track the wall time individual tests take to execute and includes the results in the summary output. This is useful for determining which tests in a test suite take the most time to execute. โฑ๏ธ--ignore-failโ Exit with status zero even if some tests fail. ๐
๐ SELECTION OPTIONS ๐
By default, lit will run failing tests first, then run tests in descending execution time order to optimize concurrency. The execution order can be changed using the --order option. ๐
The timing data is stored in the test_exec_root in a file named .lit_test_times.txt. If this file does not exist, then lit checks the test_source_root for the file to optionally accelerate clean builds. ๐
--shuffleโ Run the tests in a random order, not failing/slowest first. Deprecated, use--orderinstead. ๐ฒ--max-failures Nโ Stop execution after the given numberNof failures. An integer argument should be passed on the command line prior to execution. ๐--max-tests=Nโ Run at mostNtests and then terminate. ๐ข--max-time=Nโ Spend at mostNseconds (approximately) running tests and then terminate. Note that this is not an alias for--timeout; the two are different kinds of maximums. โณ--num-shards=Mโ Divide the set of selected tests intoMequal-sized subsets or โshardsโ, and run only one of them. Must be used with the--run-shard=Noption, which selects the shard to run. The environment variableLIT_NUM_SHARDScan also be used in place of this option. These two options provide a coarse mechanism for partitioning large testsuites, for parallel execution on separate machines (say in a large testing farm). ๐--order={lexical,random,smart}โ Define the order in which tests are run. The supported values are:lexicalโ tests will be run in lexical order according to the test file path. This option is useful when predictable test order is desired. ๐คrandomโ tests will be run in random order. ๐ฐsmartโ tests that failed previously will be run first, then the remaining tests, all in descending execution time order. This is the default as it optimizes concurrency. ๐ง
--run-shard=Nโ Select which shard to run, assuming the--num-shards=Moption was provided. The two options must be used together, and the value ofNmust be in the range1..M. The environment variableLIT_RUN_SHARDcan also be used in place of this option. ๐งฉ--timeout=Nโ Spend at mostNseconds (approximately) running each individual test.0means no time limit, and0is the default. Note that this is not an alias for--max-time; the two are different kinds of maximums. โฒ๏ธ--filter=REGEXPโ Run only those tests whose name matches the regular expression specified inREGEXP. The environment variableLIT_FILTERcan be also used in place of this option, which is especially useful in environments where the call tolitis issued indirectly. ๐ฏ--filter-out=REGEXPโ Filter out those tests whose name matches the regular expression specified inREGEXP. The environment variableLIT_FILTER_OUTcan be also used in place of this option, which is especially useful in environments where the call tolitis issued indirectly. ๐ฎ--xfail=LISTโ Treat those tests whose name is in the semicolon separated listLISTas XFAIL. This can be helpful when one does not want to modify the test suite. The environment variableLIT_XFAILcan be also used in place of this option, which is especially useful in environments where the call tolitis issued indirectly.
A test name can specified as a file name relative to the test suite directory. For example:
LIT_XFAIL="affinity/kmp-hw-subset.c;offloading/memory_manager.cpp"
In this case, all of the following tests are treated as XFAIL:
libomp :: affinity/kmp-hw-subset.c
libomptarget :: nvptx64-nvidia-cuda :: offloading/memory_manager.cpp
libomptarget :: x86_64-pc-linux-gnu :: offloading/memory_manager.cpp
Alternatively, a test name can be specified as the full test name reported in LIT output. For example, we can adjust the previous example not to treat the nvptx64-nvidia-cuda version of offloading/memory_manager.cpp as XFAIL:
LIT_XFAIL="affinity/kmp-hw-subset.c;libomptarget :: x86_64-pc-linux-gnu :: offloading/memory_manager.cpp"
--xfail-not=LISTโ Do not treat the specified tests as XFAIL. The environment variableLIT_XFAIL_NOTcan also be used in place of this option. The syntax is the same as for--xfailandLIT_XFAIL.--xfail-notandLIT_XFAIL_NOTalways override all other XFAIL specifications, including an--xfailappearing later on the command line. The primary purpose is to suppress an XPASS result without modifying a test case that uses the XFAIL directive. ๐
โญ ADDITIONAL OPTIONS โญ
--debugโ Runlitin debug mode, for debugging configuration issues andlititself. ๐--show-suitesโ List the discovered test suites and exit. ๐๏ธ--show-testsโ List all of the discovered tests and exit. ๐
๐ EXIT STATUS ๐
lit will exit with an exit code of 1 if there are any FAIL or XPASS results. Otherwise, it will exit with the status 0. Other exit codes are used for non-test related failures (for example a user error or an internal program error). ๐ฏ
๐ธ TEST DISCOVERY ๐ธ
Okay so bestie, the inputs you pass to lit can be either individual tests, or entire directories or whole hierarchies of tests to run. When lit starts up, the first thing it does is convert the inputs into a complete list of tests to run as part of test discovery. ๐
In the lit model, every test must exist inside some test suite. lit resolves the inputs specified on the command line to test suites by searching upwards from the input path until it finds a lit.cfg or lit.site.cfg file. These files serve as both a marker of test suites and as configuration files which lit loads in order to understand how to find and run the tests inside the test suite.
Once lit has mapped the inputs into test suites it traverses the list of inputs adding tests for individual files and recursively searching for tests in directories.
This behavior makes it easy to specify a subset of tests to run, while still allowing the test suite configuration to control exactly how tests are interpreted. In addition, lit always identifies tests by the test suite they are in, and their relative path inside the test suite. For appropriately configured projects, this allows lit to provide convenient and flexible support for out-of-tree builds. โจ
๐ TEST STATUS RESULTS ๐
Each test ultimately produces one of the following eight results:
PASSโ The test succeeded. ๐FLAKYPASSโ The test succeeded after being re-run more than once. This only applies to tests containing anALLOW_RETRIES:annotation.XFAILโ The test failed, but that is expected. This is used for test formats which allow specifying that a test does not currently work, but wish to leave it in the test suite. ๐XPASSโ The test succeeded, but it was expected to fail. This is used for tests which were specified as expected to fail, but are now succeeding (generally because the feature they test was broken and has been fixed).FAILโ The test failed. ๐ญUNRESOLVEDโ The test result could not be determined. For example, this occurs when the test could not be run, the test itself is invalid, or the test was interrupted.UNSUPPORTEDโ The test is not supported in this environment. This is used by test formats which can report unsupported tests.TIMEOUTโ The test was run, but it timed out before it was able to complete. This is considered a failure. ๐
Depending on the test format tests may produce additional information about their status (generally only for failures). See the OUTPUT OPTIONS section for more information.
๐ง LIT INFRASTRUCTURE ๐ง
This section describes the lit testing architecture for users interested in creating a new lit testing implementation, or extending an existing one.
lit proper is primarily an infrastructure for discovering and running arbitrary tests, and to expose a single convenient interface to these tests. lit itself doesnโt know how to run tests, rather this logic is defined by test suites. ๐ฆ
๐ TEST SUITES ๐
As described in TEST DISCOVERY, tests are always located inside a test suite. Test suites serve to define the format of the tests they contain, the logic for finding those tests, and any additional information to run the tests.
lit identifies test suites as directories containing lit.cfg or lit.site.cfg files (see also --config-prefix). Test suites are initially discovered by recursively searching up the directory hierarchy for all the input files passed on the command line. You can use --show-suites to display the discovered test suites at startup. ๐
Once a test suite is discovered, its config file is loaded. Config files themselves are Python modules which will be executed. When the config file is executed, two important global variables are predefined:
lit_configโ The globallitconfiguration object (aLitConfiginstance), which defines the builtin test formats, global configuration parameters, and other helper routines for implementing test configurations.configโ This is the config object (aTestingConfiginstance) for the test suite, which the config file is expected to populate. The following variables are also available on theconfigobject, some of which must be set by the config and others are optional or predefined:name[required] โ The name of the test suite, for use in reports and diagnostics.test_format[required] โ The test format object which will be used to discover and run tests in the test suite. Generally this will be a builtin test format available from thelit.formatsmodule.test_source_rootโ The filesystem path to the test suite root. For out-of-dir builds this is the directory that will be scanned for tests.test_exec_rootโ For out-of-dir builds, the path to the test suite root inside the object directory. This is where tests will be run and temporary output files placed.environmentโ A dictionary representing the environment to use when executing tests in the suite.standalone_testsโ When true, mark a directory with tests expected to be run standalone. Test discovery is disabled for that directory.lit.suffixesandlit.excludesmust be empty when this variable is true.suffixesโ Forlittest formats which scan directories for tests, this variable is a list of suffixes to identify test files. Used by:ShTest.substitutionsโ Forlittest formats which substitute variables into a test script, the list of substitutions to perform. Used by:ShTest.unsupportedโ Mark an unsupported directory, all tests within it will be reported as unsupported. Used by:ShTest.parentโ The parent configuration, this is the config object for the directory containing the test suite, orNone.rootโ The root configuration. This is the top-mostlitconfiguration in the project.pipefailโ Normally a test using a shell pipe fails if any of the commands on the pipe fail. If this is not desired, setting this variable to false makes the test fail only if the last command in the pipe fails.available_featuresโ A set of features that can be used inXFAIL,REQUIRES, andUNSUPPORTEDdirectives.
๐ฆ TEST DISCOVERY ๐ฆ
Once test suites are located, lit recursively traverses the source directory (following test_source_root) looking for tests. When lit enters a sub-directory, it first checks to see if a nested test suite is defined in that directory. If so, it loads that test suite recursively, otherwise it instantiates a local test config for the directory (see LOCAL CONFIGURATION FILES). ๐
Tests are identified by the test suite they are contained within, and the relative path inside that suite. Note that the relative path may not refer to an actual file on disk; some test formats (such as GoogleTest) define โvirtual testsโ which have a path that contains both the path to the actual test file and a subpath to identify the virtual test. ๐ฅ
๐ LOCAL CONFIGURATION FILES ๐
When lit loads a subdirectory in a test suite, it instantiates a local test configuration by cloning the configuration for the parent directory โ the root of this configuration chain will always be a test suite. Once the test configuration is cloned lit checks for a lit.local.cfg file in the subdirectory. If present, this file will be loaded and can be used to specialize the configuration for each individual directory. This facility can be used to define subdirectories of optional tests, or to change other configuration parameters โ for example, to change the test format, or the suffixes which identify test files. ๐
๐ธ SUBSTITUTIONS ๐ธ
ok so <pink>lit</pink> is literally that girl who lets you put patterns inside RUN commands, and it also hands you this whole base set of substitutions for free โ no cap, they're all defined in TestRunner.py:
%sโ the source path (i.e. the path to the file that's currently being run, bestie)%Sโ the source dir (the directory of the file currently being run)%pโ literally the same thing as%S%{pathsep}โ the path separator ๐%{fs-src-root}โ the root component of file system paths that point to the LLVM checkout%{fs-tmp-root}โ the root component of file system paths that point to the test's temporary directory%{fs-sep}โ the file system path separator%tโ a temporary file name that's unique to the test โจ%basename_tโ the last path component of%t, but with the.tmpextension stripped off%Tโ the parent directory of%tโ ๏ธ (not unique, deprecated, do not use โ I'm serious, don't)%%โ a literal%%/sโ%sbut every\gets replaced by/%/Sโ%Sbut\gets replaced by/%/pโ%pbut\gets replaced by/%/tโ%tbut\gets replaced by/%/Tโ%Tbut\gets replaced by/%{/s:regex_replacement}โ%/sbut escaped so it's safe to use in the replacement of ans@@@command insed%{/S:regex_replacement}โ%/Sbut escaped for use in the replacement of ans@@@command insed%{/p:regex_replacement}โ%/pbut escaped for use in the replacement of ans@@@command insed%{/t:regex_replacement}โ%/tbut escaped for use in the replacement of ans@@@command insed%{/T:regex_replacement}โ%/Tbut escaped for use in the replacement of ans@@@command insed%:sโ on Windows,%/sbut a:gets removed if it's the second character. Otherwise it's%sbut with a single leading/removed. ๐ช%:Sโ on Windows,%/Sbut a:gets removed if it's the second character. Otherwise it's%Sbut with a single leading/removed.%:pโ on Windows,%/pbut a:gets removed if it's the second character. Otherwise it's%pbut with a single leading/removed.%:tโ on Windows,%/tbut a:gets removed if it's the second character. Otherwise it's%tbut with a single leading/removed.%:Tโ on Windows,%/Tbut a:gets removed if it's the second character. Otherwise it's%Tbut with a single leading/removed.
There's also a whole other pile of substitutions that are just variations on this base set, and each test module can define even more substitution patterns of its own โ go peek at the modules in LOCAL CONFIGURATION FILES for that. ๐
And if you want the full deep-dive on substitutions, it lives in the LLVM Testing Infrastructure Guide <>. ๐
โญ TEST RUN OUTPUT FORMAT โญ
The <pink>lit</pink> output for a test run follows this schema in both short and verbose modes โ though heads up, in short mode you won't see any PASS lines at all. ๐
Why this schema? Because it's designed to be relatively easy for a machine to reliably parse (think buildbot log scraping, iykyk), and for other tools to generate too. It's giving thoughtful. ๐
Every test result is expected to show up on a line that matches this, exactly:
<result code>: <test name> (<progress info>)
Where <result-code> is a standard test result like PASS, FAIL, XFAIL, XPASS, UNRESOLVED, or UNSUPPORTED. And the performance result codes IMPROVED and REGRESSED are also allowed in there. ๐ฅ
So like, the <test name> field? It can literally be any arbitrary string you want โ just no newlines in it, okay? Keep it on one line bestie. ๐
The <progress info> field is where you flex your progress like (1/300), or you can leave it empty โ but the parentheses? required either way. Not optional. No cap.
Each test result can also carry extra multiline log info, formatted exactly like this:
<log delineator> TEST '(<test name>)' <trailing delineator>
... log message ...
<log delineator>
Where <test name> should match the name of a test you already reported (so we know who's being dragged ๐ญ), <log delineator> is a string of * characters at least four characters long โ recommended length is 20, go big or go home โ and <trailing delineator> is an arbitrary string that just gets ignored, unparsed. Slay.
Okay so here's a full example run with four tests โ A, B, C, and D โ plus the log message for the failing test C:
PASS: A (1 of 4)
PASS: B (2 of 4)
FAIL: C (3 of 4)
******************** TEST 'C' FAILED ********************
Test 'C' failed as a result of exit code 1.
********************
PASS: D (4 of 4)
C really said "not today" and took the whole vibe down with it ๐ but look at that formatting! Iconic.
๐ง LIT EXAMPLE TESTS ๐ง
The lit distribution ships with several example implementations of test suites chilling in the ExampleTests directory. Go look, bestie โ free real estate. โจ
๐ฆ SEE ALSO ๐ฆ
valgrind(1)โ yeah, that one. It's in the list. ๐ซถ
๐ Author ๐
Maintained by the LLVM Team (https://llvm.org/). The main characters, honestly. ๐
๐ธ Copyright ๐ธ
2003-2026, LLVM Project โ all the rights, all the years, all the vibes. ๐
And that's a wrap on LIT(1), bestie! This lil masterpiece is lit version 15, dated 2026-09-09, and it's giving documentation main character energy fr fr. Go forth and run your tests. Periodt. ๐
โจ๐
๐ฆ where this page comes from
- ubuntu stonking: llvm-17 1:17.0.6-23ubuntu10 ยท APACHE-2-LLVM-EXCEPTIONS
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms