LIT(1)
π LIT(1) β LLVM Integrated Tester π
okay bestie, welcome to the lit manual page, from the LLVM crew. this is LLVM Integrated Tester and she is that girl. let's get into it β¨
πΈ SYNOPSIS πΈ
lit [options] [tests]
β¨ DESCRIPTION β¨
so lit is a portable tool for running LLVM- and Clang-style test suites, giving you the rundown on how they went, and pointing at the failures. she's built to be a lightweight testing tool with the simplest user interface possible. no cap. π
you run lit with one or more tests specified on the command line, bestie. those tests can be either individual test files or directories to search for tests (peep TEST DISCOVERY for the deets).
every test you specify gets executed β potentially concurrently π β and once they've all run, lit prints summary info on how many passed or failed (that's TEST STATUS RESULTS, iykyk). and heads up: if any tests fail, lit exits with a non-zero exit code. periodt.
by default lit keeps it cute with a succinct progress display and only prints summary info for the tests that failed. want to control that? that's what OUTPUT OPTIONS are for π«Ά
lit also ships a whole bunch of options for controlling how tests get executed (some specific features depend on the particular test format, ngl). see EXECUTION OPTIONS for more.
and finally, there are extra options for running only a subset of the options you specified on the command line β that's SELECTION OPTIONS, go look π
one more thing, and it's important: lit parses options from the environment variable LIT_OPTS after it parses options from the command line. LIT_OPTS is mostly for supplementing or overriding the command-line options that a project's build system passes to lit via check targets. iconic behavior honestly.
if you're the kind of person who's into the lit architecture, or you're designing your own lit testing implementation, go read LIT INFRASTRUCTURE. that one's for you π
π§ GENERAL OPTIONS π§
-h,--helpβ show thelithelp message. simple as that, bestie.-j N,--workers=Nβ runNtests in parallel. by default this is automatically picked to match the number of detected available CPUs. the machine knows itself fr fr.--config-prefix=NAMEβ when searching for test suites, look forNAME.cfgandNAME.site.cfginstead oflit.cfgandlit.site.cfg.-D NAME[=VALUE],--param NAME[=VALUE]β add a user-defined parameterNAMEwith the givenVALUE(or the empty string if you don't give one). what these parameters actually mean and how they're used is entirely up to the test suite. not our business π
π OUTPUT OPTIONS π
-q,--quietβ suppress any output except for test failures. silence is golden β¨-s,--succinctβ show less output, like, don't show info on tests that pass. also shows a progress bar, unless--no-progress-baris specified.-v,--verboseβ show more info on test failures, e.g. the entire test output instead of just the test result. the receipts, basically.-vv,--echo-all-commandsβ echo all commands to stdout as they're being executed. this is lowkey valuable for debugging test failures, because the last echoed command is the one that failed.litnormally inserts a no-op command (:in the case ofbash) with the argument'RUN: at line N'before each command pipeline, and this option also makes those no-op commands get echoed to stdout to help you locate the source line of the failed command. this option implies--verbose.-a,--show-allβ show more info about all tests, e.g. the entire test commandline and output. everything everywhere all at once π«Ά--no-progress-barβ do not use the 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 thememchecktool). the--error-exitcodeargument for valgrind is used, so that valgrind failures make the program exit with a non-zero status.
when this option is enabled, lit also automatically provides a "valgrind" feature that you can use to conditionally disable certain tests (or expect failure in them).
--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,litalso automatically provides a"vg_leak"feature that you can use to conditionally disable certain tests (or expect failure in them).--time-testsβ track the wall time individual tests take to execute and include the results in the summary output. super useful for figuring out which tests in a suite take the longest to run. the slow ones are always the main characters smh π--ignore-failβ exit with status zero even if some tests fail. we're pretending we didn't see it bestie π--no-indirectly-run-checkβ do not error if a test would not have been run had you specified the containing directory instead of naming the test directly.
π SELECTION OPTIONS π
by default, lit runs failing tests first, then runs tests in descending execution time order to optimize concurrency. you can change the execution order with the --order option.
the timing data lives in the test_exec_root in a file named .lit_test_times.txt. if that file doesn't exist, lit checks the test_source_root for the file, so it can optionally accelerate clean builds. cute β¨
--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. you pass an integer argument 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, okay?--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 give you a coarse mechanism for partitioning large testsuites, for parallel execution on separate machines (say, in a big 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. useful when you want a predictable test order.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 because 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, fr fr.--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 listLISTas XFAIL. helpful when you don't 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 so the nvptx64-nvidia-cuda version of offloading/memory_manager.cpp is not treated 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--xfailthat appears later on the command line. the main purpose is to suppress an XPASS result without having to modify a test case that uses the XFAIL directive. so powerful honestly π
π¦ 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 exits with an exit code of 1 if there are any FAIL or XPASS results. otherwise, it exits with status 0. other exit codes get used for non-test related failures (like a user error, or an internal program error π).
more to come bestie, don't go anywhere π
π TEST DISCOVERY π
okay so bestie, when you hand lit some stuff to run, those inputs can be individual tests, or whole directories, or even entire hierarchies of tests. And the very first thing lit does when it wakes up? It converts all of those inputs into one complete list of tests to run. That whole process is literally called test discovery. β¨
In the lit model, every test has to exist inside some test suite β no exceptions, no cap. So lit takes the inputs you gave it on the command line and resolves them to test suites by searching upwards from the input path until it finds a lit.cfg or lit.site.cfg file. π¦ Those files are doing double duty fr fr β they're the marker that says "yep, this is a test suite" and they're the configuration files lit loads so it knows how to find and run the tests inside that suite.
Once lit has mapped your inputs onto test suites, it walks the list of inputs, adding tests for individual files and recursively searching directories for more tests. π₯
And like, that's the whole point: it makes it super easy to specify just a subset of tests to run, while the test suite configuration still gets to control exactly how those tests are interpreted. Also β and this is the iconic part β lit always identifies tests by the test suite they're in, plus their relative path inside that test suite. For projects that are configured the right way, that's what gives lit its convenient and flexible support for out-of-tree builds. π
π TEST STATUS RESULTS π
Every single test ends up with exactly one of these eight results. Eight of them! Count 'em:
PASSβ the test succeeded. slay. πFLAKYPASSβ the test succeeded, but only after being re-run more than once. This one only applies to tests that contain anALLOW_RETRIES:annotation. she needed a second chance and she took it. πXFAILβ the test failed, but that's expected. This is used for test formats that let you specify a test doesn't currently work, but you still wanna leave it sitting in the test suite. it's fine. it's fine.XPASSβ the test succeeded, but it was expected to fail. This is for tests that were marked as expected-to-fail but are now passing (usually because the feature they test was broken and someone fixed it). glow-up behavior honestly. β¨FAILβ the test failed. πUNRESOLVEDβ the test result could not be determined at all. For example, this happens when the test couldn't be run, or the test itself is invalid, or the test got interrupted. it's giving mystery. πUNSUPPORTEDβ the test is not supported in this environment. Used by test formats that can report unsupported tests.TIMEOUTβ the test ran, but it timed out before it could finish. And heads up: this counts as a failure. β°
Depending on the test format, tests may produce extra info about their status (generally only for failures). Peep the OUTPUT OPTIONS section for more on that. π
β¨ LIT INFRASTRUCTURE β¨
This section is for the girlies who wanna know how lit is actually built β whether you're creating a brand new lit testing implementation or extending one that already exists. π οΈ
Here's the vibe: lit proper is primarily an infrastructure for discovering and running arbitrary tests, and for exposing a single convenient interface to those tests. lit itself does not know how to run tests β that logic is defined by test suites. periodt.
π TEST SUITES π
As we said back in TEST DISCOVERY, tests always live inside a test suite. Test suites are the ones that define the format of the tests they contain, the logic for finding those tests, and any additional info needed to run them. π
lit identifies test suites as directories containing lit.cfg or lit.site.cfg files (see also --config-prefix). Test suites get discovered initially by recursively searching up the directory hierarchy for all the input files you passed on the command line. And you can use --show-suites to display the discovered test suites at startup. cute, right? πΈ
Once a test suite is discovered, its config file gets loaded. Config files are themselves Python modules that will be executed. When the config file runs, two important global variables are predefined for you:
lit_configβ the globallitconfiguration object (aLitConfiginstance), which defines the builtin test formats, global configuration parameters, and other helper routines for implementing test configurations.configβ 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 them must be set by the config, and the rest 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 that 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, marks a directory with tests expected to be run standalone. Test discovery is disabled for that directory andβno-indirectly-run-checkis in effect.lit.suffixesandlit.excludesmust be empty when this variable is true. β οΈsuffixesβ forlittest formats that scan directories for tests, this variable is a list of suffixes used to identify test files. Used by:ShTest.substitutionsβ forlittest formats that substitute variables into a test script, the list of substitutions to perform. Used by:ShTest.unsupportedβ marks an unsupported directory, and all tests within it will be reported as unsupported. Used by:ShTest.parentβ the parent configuration, i.e. 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 that's not what you want, 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 the test suites are located, lit recursively traverses the source directory (following test_source_root) looking for tests. When lit enters a sub-directory, the first thing it checks is whether a nested test suite is defined in that directory. If so, it loads that test suite recursively. If not, it instantiates a local test config for that directory (see LOCAL CONFIGURATION FILES below). π
Tests are identified by the test suite they're contained within, plus the relative path inside that suite. And heads up: that relative path might not refer to an actual file on disk! Some test formats (like GoogleTest) define "virtual tests" whose path contains both the path to the actual test file and a subpath that identifies the virtual test. sneaky but iconic. π
πΈ LOCAL CONFIGURATION FILES πΈ
When lit loads a subdirectory inside a test suite, it instantiates a local test configuration by cloning the configuration of the parent directory β and the root of this whole configuration chain will always be a test suite. Once the test configuration is cloned, lit checks for a lit.local.cfg file in that subdirectory. If it's there, that file gets loaded and can be used to specialize the configuration for each individual directory. π
This whole facility is perfect for defining subdirectories of optional tests, or for changing other configuration parameters β for example, changing the test format, or changing the suffixes that identify test files. chef's kiss. π
β¨ SUBSTITUTIONS β¨
okay so here's the tea bestie: lit lets you substitute patterns inside RUN commands. and it also hands you this whole base set of substitutions for free, all defined in TestRunner.py π«Ά
%sβ source path (the path to the file that's currently being run, iykyk)%Sβ source dir (the directory of the file currently being run)%pβ literally the same thing as%S%{pathsep}β the 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, bestie I'm begging)%%β a literal%%/sβ%sbut every\gets replaced by/%/Sβ%Sbut every\gets replaced by/%/pβ%pbut every\gets replaced by/%/tβ%tbut every\gets replaced by/%/Tβ%Tbut every\gets replaced by/%{/s:regex_replacement}β%/sbut escaped so you can use it in the replacement of as@@@command insed%{/S:regex_replacement}β%/Sbut escaped so you can use it in the replacement of as@@@command insed%{/p:regex_replacement}β%/pbut escaped so you can use it in the replacement of as@@@command insed%{/t:regex_replacement}β%/tbut escaped so you can use it in the replacement of as@@@command insed%{/T:regex_replacement}β%/Tbut escaped so you can use it in the replacement of as@@@command insed%:sβ on Windows, that's%/sbut a:gets removed if it's the second character. otherwise, it's%sbut with a single leading/removed.%:Sβ on Windows, that's%/Sbut a:gets removed if it's the second character. otherwise, it's%Sbut with a single leading/removed.%:pβ on Windows, that's%/pbut a:gets removed if it's the second character. otherwise, it's%pbut with a single leading/removed.%:tβ on Windows, that's%/tbut a:gets removed if it's the second character. otherwise, it's%tbut with a single leading/removed.%:Tβ on Windows, that's%/Tbut a:gets removed if it's the second character. otherwise, it's%Tbut with a single leading/removed.
and there's more, obviously π other substitutions are provided that are just variations on this base set, and each test module can define even more substitution patterns of its own. peep the LOCAL CONFIGURATION FILES section for the modules.
now, the important bit, don't skip this π«Ά by default substitutions get expanded exactly once. so like, if a substitution %build is defined on top of another substitution %cxx, then %build expands to the text %cxx, not to whatever %cxx actually expands to. no cap.
but β if the recursiveExpansionLimit property of the TestingConfig is set to a non-negative integer, then substitutions get expanded recursively until that limit is hit. and here's the catch: it's an error if the limit is reached and expanding substitutions one more time would give you a different result. so like, know your limits bestie π
more detailed info on substitutions lives in the LLVM Testing Infrastructure Guide.
π TEST RUN OUTPUT FORMAT π
the lit output for a test run follows this schema, in both short and verbose modes (tho in short mode there just won't be any PASS lines shown, sorry bestie). this schema was picked so a machine can reliably parse it (like, say, when you're scraping buildbot logs π) and so other tools can generate it too.
every test result is expected to show up on a line matching:
<result code>: <test name> (<progress info>)
where <result-code> is a standard test result like PASS, FAIL, XFAIL, XPASS, UNRESOLVED, or UNSUPPORTED. the performance result codes IMPROVED and REGRESSED are also allowed β¨
the <test name> field can be any arbitrary string, just no newlines allowed in it.
the <progress info> field is for reporting progress info like (1/300), or it can be empty β but even when it's empty, the parentheses are required. them's the rules π
every test result can also include extra (multiline) log info in this 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 that's at least four characters long (and bestie, the recommended length is 20, so likeβ¦ go for 20 π
), and <trailing delineator> is an arbitrary (unparsed) string. She does not read it. She does not care. It's just vibes at the end. π
Okay so here's what a run looks like when it's got four tests β A, B, C, and D β and test C decides to absolutely tank and leaves a log message on its way out:
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)
See how C is out here being the main character of its own tragedy? π A, B and D are just passing through like nothing happened. Iconic behaviour from all four of them honestly.
πΈ LIT EXAMPLE TESTS πΈ
The lit distribution ships with several example implementations of test suites living in the ExampleTests directory. Fr fr, they're right there for you to peek at β go look, it's giving free education. β¨
π«Ά SEE ALSO π«Ά
π AUTHOR π
Maintained by the LLVM Team (https://llvm.org/). Slay, kings. π
π COPYRIGHT π
2003-2025, LLVM Project
okay that's the whole page bestie, we made it to the end together π₯Ή this was version 14, dated 2025-05-22, and it's the LIT(1) page β go forth and run your tests, no cap πβ¨πΈπ¦
π¦ where this page comes from
- ubuntu questing: llvm-14 1:14.0.6-20ubuntu3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms