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 the lit help message and exit. 🫢
  • --version β€” Show lit’s version number and exit. ✨
  • -j N, --workers N β€” Run N tests in parallel. By default, this is automatically chosen to match the number of detected available CPUs. Slay, parallelism. ⚑
  • --config-prefix NAME β€” Search for NAME.cfg and NAME.site.cfg when searching for test suites, instead of lit.cfg and lit.site.cfg. πŸŽ€
  • -D NAME[=VALUE], --param NAME[=VALUE] β€” Add a user defined parameter NAME with the given VALUE (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-bar is 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 additional PATH to use when searching for executables in tests. πŸ”Ž
  • --vg β€” Run individual tests under valgrind (using the memcheck tool). The --error-exitcode argument 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 --vg is used, enable memory leak checks. When this option is enabled, lit will also automatically provide a "vg_leak" feature that can be used to conditionally disable (or expect failure in) certain tests. 🫧
  • --vg-arg ARG β€” When --vg is 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). 0 means no time limit. [Default: 0] ⏱️
  • --timeout N β€” Spend at most N seconds (approximately) running each individual test. 0 means no time limit, and 0 is 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 most N times. Out of the following options to rerun failed tests the --max-retries-per-test is the only one that doesn’t require a change in the test scripts or the test config: πŸ”
    • --max-retries-per-test lit option
    • config.test_retry_attempts test suite option
    • ALLOW_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 to LLVM_PROFILE_FILE for each RUN). The coverage data files will be emitted in the directory specified by config.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 most N tests, then terminate. That's it, that's the whole thing πŸŽ€
  • --max-time N β€” Spend at most N seconds (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 --order instead πŸ™ˆ
  • -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 in REGEXP. The environment variable LIT_FILTER can also be used in place of this option, which is especially useful in environments where the call to lit is issued indirectly πŸ”₯
  • --filter-out REGEXP β€” Filter out those tests whose name matches the regular expression specified in REGEXP. The environment variable LIT_FILTER_OUT can also be used in place of this option, which is especially useful in environments where the call to lit is issued indirectly ✨
  • --xfail LIST β€” Treat those tests whose name is in the semicolon separated list LIST as XFAIL. This can be helpful when one does not want to modify the test suite. The environment variable LIT_XFAIL can also be used in place of this option, which is especially useful in environments where the call to lit is 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 as XFAIL. The environment variable LIT_XFAIL_NOT can also be used in place of this option. The syntax is the same as for --xfail and LIT_XFAIL. --xfail-not and LIT_XFAIL_NOT always override all other XFAIL specifications, including an --xfail appearing later on the command line. The primary purpose is to suppress an XPASS result without modifying a test case that uses the XFAIL directive 😌
  • --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=N option, which selects the shard to run. The environment variable LIT_NUM_SHARDS can 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=M option was provided. The two options must be used together, and the value of N must be in the range 1..M. The environment variable LIT_RUN_SHARD can also be used in place of this option πŸ’œ

πŸ› οΈ ADDITIONAL OPTIONS πŸ› οΈ

  • --debug β€” Run lit in debug mode, for debugging configuration issues and lit itself πŸ”
  • --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 (in XFAIL, UNSUPPORTED and REQUIRES) 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 global lit configuration object (a LitConfig instance), which defines the builtin test formats, global configuration parameters, and other helper routines for implementing test configurations πŸ› οΈ
  • config β€” This is the config object (a TestingConfig instance) for the test suite, which the config file is expected to populate. The following variables are also available on the config object, 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 the lit.formats module πŸ“¦
    • 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.suffixes and lit.excludes must 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 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 be None, 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 to false and the test fails only if the last command in the pipe fails 🫢.
  • available_features β€” a whole set of features you can use in XFAIL, REQUIRES, and UNSUPPORTED directives ✨.

πŸ” 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 .tmp extension 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 β€” %s but with \ replaced by /
  • %/S β€” %S but with \ replaced by /
  • %/p β€” %p but with \ replaced by /
  • %/t β€” %t but with \ replaced by /
  • %/T β€” %T but with \ replaced by /
  • %{s:basename} β€” the last path component of %s
  • %{t:stem} β€” the last path component of %t, but without the .tmp extension (it's an alias for %basename_t, bestie, they're the same girl πŸ’–)
  • %{s:real} β€” %s after expanding all symbolic links and substitute drives
  • %{S:real} β€” %S after expanding all symbolic links and substitute drives
  • %{p:real} β€” %p after expanding all symbolic links and substitute drives
  • %{t:real} β€” %t after expanding all symbolic links and substitute drives
  • %{T:real} β€” %T after expanding all symbolic links and substitute drives
  • %{/s:real} β€” %/s after expanding all symbolic links and substitute drives
  • %{/S:real} β€” %/S after expanding all symbolic links and substitute drives
  • %{/p:real} β€” %/p after expanding all symbolic links and substitute drives
  • %{/t:real} β€” %/t after expanding all symbolic links and substitute drives
  • %{/T:real} β€” %/T after expanding all symbolic links and substitute drives
  • %{/s:regex_replacement} β€” %/s but escaped so you can use it in the replacement of a s@@@ command in sed 🧚
  • %{/S:regex_replacement} β€” %/S but escaped for use in the replacement of a s@@@ command in sed
  • %{/p:regex_replacement} β€” %/p but escaped for use in…

okay picking up the substitution table right where we left off, bestie πŸ’…:

  • %{/t:regex_replacement} β€” %/t but escaped for use in the replacement of a s@@@ command in sed.
  • %{/T:regex_replacement} β€” %/T but escaped for use in the replacement of a s@@@ command in sed.
  • %:s β€” on Windows, %/s but a : is removed if its the second character. Otherwise, %s but with a single leading / removed.
  • %:S β€” on Windows, %/S but a : is removed if its the second character. Otherwise, %S but with a single leading / removed.
  • %:p β€” on Windows, %/p but a : is removed if its the second character. Otherwise, %p but with a single leading / removed.
  • %:t β€” on Windows, %/t but a : is removed if its the second character. Otherwise, %t but with a single leading / removed.
  • %:T β€” on Windows, %/T but a : is removed if its the second character. Otherwise, %T but 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/).

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