LIT(1)
π LIT(1) β lit, the LLVM Integrated Tester π
πΈ NAME πΈ
lit β LLVM Integrated Tester π
β¨ SYNOPSIS β¨
lit [options] [tests]
π DESCRIPTION π
Okay bestie, so lit is this portable tool for executing LLVM and Clang style test suites, summarizing their results, and giving you a heads-up when failures happen. 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. π
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 and exit. π«Ά--versionβ Showlitβs version number and exit. β¨-j N,--workers Nβ RunNtests in parallel. By default, this is automatically chosen to match the number of detected available CPUs. Slay, parallelism. β‘--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. Peace and quiet, but make it test-result-specific. π€«-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. Cute and compact. π-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 after each command pipeline in the output to help you locate the source line of the failed command. Very main character debugging energy. π
-vv,--echo-all-commandsβ Deprecated alias for-v. Itβs giving legacy, but we still list it. π-a,--show-allβ Enable-v, but for all tests not just failed tests. Show everything, bestie. π-o PATH,--output PATHβ Write test results to the provided path. π--no-progress-barβ Do not use curses based progress bar. No curses, no drama. π«--show-excludedβ Show excluded tests. π--show-skippedβ Show skipped tests. βοΈ--show-unsupportedβ Show unsupported tests. π«--show-passβ Show passed tests. β--show-flakypassβ Show passed with retry tests. π--show-xfailβ Show expectedly failed tests. π
π₯ EXECUTION OPTIONS π₯
--gtest-shardingβ Enable sharding for GoogleTest format. π§©--no-gtest-shardingβ Disable sharding for GoogleTest format. π«--path PATHβ Specify an additionalPATHto use when searching for executables in tests. π--vgβ Run individual tests under valgrind (using thememchecktool). 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-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. π«§--vg-arg ARGβ When--vgis used, specify an additional argument to pass to valgrind itself. π--no-executeβ Donβt execute any tests (assume that they pass). Manifesting all passes, no running. β¨--xunit-xml-output XUNIT_XML_OUTPUTβ Write XUnit-compatible XML test reports to the specified file. π--report-failures-onlyβ Only include failures (see TEST STATUS RESULTS) in the report. π--resultdb-output RESULTDB_OUTPUTβ Write LuCI ResultDB compatible JSON to the specified file. π¦--time-trace-output TIME_TRACE_OUTPUTβ Write Chrome tracing compatible JSON to the specified file. π--timeout MAXINDIVIDUALTESTTIMEβ Maximum time to spend running a single test (in seconds).0means no time limit.[Default: 0]β±οΈ--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. π«--max-failures MAX_FAILURESβ Stop execution after the given number of failures. π--max-retries-per-test Nβ Retry running failed tests at mostNtimes. Out of the following options to rerun failed tests the--max-retries-per-testis the only one that doesnβt require a change in the test scripts or the test config: π--max-retries-per-testlit optionconfig.test_retry_attemptstest suite optionALLOW_RETRIES:annotation in test script
Any option in the list above overrules its predecessor. π
--allow-empty-runsβ Do not fail the run if all tests are filtered out. Empty run said no thank you to failing. π«Ά--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. π--ignore-failβ Exit with status zero even if some tests fail. Ignoring the haters, exit-code edition. π--skip-test-time-recordingβ Do not track elapsed wall time for each test. βοΈ--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. π°οΈ
π― SELECTION OPTIONS π―
ok so bestie, here's the vibe: by default lit runs the failing tests first, then runs everything else in descending execution time order, because that's what optimizes concurrency β¨. You can change that whole order thing with --order, iykyk.
The timing data lives in the test_exec_root in a file literally named .lit_test_times.txt. If that file doesn't exist? No stress β lit checks the test_source_root for the file, so it can optionally speed up clean builds π
.
--max-tests Nβ Run at mostNtests, then terminate. That's it, that's the whole thing π--max-time Nβ Spend at mostNseconds (approximately) running tests, then terminate. And listen β this is not an alias for--timeout. The two are different kinds of maximums, fr fr π«Ά--order {lexical,random,smart}β Defines the order in which tests are run. The supported values are:lexicalβ tests get run in lexical order according to the test file path. Iconic when you want predictable test order πΈrandomβ tests get run in random order. chaos, but make it intentional πsmartβ tests that failed previously get run first, then the remaining tests, all in descending execution time order. This is the default because it optimizes concurrency π
--shuffleβ Run the tests in a random order, not failing/slowest first. Deprecated, use--orderinstead π-i,--incrementalβ Run failed tests first (DEPRECATED: use--order=smart). bestie it's literally right there π--filter REGEXPβ Run only those tests whose name matches the regular expression specified inREGEXP. The environment variableLIT_FILTERcan also be 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 also be 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 also be used in place of this option, which is especially useful in environments where the call tolitis issued indirectly π¦
A test name can be 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 other XFAIL specifications, including an--xfailappearing later on the command line. The primary purpose is to suppress anXPASSresult without modifying a test case that uses theXFAILdirective π--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) π§--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 π
π οΈ 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 π--show-used-featuresβ Show all features used in the test suite (inXFAIL,UNSUPPORTEDandREQUIRES) and exit β
πͺ EXIT STATUS πͺ
lit exits with an exit code of 1 if there are any failures (see TEST STATUS RESULTS) and --ignore-fail has not been passed. Otherwise, it exits with the status 0. Other exit codes get used for non-test related failures β think a user error or an internal program error, no cap π
π TEST DISCOVERY π
The inputs you pass to lit can be either individual tests, or entire directories or hierarchies of tests to run. When lit starts up, the very 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 π
Every single test ultimately produces one of the following eight results. Eight of them. bestie, count 'em π
PASS
The test succeeded. slay π
FLAKYPASS
The test succeeded after being re-run more than once. This only applies to tests containing an ALLOW_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 β°
Unresolved (UNRESOLVED), timed out (TIMEOUT), failed (FAIL) and unexpectedly passed (XPASS) tests are considered failures. like, all four of them. no wiggle room π₯
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 a directory as unsupported and every single test inside it gets reported as unsupported, no questions asked π . Used by: ShTest.parentβ the parent configuration, aka the config object for the directory that contains the test suite. Can also beNone, because sometimes you simply have no parent (it happens).rootβ the root configuration, bestie. This is the top-most lit configuration in the whole entire project π.pipefailβ okay so normally a test that uses a shell pipe fails if any command on the pipe fails. If that's not the vibe you want, set this tofalseand the test fails only if the last command in the pipe fails π«Ά.available_featuresβ a whole set of features you can use inXFAIL,REQUIRES, andUNSUPPORTEDdirectives β¨.
π TEST DISCOVERY π
So once test suites are located, lit recursively traverses the source directory (following test_source_root, obviously) 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 β slay β it loads that test suite recursively. Otherwise it instantiates a local test config for the directory (see LOCAL CONFIGURATION FILES below, iykyk).
Tests are identified by the test suite they're contained within, plus the relative path inside that suite. And heads up: that relative path may not refer to an actual file on disk! Some test formats (like GoogleTest, we love you) 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 π¦. It's giving inception, honestly.
π 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, no cap π―. Once the test configuration is cloned, lit checks for a lit.local.cfg file in the subdirectory. If it's present, that file gets loaded and can be used to specialize the configuration for each individual directory π§.
This facility is literally iconic for defining subdirectories of optional tests, or for changing other configuration parameters β for example, to change the test format, or the suffixes that identify test files πΈ.
π SUBSTITUTIONS π
okay so this is the part where it gets good β lit lets you substitute patterns right inside your RUN commands π
like little magic words that get swapped for real paths before anything actually runs. It also ships with this base set of substitutions, and they're all defined in TestRunner.py (iykyk, that's the file to go look at if you ever want receipts):
%sβ the source path, aka the path to the file that's currently being run π«Ά%Sβ the source dir, aka 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. heads up bestie: this one is deprecated, use%{t:stem}instead π%Tβ the parent directory of%t. not unique, deprecated, just don't use it, okay? π%%β literally just%%/sβ%sbut with\replaced by/%/Sβ%Sbut with\replaced by/%/pβ%pbut with\replaced by/%/tβ%tbut with\replaced by/%/Tβ%Tbut with\replaced by/%{s:basename}β the last path component of%s%{t:stem}β the last path component of%t, but without the.tmpextension (it's an alias for%basename_t, bestie, they're the same girl π)%{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}β%/sbut escaped so you can use it in the replacement of as@@@command insedπ§%{/S:regex_replacement}β%/Sbut escaped for use in the replacement of as@@@command insed%{/p:regex_replacement}β%/pbut escaped for use inβ¦
okay picking up the substitution table right where we left off, bestie π :
%{/t:regex_replacement}β%/tbut escaped for use in the replacement of as@@@command in sed.%{/T:regex_replacement}β%/Tbut escaped for use in the replacement of as@@@command in sed.%: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.
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.
Should a test be allowed retries (see ALLOW_RETRIES: annotation) and it needed more than one attempt to succeed, then <progress info> is extended by this information:
, <num_attempts_made> of <max_allowed_attempts> attempts
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.
π SEE ALSO π
βοΈ Author βοΈ
Maintained by the LLVM Team (https://llvm.org/).
Β©οΈ Copyright Β©οΈ
2003-2026, LLVM Project
and that's a wrap, bestie π source/version LIT(1), page 21, dated 2026-05-15 β go make those tests behave π
β¨
π¦ where this page comes from
- fedora 44: llvm21 21.1.8-5.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm21 21.1.8-5.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms