blob: ceb2023e750a59f3e3fdee8adc184e5681d6b744 [file] [log] [blame]
Sean Silvaa89edf62012-11-14 21:09:30 +00001=================================
2LLVM Testing Infrastructure Guide
3=================================
4
Sean Silvaa89edf62012-11-14 21:09:30 +00005.. contents::
6 :local:
7
Sean Silvae0db5192012-11-14 23:11:10 +00008.. toctree::
9 :hidden:
10
Matthias Braun4f340e92018-08-31 21:47:01 +000011 TestSuiteGuide
Sean Silvae0db5192012-11-14 23:11:10 +000012 TestSuiteMakefileGuide
13
Sean Silvaa89edf62012-11-14 21:09:30 +000014Overview
15========
16
17This document is the reference manual for the LLVM testing
18infrastructure. It documents the structure of the LLVM testing
19infrastructure, the tools needed to use it, and how to add and run
20tests.
21
22Requirements
23============
24
Bill Wendling27f96da2013-10-27 04:02:21 +000025In order to use the LLVM testing infrastructure, you will need all of the
Rafael Espindola21a400852014-12-12 15:29:31 +000026software required to build LLVM, as well as `Python <http://python.org>`_ 2.7 or
Bill Wendling27f96da2013-10-27 04:02:21 +000027later.
Sean Silvaa89edf62012-11-14 21:09:30 +000028
Matthias Braun4f340e92018-08-31 21:47:01 +000029LLVM Testing Infrastructure Organization
Sean Silvaa89edf62012-11-14 21:09:30 +000030========================================
31
32The LLVM testing infrastructure contains two major categories of tests:
33regression tests and whole programs. The regression tests are contained
34inside the LLVM repository itself under ``llvm/test`` and are expected
35to always pass -- they should be run before every commit.
36
37The whole programs tests are referred to as the "LLVM test suite" (or
38"test-suite") and are in the ``test-suite`` module in subversion. For
39historical reasons, these tests are also referred to as the "nightly
40tests" in places, which is less ambiguous than "test-suite" and remains
41in use although we run them much more often than nightly.
42
43Regression tests
44----------------
45
46The regression tests are small pieces of code that test a specific
Eli Bendersky03551382012-12-03 04:10:58 +000047feature of LLVM or trigger a specific bug in LLVM. The language they are
48written in depends on the part of LLVM being tested. These tests are driven by
49the :doc:`Lit <CommandGuide/lit>` testing tool (which is part of LLVM), and
50are located in the ``llvm/test`` directory.
Sean Silvaa89edf62012-11-14 21:09:30 +000051
52Typically when a bug is found in LLVM, a regression test containing just
53enough code to reproduce the problem should be written and placed
Eli Bendersky03551382012-12-03 04:10:58 +000054somewhere underneath this directory. For example, it can be a small
55piece of LLVM IR distilled from an actual application or benchmark.
Sean Silvaa89edf62012-11-14 21:09:30 +000056
57``test-suite``
58--------------
59
60The test suite contains whole programs, which are pieces of code which
61can be compiled and linked into a stand-alone program that can be
62executed. These programs are generally written in high level languages
63such as C or C++.
64
65These programs are compiled using a user specified compiler and set of
66flags, and then executed to capture the program output and timing
67information. The output of these programs is compared to a reference
68output to ensure that the program is being compiled correctly.
69
70In addition to compiling and executing programs, whole program tests
71serve as a way of benchmarking LLVM performance, both in terms of the
72efficiency of the programs generated as well as the speed with which
73LLVM compiles, optimizes, and generates code.
74
75The test-suite is located in the ``test-suite`` Subversion module.
76
Matthias Braun4f340e92018-08-31 21:47:01 +000077See the :doc:`TestSuiteGuide` for details.
78
Sean Silvaa89edf62012-11-14 21:09:30 +000079Debugging Information tests
80---------------------------
81
82The test suite contains tests to check quality of debugging information.
83The test are written in C based languages or in LLVM assembly language.
84
85These tests are compiled and run under a debugger. The debugger output
86is checked to validate of debugging information. See README.txt in the
87test suite for more information . This test suite is located in the
88``debuginfo-tests`` Subversion module.
89
90Quick start
91===========
92
93The tests are located in two separate Subversion modules. The
94regressions tests are in the main "llvm" module under the directory
Eli Bendersky03551382012-12-03 04:10:58 +000095``llvm/test`` (so you get these tests for free with the main LLVM tree).
96Use ``make check-all`` to run the regression tests after building LLVM.
Sean Silvaa89edf62012-11-14 21:09:30 +000097
Matthias Braun4f340e92018-08-31 21:47:01 +000098The ``test-suite`` module contains more comprehensive tests including whole C
99and C++ programs. See the :doc:`TestSuiteGuide` for details.
Sean Silvaa89edf62012-11-14 21:09:30 +0000100
101Regression tests
102----------------
103
Chris Bienemanbcc6f192016-01-26 22:53:12 +0000104To run all of the LLVM regression tests use the check-llvm target:
Sean Silvaa89edf62012-11-14 21:09:30 +0000105
106.. code-block:: bash
107
Chris Bienemanbcc6f192016-01-26 22:53:12 +0000108 % make check-llvm
Sean Silvaa89edf62012-11-14 21:09:30 +0000109
Davide Italiano078fb932019-01-22 21:52:50 +0000110In order to get reasonable testing performance, build LLVM and subprojects
111in release mode, i.e.
112
113.. code-block:: bash
114
115 % cmake -DCMAKE_BUILD_TYPE="Release"
116
Sean Silvaa89edf62012-11-14 21:09:30 +0000117If you have `Clang <http://clang.llvm.org/>`_ checked out and built, you
118can run the LLVM and Clang tests simultaneously using:
119
Sean Silvaa89edf62012-11-14 21:09:30 +0000120.. code-block:: bash
121
Eli Bendersky03551382012-12-03 04:10:58 +0000122 % make check-all
Sean Silvaa89edf62012-11-14 21:09:30 +0000123
Daniel Dunbar04388af2013-08-09 19:39:48 +0000124To run the tests with Valgrind (Memcheck by default), use the ``LIT_ARGS`` make
125variable to pass the required options to lit. For example, you can use:
Sean Silvaa89edf62012-11-14 21:09:30 +0000126
127.. code-block:: bash
128
Daniel Dunbar04388af2013-08-09 19:39:48 +0000129 % make check LIT_ARGS="-v --vg --vg-leak"
130
131to enable testing with valgrind and with leak checking enabled.
Sean Silvaa89edf62012-11-14 21:09:30 +0000132
Eli Bendersky03551382012-12-03 04:10:58 +0000133To run individual tests or subsets of tests, you can use the ``llvm-lit``
Sean Silvaa89edf62012-11-14 21:09:30 +0000134script which is built as part of LLVM. For example, to run the
Eli Bendersky03551382012-12-03 04:10:58 +0000135``Integer/BitPacked.ll`` test by itself you can run:
Sean Silvaa89edf62012-11-14 21:09:30 +0000136
137.. code-block:: bash
138
139 % llvm-lit ~/llvm/test/Integer/BitPacked.ll
140
141or to run all of the ARM CodeGen tests:
142
143.. code-block:: bash
144
145 % llvm-lit ~/llvm/test/CodeGen/ARM
146
Eli Bendersky03551382012-12-03 04:10:58 +0000147For more information on using the :program:`lit` tool, see ``llvm-lit --help``
148or the :doc:`lit man page <CommandGuide/lit>`.
Sean Silvaa89edf62012-11-14 21:09:30 +0000149
150Debugging Information tests
151---------------------------
152
153To run debugging information tests simply checkout the tests inside
154clang/test directory.
155
156.. code-block:: bash
157
158 % cd clang/test
159 % svn co http://llvm.org/svn/llvm-project/debuginfo-tests/trunk debuginfo-tests
160
161These tests are already set up to run as part of clang regression tests.
162
163Regression test structure
164=========================
165
Eli Bendersky03551382012-12-03 04:10:58 +0000166The LLVM regression tests are driven by :program:`lit` and are located in the
Sean Silvaa89edf62012-11-14 21:09:30 +0000167``llvm/test`` directory.
168
169This directory contains a large array of small tests that exercise
170various features of LLVM and to ensure that regressions do not occur.
171The directory is broken into several sub-directories, each focused on a
Eli Bendersky42e10732012-12-04 13:55:17 +0000172particular area of LLVM.
Sean Silvaa89edf62012-11-14 21:09:30 +0000173
174Writing new regression tests
175----------------------------
176
177The regression test structure is very simple, but does require some
178information to be set. This information is gathered via ``configure``
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000179and is written to a file, ``test/lit.site.cfg`` in the build directory.
180The ``llvm/test`` Makefile does this work for you.
Sean Silvaa89edf62012-11-14 21:09:30 +0000181
182In order for the regression tests to work, each directory of tests must
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000183have a ``lit.local.cfg`` file. :program:`lit` looks for this file to determine
184how to run the tests. This file is just Python code and thus is very
Sean Silvaa89edf62012-11-14 21:09:30 +0000185flexible, but we've standardized it for the LLVM regression tests. If
186you're adding a directory of tests, just copy ``lit.local.cfg`` from
187another directory to get running. The standard ``lit.local.cfg`` simply
188specifies which files to look in for tests. Any directory that contains
Dmitri Gribenko42c31d22012-11-18 10:35:18 +0000189only directories does not need the ``lit.local.cfg`` file. Read the :doc:`Lit
190documentation <CommandGuide/lit>` for more information.
Sean Silvaa89edf62012-11-14 21:09:30 +0000191
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000192Each test file must contain lines starting with "RUN:" that tell :program:`lit`
193how to run it. If there are no RUN lines, :program:`lit` will issue an error
194while running a test.
Sean Silvaa89edf62012-11-14 21:09:30 +0000195
196RUN lines are specified in the comments of the test program using the
197keyword ``RUN`` followed by a colon, and lastly the command (pipeline)
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000198to execute. Together, these lines form the "script" that :program:`lit`
199executes to run the test case. The syntax of the RUN lines is similar to a
200shell's syntax for pipelines including I/O redirection and variable
201substitution. However, even though these lines may *look* like a shell
202script, they are not. RUN lines are interpreted by :program:`lit`.
203Consequently, the syntax differs from shell in a few ways. You can specify
204as many RUN lines as needed.
Sean Silvaa89edf62012-11-14 21:09:30 +0000205
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000206:program:`lit` performs substitution on each RUN line to replace LLVM tool names
Sean Silvaa89edf62012-11-14 21:09:30 +0000207with the full paths to the executable built for each tool (in
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000208``$(LLVM_OBJ_ROOT)/$(BuildMode)/bin)``. This ensures that :program:`lit` does
209not invoke any stray LLVM tools in the user's path during testing.
Sean Silvaa89edf62012-11-14 21:09:30 +0000210
211Each RUN line is executed on its own, distinct from other lines unless
212its last character is ``\``. This continuation character causes the RUN
213line to be concatenated with the next one. In this way you can build up
214long pipelines of commands without making huge line lengths. The lines
215ending in ``\`` are concatenated until a RUN line that doesn't end in
216``\`` is found. This concatenated set of RUN lines then constitutes one
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000217execution. :program:`lit` will substitute variables and arrange for the pipeline
218to be executed. If any process in the pipeline fails, the entire line (and
Sean Silvaa89edf62012-11-14 21:09:30 +0000219test case) fails too.
220
221Below is an example of legal RUN lines in a ``.ll`` file:
222
223.. code-block:: llvm
224
225 ; RUN: llvm-as < %s | llvm-dis > %t1
226 ; RUN: llvm-dis < %s.bc-13 > %t2
227 ; RUN: diff %t1 %t2
228
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000229As with a Unix shell, the RUN lines permit pipelines and I/O
Sean Silva8eaf3ca2013-03-19 15:22:02 +0000230redirection to be used.
Sean Silvaa89edf62012-11-14 21:09:30 +0000231
232There are some quoting rules that you must pay attention to when writing
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000233your RUN lines. In general nothing needs to be quoted. :program:`lit` won't
234strip off any quote characters so they will get passed to the invoked program.
Eli Benderskyf747bd62013-01-18 19:01:34 +0000235To avoid this use curly braces to tell :program:`lit` that it should treat
236everything enclosed as one value.
Sean Silvaa89edf62012-11-14 21:09:30 +0000237
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000238In general, you should strive to keep your RUN lines as simple as possible,
Eli Benderskyf747bd62013-01-18 19:01:34 +0000239using them only to run tools that generate textual output you can then examine.
Eli Bendersky6f6cbdb2013-03-22 16:09:06 +0000240The recommended way to examine output to figure out if the test passes is using
Eli Benderskyf747bd62013-01-18 19:01:34 +0000241the :doc:`FileCheck tool <CommandGuide/FileCheck>`. *[The usage of grep in RUN
242lines is deprecated - please do not send or commit patches that use it.]*
Sean Silvaa89edf62012-11-14 21:09:30 +0000243
Davide Italiano4efa3952015-11-17 02:17:35 +0000244Put related tests into a single file rather than having a separate file per
245test. Check if there are files already covering your feature and consider
246adding your code there instead of creating a new file.
247
Sean Silva15ee4082014-11-05 22:17:18 +0000248Extra files
249-----------
250
251If your test requires extra files besides the file containing the ``RUN:``
252lines, the idiomatic place to put them is in a subdirectory ``Inputs``.
253You can then refer to the extra files as ``%S/Inputs/foo.bar``.
254
255For example, consider ``test/Linker/ident.ll``. The directory structure is
256as follows::
257
258 test/
259 Linker/
260 ident.ll
261 Inputs/
262 ident.a.ll
263 ident.b.ll
264
265For convenience, these are the contents:
266
267.. code-block:: llvm
268
269 ;;;;; ident.ll:
270
271 ; RUN: llvm-link %S/Inputs/ident.a.ll %S/Inputs/ident.b.ll -S | FileCheck %s
272
273 ; Verify that multiple input llvm.ident metadata are linked together.
274
275 ; CHECK-DAG: !llvm.ident = !{!0, !1, !2}
276 ; CHECK-DAG: "Compiler V1"
277 ; CHECK-DAG: "Compiler V2"
278 ; CHECK-DAG: "Compiler V3"
279
280 ;;;;; Inputs/ident.a.ll:
281
282 !llvm.ident = !{!0, !1}
283 !0 = metadata !{metadata !"Compiler V1"}
284 !1 = metadata !{metadata !"Compiler V2"}
285
286 ;;;;; Inputs/ident.b.ll:
287
288 !llvm.ident = !{!0}
289 !0 = metadata !{metadata !"Compiler V3"}
290
291For symmetry reasons, ``ident.ll`` is just a dummy file that doesn't
292actually participate in the test besides holding the ``RUN:`` lines.
293
294.. note::
295
296 Some existing tests use ``RUN: true`` in extra files instead of just
297 putting the extra files in an ``Inputs/`` directory. This pattern is
298 deprecated.
299
Dmitri Gribenko12be9282012-12-30 14:51:03 +0000300Fragile tests
301-------------
302
303It is easy to write a fragile test that would fail spuriously if the tool being
304tested outputs a full path to the input file. For example, :program:`opt` by
305default outputs a ``ModuleID``:
306
307.. code-block:: console
308
309 $ cat example.ll
310 define i32 @main() nounwind {
311 ret i32 0
312 }
313
314 $ opt -S /path/to/example.ll
315 ; ModuleID = '/path/to/example.ll'
316
317 define i32 @main() nounwind {
318 ret i32 0
319 }
320
Sylvestre Ledrue6ec4412017-01-14 11:37:01 +0000321``ModuleID`` can unexpectedly match against ``CHECK`` lines. For example:
Dmitri Gribenko12be9282012-12-30 14:51:03 +0000322
323.. code-block:: llvm
324
325 ; RUN: opt -S %s | FileCheck
326
327 define i32 @main() nounwind {
328 ; CHECK-NOT: load
329 ret i32 0
330 }
331
332This test will fail if placed into a ``download`` directory.
333
334To make your tests robust, always use ``opt ... < %s`` in the RUN line.
335:program:`opt` does not output a ``ModuleID`` when input comes from stdin.
336
Renato Golin98c60812013-07-03 20:56:33 +0000337Platform-Specific Tests
338-----------------------
339
340Whenever adding tests that require the knowledge of a specific platform,
341either related to code generated, specific output or back-end features,
342you must make sure to isolate the features, so that buildbots that
343run on different architectures (and don't even compile all back-ends),
344don't fail.
345
346The first problem is to check for target-specific output, for example sizes
347of structures, paths and architecture names, for example:
348
349* Tests containing Windows paths will fail on Linux and vice-versa.
350* Tests that check for ``x86_64`` somewhere in the text will fail anywhere else.
351* Tests where the debug information calculates the size of types and structures.
352
353Also, if the test rely on any behaviour that is coded in any back-end, it must
354go in its own directory. So, for instance, code generator tests for ARM go
355into ``test/CodeGen/ARM`` and so on. Those directories contain a special
356``lit`` configuration file that ensure all tests in that directory will
357only run if a specific back-end is compiled and available.
358
359For instance, on ``test/CodeGen/ARM``, the ``lit.local.cfg`` is:
360
361.. code-block:: python
362
363 config.suffixes = ['.ll', '.c', '.cpp', '.test']
Alp Tokerd3d017c2014-06-09 22:42:55 +0000364 if not 'ARM' in config.root.targets:
Renato Golin98c60812013-07-03 20:56:33 +0000365 config.unsupported = True
366
367Other platform-specific tests are those that depend on a specific feature
368of a specific sub-architecture, for example only to Intel chips that support ``AVX2``.
369
370For instance, ``test/CodeGen/X86/psubus.ll`` tests three sub-architecture
371variants:
372
373.. code-block:: llvm
374
375 ; RUN: llc -mcpu=core2 < %s | FileCheck %s -check-prefix=SSE2
376 ; RUN: llc -mcpu=corei7-avx < %s | FileCheck %s -check-prefix=AVX1
377 ; RUN: llc -mcpu=core-avx2 < %s | FileCheck %s -check-prefix=AVX2
378
379And the checks are different:
380
381.. code-block:: llvm
382
383 ; SSE2: @test1
384 ; SSE2: psubusw LCPI0_0(%rip), %xmm0
385 ; AVX1: @test1
386 ; AVX1: vpsubusw LCPI0_0(%rip), %xmm0, %xmm0
387 ; AVX2: @test1
388 ; AVX2: vpsubusw LCPI0_0(%rip), %xmm0, %xmm0
389
390So, if you're testing for a behaviour that you know is platform-specific or
391depends on special features of sub-architectures, you must add the specific
392triple, test with the specific FileCheck and put it into the specific
393directory that will filter out all other architectures.
394
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000395
Greg Parker17db7702017-01-25 02:26:03 +0000396Constraining test execution
397---------------------------
398
399Some tests can be run only in specific configurations, such as
400with debug builds or on particular platforms. Use ``REQUIRES``
401and ``UNSUPPORTED`` to control when the test is enabled.
402
403Some tests are expected to fail. For example, there may be a known bug
404that the test detect. Use ``XFAIL`` to mark a test as an expected failure.
405An ``XFAIL`` test will be successful if its execution fails, and
406will be a failure if its execution succeeds.
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000407
408.. code-block:: llvm
409
Greg Parker17db7702017-01-25 02:26:03 +0000410 ; This test will be only enabled in the build with asserts.
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000411 ; REQUIRES: asserts
Greg Parker17db7702017-01-25 02:26:03 +0000412 ; This test is disabled on Linux.
413 ; UNSUPPORTED: -linux-
414 ; This test is expected to fail on PowerPC.
415 ; XFAIL: powerpc
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000416
Greg Parker17db7702017-01-25 02:26:03 +0000417``REQUIRES`` and ``UNSUPPORTED`` and ``XFAIL`` all accept a comma-separated
418list of boolean expressions. The values in each expression may be:
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000419
Greg Parker17db7702017-01-25 02:26:03 +0000420- Features added to ``config.available_features`` by
421 configuration files such as ``lit.cfg``.
422- Substrings of the target triple (``UNSUPPORTED`` and ``XFAIL`` only).
423
424| ``REQUIRES`` enables the test if all expressions are true.
425| ``UNSUPPORTED`` disables the test if any expression is true.
426| ``XFAIL`` expects the test to fail if any expression is true.
427
428As a special case, ``XFAIL: *`` is expected to fail everywhere.
429
430.. code-block:: llvm
431
432 ; This test is disabled on Windows,
433 ; and is disabled on Linux, except for Android Linux.
434 ; UNSUPPORTED: windows, linux && !android
435 ; This test is expected to fail on both PowerPC and ARM.
436 ; XFAIL: powerpc || arm
437
Renato Golin98c60812013-07-03 20:56:33 +0000438
Nico Rieckc4e7f302014-02-15 08:35:56 +0000439Substitutions
440-------------
Sean Silvaa89edf62012-11-14 21:09:30 +0000441
Nico Rieckc4e7f302014-02-15 08:35:56 +0000442Besides replacing LLVM tool names the following substitutions are performed in
443RUN lines:
Sean Silvaa89edf62012-11-14 21:09:30 +0000444
Nico Rieckc4e7f302014-02-15 08:35:56 +0000445``%%``
446 Replaced by a single ``%``. This allows escaping other substitutions.
Sean Silvaa89edf62012-11-14 21:09:30 +0000447
Nico Rieckc4e7f302014-02-15 08:35:56 +0000448``%s``
449 File path to the test case's source. This is suitable for passing on the
450 command line as the input to an LLVM tool.
Sean Silvaa89edf62012-11-14 21:09:30 +0000451
Nico Rieckc4e7f302014-02-15 08:35:56 +0000452 Example: ``/home/user/llvm/test/MC/ELF/foo_test.s``
Sean Silvaa89edf62012-11-14 21:09:30 +0000453
Nico Rieckc4e7f302014-02-15 08:35:56 +0000454``%S``
455 Directory path to the test case's source.
Sean Silvaa89edf62012-11-14 21:09:30 +0000456
Nico Rieckc4e7f302014-02-15 08:35:56 +0000457 Example: ``/home/user/llvm/test/MC/ELF``
Sean Silvaa89edf62012-11-14 21:09:30 +0000458
Nico Rieckc4e7f302014-02-15 08:35:56 +0000459``%t``
460 File path to a temporary file name that could be used for this test case.
Sean Silvaa89edf62012-11-14 21:09:30 +0000461 The file name won't conflict with other test cases. You can append to it
462 if you need multiple temporaries. This is useful as the destination of
463 some redirected output.
464
Nico Rieckc4e7f302014-02-15 08:35:56 +0000465 Example: ``/home/user/llvm.build/test/MC/ELF/Output/foo_test.s.tmp``
Sean Silvaa89edf62012-11-14 21:09:30 +0000466
Nico Rieckc4e7f302014-02-15 08:35:56 +0000467``%T``
Kuba Mracek77920a42018-06-19 22:22:48 +0000468 Directory of ``%t``. Deprecated. Shouldn't be used, because it can be easily
469 misused and cause race conditions between tests.
470
471 Use ``rm -rf %t && mkdir %t`` instead if a temporary directory is necessary.
Sean Silvaa89edf62012-11-14 21:09:30 +0000472
Nico Rieckc4e7f302014-02-15 08:35:56 +0000473 Example: ``/home/user/llvm.build/test/MC/ELF/Output``
Sean Silvaa89edf62012-11-14 21:09:30 +0000474
Nico Rieckc4e7f302014-02-15 08:35:56 +0000475``%{pathsep}``
476
477 Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
478
David Bozier9126f542017-02-09 14:12:30 +0000479``%/s, %/S, %/t, %/T:``
480
481 Act like the corresponding substitution above but replace any ``\``
482 character with a ``/``. This is useful to normalize path separators.
483
484 Example: ``%s: C:\Desktop Files/foo_test.s.tmp``
485
486 Example: ``%/s: C:/Desktop Files/foo_test.s.tmp``
487
488``%:s, %:S, %:t, %:T:``
489
490 Act like the corresponding substitution above but remove colons at
491 the beginning of Windows paths. This is useful to allow concatenation
492 of absolute paths on Windows to produce a legal path.
493
494 Example: ``%s: C:\Desktop Files\foo_test.s.tmp``
495
496 Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
497
Nico Rieckc4e7f302014-02-15 08:35:56 +0000498
499**LLVM-specific substitutions:**
500
501``%shlibext``
502 The suffix for the host platforms shared library files. This includes the
503 period as the first character.
504
505 Example: ``.so`` (Linux), ``.dylib`` (OS X), ``.dll`` (Windows)
506
507``%exeext``
508 The suffix for the host platforms executable files. This includes the
509 period as the first character.
510
511 Example: ``.exe`` (Windows), empty on Linux.
512
513``%(line)``, ``%(line+<number>)``, ``%(line-<number>)``
514 The number of the line where this substitution is used, with an optional
515 integer offset. This can be used in tests with multiple RUN lines, which
516 reference test file's line numbers.
517
518
519**Clang-specific substitutions:**
520
521``%clang``
522 Invokes the Clang driver.
523
524``%clang_cpp``
525 Invokes the Clang driver for C++.
526
527``%clang_cl``
528 Invokes the CL-compatible Clang driver.
529
530``%clangxx``
531 Invokes the G++-compatible Clang driver.
532
533``%clang_cc1``
534 Invokes the Clang frontend.
535
536``%itanium_abi_triple``, ``%ms_abi_triple``
537 These substitutions can be used to get the current target triple adjusted to
538 the desired ABI. For example, if the test suite is running with the
539 ``i686-pc-win32`` target, ``%itanium_abi_triple`` will expand to
540 ``i686-pc-mingw32``. This allows a test to run with a specific ABI without
541 constraining it to a specific triple.
542
543To add more substituations, look at ``test/lit.cfg`` or ``lit.local.cfg``.
544
Sean Silvaa89edf62012-11-14 21:09:30 +0000545
Matthias Braun29f3f112015-05-04 21:37:00 +0000546Options
547-------
548
549The llvm lit configuration allows to customize some things with user options:
550
551``llc``, ``opt``, ...
552 Substitute the respective llvm tool name with a custom command line. This
553 allows to specify custom paths and default arguments for these tools.
554 Example:
555
556 % llvm-lit "-Dllc=llc -verify-machineinstrs"
557
558``run_long_tests``
559 Enable the execution of long running tests.
560
561``llvm_site_config``
562 Load the specified lit configuration instead of the default one.
563
564
Sean Silvaa89edf62012-11-14 21:09:30 +0000565Other Features
566--------------
567
Nico Rieckea623c62014-01-08 16:30:03 +0000568To make RUN line writing easier, there are several helper programs. These
569helpers are in the PATH when running tests, so you can just call them using
570their name. For example:
Sean Silvaa89edf62012-11-14 21:09:30 +0000571
Sean Silvaa89edf62012-11-14 21:09:30 +0000572``not``
Nico Rieckea623c62014-01-08 16:30:03 +0000573 This program runs its arguments and then inverts the result code from it.
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000574 Zero result codes become 1. Non-zero result codes become 0.
Sean Silvaa89edf62012-11-14 21:09:30 +0000575
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000576To make the output more useful, :program:`lit` will scan
Sean Silvaa89edf62012-11-14 21:09:30 +0000577the lines of the test case for ones that contain a pattern that matches
578``PR[0-9]+``. This is the syntax for specifying a PR (Problem Report) number
579that is related to the test case. The number after "PR" specifies the
580LLVM bugzilla number. When a PR number is specified, it will be used in
581the pass/fail reporting. This is useful to quickly get some context when
582a test fails.
583
584Finally, any line that contains "END." will cause the special
585interpretation of lines to terminate. This is generally done right after
586the last RUN: line. This has two side effects:
587
588(a) it prevents special interpretation of lines that are part of the test
589 program, not the instructions to the test case, and
590
591(b) it speeds things up for really big test cases by avoiding
592 interpretation of the remainder of the file.