LIT(1)
π NAME π
lit β LLVM Integrated Tester π«Ά (yes bestie, this is the LIT(1) page, and we're gonna make it make sense β¨)
πΈ SYNOPSIS πΈ
lit [options] [tests]
π¦ DESCRIPTION π¦
Okay so lit is this portable tool for executing LLVM and Clang style test suites, summarizing their results, and giving you an indication of failures. It's designed to be a lightweight testing tool with as simple a user interface as possible. Iconic behavior, honestly π
.
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. No cap, failure is not the vibe π.
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. It's giving recursion, but make it practical π.
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β Run N tests in parallel. By default, this is automatically chosen to match the number of detected available CPUs. Main character scheduling energy π₯.--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.
Each command is printed before it is executed. This can be valuable for debugging test failures, as the last printed command is the one that failed. Moreover, lit inserts RUN: at line N before each command pipeline in the output to help you locate the source line of the failed command. Detective mode activated π.
-vv,--echo-all-commandsβ Deprecated alias for-v. Deprecated alert π¨ β it's just being-v's understudy.-a,--show-allβ Enable-v, but for all tests not just failed tests.--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 a"vg_leak"feature that can be used to conditionally disable (or expect failure in) certain tests.--skip-test-time-recordingβ Disable tracking the wall time individual tests take to execute.--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. Slow-test reveal era β±οΈ.--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.--per-test-coverageβ Emit the necessary test coverage data, divided per test case (involves setting a unique value toLLVM_PROFILE_FILEfor eachRUN). The coverage data files will be emitted in the directory specified byconfig.test_exec_root.--max-failures Nβ Stop execution after the given number N of failures. An integer argument should be passed on the command line prior to execution.--max-tests=Nβ Run at most N tests and then terminate.--max-time=Nβ Spend at most N seconds (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 into M equal-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 of N must be in the range1..M. The environment variableLIT_RUN_SHARDcan also be used in place of this option.--timeout=Nβ Spend at most N seconds (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 listLISTasXFAIL. 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 asXFAIL. 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 otherXFAILspecifications, including an--xfailappearing later on the command line. The primary purpose is to suppress anXPASSresult without modifying a test case that uses theXFAILdirective. Override queen behavior π.
π 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 (the β¨main characterβ¨ of startup)
Okay so bestie, the inputs you hand to lit can be literally anything β individual tests, whole directories, or entire hierarchies of tests you want to run. When lit starts up, the very first thing it does is turn those inputs into one complete list of tests to run. That whole process is called test discovery. π
In the lit model, every single test has to exist inside some test suite. No exceptions, no lone wolves. lit figures out which suites your inputs belong to by searching upwards from the input path until it finds a lit.cfg or lit.site.cfg file. Those files are doing double duty, bestie β they're both the marker that says "yep, this is a test suite" and the configuration files that lit loads so it knows how to find and run the tests inside that suite. Iconic behavior honestly. π
Once lit has mapped the inputs into test suites, it walks the list of inputs adding tests for individual files and recursively hunting for tests in directories. π΅οΈββοΈ
The way this makes life easy: you can specify a subset of tests to run while still letting the test suite config control exactly how tests are interpreted. And lit always identifies tests by the test suite they're in plus their relative path inside that test suite. For appropriately configured projects, that's what gives lit its convenient and flexible support for out-of-tree builds. We love to see it. π¦
π TEST STATUS RESULTS
Every test ultimately produces one of these eight results. Learn them, love them, memorize them. π
PASSβ the test succeeded. Slay. β¨FLAKYPASSβ the test succeeded after being re-run more than once. This only applies to tests containing anALLOW_RETRIES:annotation. She was being dramatic and then pulled through. πXFAILβ the test failed, but that's expected. This is used for test formats which allow specifying that a test does not currently work, but you still want to leave it in the test suite.XPASSβ the test succeeded, but it was expected to fail. 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. A surprise win, lowkey. πΈFAILβ the test failed. πUNRESOLVEDβ the test result could not be determined. For example, this happens when the test couldn't 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 info on that. π«Ά
π οΈ LIT INFRASTRUCTURE
This section describes the lit testing architecture for users interested in creating a new lit testing implementation, or extending an existing one. So likeβ¦ if you wanna build your own, this is the blueprint. π
lit proper is primarily an infrastructure for discovering and running arbitrary tests, and for exposing a single convenient interface to those tests. Here's the thing: lit itself doesn't know how to run tests. That logic is defined by test suites. It's giving delegator energy and honestly? Respect. π
π§ 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 needed 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 gets 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 global lit configuration 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 the config object β some of them must be set by the config, and the others are optional or predefined. Buckle up bestie, there's a lot. π
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β For lit test formats which scan directories for tests, this variable is a list of suffixes to identify test files. Used by:ShTest.substitutionsβ For lit test 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-most lit configuration 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.
π Quick vibe check:nameandtest_formatare marked[required]. Do not skip them, bestie, the config will not be okay about it.
π TEST DISCOVERY (yes, again β this one's the infra-level tea)
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're 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. Spooky but valid. π»
π 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 β and 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. Main character energy for a tiny config file, honestly. π
π SUBSTITUTIONS π
Okay so this part is genuinely iconic β lit lets you sub in patterns inside RUN commands, so you're not out here hardcoding paths like a loser. It also hands you this base set of substitutions for free, all of which are defined in TestRunner.py:
%sβ source path (the path to the file that's currently being run)%Sβ source dir (the directory of the file currently being run)%pβ same thing as%S, no cap%{pathsep}β 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}β 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β parent directory of%t. Heads up bestie: this one is not unique, it's deprecated, and the manpage literally says do not use. π%%β just a literal%%/sβ%s, but every\gets replaced by/%/Sβ%S, but every\gets replaced by/%/pβ%p, but every\gets replaced by/%/tβ%t, but every\gets replaced by/%/Tβ%T, but every\gets replaced by/%{s:real}β%safter expanding all symbolic links and substitute drives%{S:real}β%Safter expanding all symbolic links and substitute drives%{p:real}β%pafter expanding all symbolic links and substitute drives%{t:real}β%tafter expanding all symbolic links and substitute drives%{T:real}β%Tafter expanding all symbolic links and substitute drives%{/s:real}β%/safter expanding all symbolic links and substitute drives%{/S:real}β%/Safter expanding all symbolic links and substitute drives%{/p:real}β%/pafter expanding all symbolic links and substitute drives%{/t:real}β%/tafter expanding all symbolic links and substitute drives%{/T:real}β%/Tafter expanding all symbolic links and substitute drives%{/s:regex_replacement}β%/s, but escaped so you can drop it into the replacement of as@@@command insed%{/S:regex_replacement}β%/S, but escaped so you can drop it into the replacement of as@@@command insed%{/p:regex_replacement}β%/p, but escaped so you can drop it into the replacement of as@@@command insed%{/t:regex_replacement}β%/t, but escaped so you can drop it into the replacement of as@@@command insed%{/T:regex_replacement}β%/T, but escaped so you can drop it into the replacement of as@@@command insed
Likeβ¦ the :real girlies are doing the absolute most (resolving every symlink and substituting drives) and the regex_replacement girlies are out here pre-escaping themselves so sed doesn't choke. Both are valid. Both are slay. π¦
okay so picking up right where we left off in the substitution chart, no cap π
%:sβ On Windows,%/sbut a:is removed if its the second character. Otherwise,%sbut with a single leading/removed.%:Sβ On Windows,%/Sbut a:is removed if its the second character. Otherwise,%Sbut with a single leading/removed.%:pβ On Windows,%/pbut a:is removed if its the second character. Otherwise,%pbut with a single leading/removed.%:tβ On Windows,%/tbut a:is removed if its the second character. Otherwise,%tbut with a single leading/removed.%:Tβ On Windows,%/Tbut a:is removed if its the second character. Otherwise,%Tbut with a single leading/removed.
Other substitutions are provided that are variations on this base set, and further substitution patterns can be defined by each test module. See the modules LOCAL CONFIGURATION FILES π
More detailed information on substitutions can be found in the LLVM Testing Infrastructure Guide <>. π¦
β¨ TEST RUN OUTPUT FORMAT β¨
The lit output for a test run conforms to the following schema, in both short and verbose modes (although in short mode no PASS lines will be shown). This schema has been chosen to be relatively easy to reliably parse by a machine (for example in buildbot log scraping), and for other tools to generate. periodt π«Ά
Each test result is expected to appear on a line that matches:
<result code>: <test name> (<progress info>)
where <result-code> is a standard test result such as PASS, FAIL, XFAIL, XPASS, UNRESOLVED, or UNSUPPORTED. The performance result codes of IMPROVED and REGRESSED are also allowed. π₯
The <test name> field can consist of an arbitrary string containing no newline.
The <progress info> field can be used to report progress information such as (1/300) or can be empty, but even when empty the parentheses are required. literally do not skip the parentheses bestie π
Each test result may include additional (multiline) log information in the following format:
<log delineator> TEST '(<test name>)' <trailing delineator>
... log message ...
<log delineator>
where <test name> should be the name of a preceding reported test, <log delineator> is a string of * characters at least four characters long (the recommended length is 20), and <trailing delineator> is an arbitrary (unparsed) string. π
The following is an example of a test run output which consists of four tests A, B, C, and D, and a 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)
π DEFAULT FEATURES π
For convenience lit automatically adds available_features for some common use cases. π
lit adds a feature based on the operating system being built on, for example: system-darwin, system-linux, etc. lit also automatically adds a feature based on the current architecture, for example target-x86_64, target-aarch64, etc. π§
When building with sanitizers enabled, lit automatically adds the short name of the sanitizer, for example: asan, tsan, etc. π
To see the full list of features that can be added, see llvm/utils/lit/lit/llvm/config.py. β
π¦ LIT EXAMPLE TESTS π¦
The lit distribution contains several example implementations of test suites in the ExampleTests directory. slay, examples are iconic π
πΈ SEE ALSO πΈ
π Author π
Maintained by the LLVM Team (https://llvm.org/). π«Ά
π Copyright π
2003-2026, LLVM Project
mwah π that was LIT(1), version 15, dated 2026-09-09 β now go make those tests behave, bestie, fr fr β¨π
π
π¦ where this page comes from
- ubuntu stonking: llvm-19 1:19.1.7-20ubuntu8 Β· 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