blob: e3db60dd9e788de898bf97c9d2f96e82e961db2d [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
110If you have `Clang <http://clang.llvm.org/>`_ checked out and built, you
111can run the LLVM and Clang tests simultaneously using:
112
Sean Silvaa89edf62012-11-14 21:09:30 +0000113.. code-block:: bash
114
Eli Bendersky03551382012-12-03 04:10:58 +0000115 % make check-all
Sean Silvaa89edf62012-11-14 21:09:30 +0000116
Daniel Dunbar04388af2013-08-09 19:39:48 +0000117To run the tests with Valgrind (Memcheck by default), use the ``LIT_ARGS`` make
118variable to pass the required options to lit. For example, you can use:
Sean Silvaa89edf62012-11-14 21:09:30 +0000119
120.. code-block:: bash
121
Daniel Dunbar04388af2013-08-09 19:39:48 +0000122 % make check LIT_ARGS="-v --vg --vg-leak"
123
124to enable testing with valgrind and with leak checking enabled.
Sean Silvaa89edf62012-11-14 21:09:30 +0000125
Eli Bendersky03551382012-12-03 04:10:58 +0000126To run individual tests or subsets of tests, you can use the ``llvm-lit``
Sean Silvaa89edf62012-11-14 21:09:30 +0000127script which is built as part of LLVM. For example, to run the
Eli Bendersky03551382012-12-03 04:10:58 +0000128``Integer/BitPacked.ll`` test by itself you can run:
Sean Silvaa89edf62012-11-14 21:09:30 +0000129
130.. code-block:: bash
131
132 % llvm-lit ~/llvm/test/Integer/BitPacked.ll
133
134or to run all of the ARM CodeGen tests:
135
136.. code-block:: bash
137
138 % llvm-lit ~/llvm/test/CodeGen/ARM
139
Eli Bendersky03551382012-12-03 04:10:58 +0000140For more information on using the :program:`lit` tool, see ``llvm-lit --help``
141or the :doc:`lit man page <CommandGuide/lit>`.
Sean Silvaa89edf62012-11-14 21:09:30 +0000142
143Debugging Information tests
144---------------------------
145
146To run debugging information tests simply checkout the tests inside
147clang/test directory.
148
149.. code-block:: bash
150
151 % cd clang/test
152 % svn co http://llvm.org/svn/llvm-project/debuginfo-tests/trunk debuginfo-tests
153
154These tests are already set up to run as part of clang regression tests.
155
156Regression test structure
157=========================
158
Eli Bendersky03551382012-12-03 04:10:58 +0000159The LLVM regression tests are driven by :program:`lit` and are located in the
Sean Silvaa89edf62012-11-14 21:09:30 +0000160``llvm/test`` directory.
161
162This directory contains a large array of small tests that exercise
163various features of LLVM and to ensure that regressions do not occur.
164The directory is broken into several sub-directories, each focused on a
Eli Bendersky42e10732012-12-04 13:55:17 +0000165particular area of LLVM.
Sean Silvaa89edf62012-11-14 21:09:30 +0000166
167Writing new regression tests
168----------------------------
169
170The regression test structure is very simple, but does require some
171information to be set. This information is gathered via ``configure``
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000172and is written to a file, ``test/lit.site.cfg`` in the build directory.
173The ``llvm/test`` Makefile does this work for you.
Sean Silvaa89edf62012-11-14 21:09:30 +0000174
175In order for the regression tests to work, each directory of tests must
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000176have a ``lit.local.cfg`` file. :program:`lit` looks for this file to determine
177how to run the tests. This file is just Python code and thus is very
Sean Silvaa89edf62012-11-14 21:09:30 +0000178flexible, but we've standardized it for the LLVM regression tests. If
179you're adding a directory of tests, just copy ``lit.local.cfg`` from
180another directory to get running. The standard ``lit.local.cfg`` simply
181specifies which files to look in for tests. Any directory that contains
Dmitri Gribenko42c31d22012-11-18 10:35:18 +0000182only directories does not need the ``lit.local.cfg`` file. Read the :doc:`Lit
183documentation <CommandGuide/lit>` for more information.
Sean Silvaa89edf62012-11-14 21:09:30 +0000184
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000185Each test file must contain lines starting with "RUN:" that tell :program:`lit`
186how to run it. If there are no RUN lines, :program:`lit` will issue an error
187while running a test.
Sean Silvaa89edf62012-11-14 21:09:30 +0000188
189RUN lines are specified in the comments of the test program using the
190keyword ``RUN`` followed by a colon, and lastly the command (pipeline)
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000191to execute. Together, these lines form the "script" that :program:`lit`
192executes to run the test case. The syntax of the RUN lines is similar to a
193shell's syntax for pipelines including I/O redirection and variable
194substitution. However, even though these lines may *look* like a shell
195script, they are not. RUN lines are interpreted by :program:`lit`.
196Consequently, the syntax differs from shell in a few ways. You can specify
197as many RUN lines as needed.
Sean Silvaa89edf62012-11-14 21:09:30 +0000198
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000199:program:`lit` performs substitution on each RUN line to replace LLVM tool names
Sean Silvaa89edf62012-11-14 21:09:30 +0000200with the full paths to the executable built for each tool (in
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000201``$(LLVM_OBJ_ROOT)/$(BuildMode)/bin)``. This ensures that :program:`lit` does
202not invoke any stray LLVM tools in the user's path during testing.
Sean Silvaa89edf62012-11-14 21:09:30 +0000203
204Each RUN line is executed on its own, distinct from other lines unless
205its last character is ``\``. This continuation character causes the RUN
206line to be concatenated with the next one. In this way you can build up
207long pipelines of commands without making huge line lengths. The lines
208ending in ``\`` are concatenated until a RUN line that doesn't end in
209``\`` is found. This concatenated set of RUN lines then constitutes one
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000210execution. :program:`lit` will substitute variables and arrange for the pipeline
211to be executed. If any process in the pipeline fails, the entire line (and
Sean Silvaa89edf62012-11-14 21:09:30 +0000212test case) fails too.
213
214Below is an example of legal RUN lines in a ``.ll`` file:
215
216.. code-block:: llvm
217
218 ; RUN: llvm-as < %s | llvm-dis > %t1
219 ; RUN: llvm-dis < %s.bc-13 > %t2
220 ; RUN: diff %t1 %t2
221
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000222As with a Unix shell, the RUN lines permit pipelines and I/O
Sean Silva8eaf3ca2013-03-19 15:22:02 +0000223redirection to be used.
Sean Silvaa89edf62012-11-14 21:09:30 +0000224
225There are some quoting rules that you must pay attention to when writing
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000226your RUN lines. In general nothing needs to be quoted. :program:`lit` won't
227strip off any quote characters so they will get passed to the invoked program.
Eli Benderskyf747bd62013-01-18 19:01:34 +0000228To avoid this use curly braces to tell :program:`lit` that it should treat
229everything enclosed as one value.
Sean Silvaa89edf62012-11-14 21:09:30 +0000230
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000231In general, you should strive to keep your RUN lines as simple as possible,
Eli Benderskyf747bd62013-01-18 19:01:34 +0000232using them only to run tools that generate textual output you can then examine.
Eli Bendersky6f6cbdb2013-03-22 16:09:06 +0000233The recommended way to examine output to figure out if the test passes is using
Eli Benderskyf747bd62013-01-18 19:01:34 +0000234the :doc:`FileCheck tool <CommandGuide/FileCheck>`. *[The usage of grep in RUN
235lines is deprecated - please do not send or commit patches that use it.]*
Sean Silvaa89edf62012-11-14 21:09:30 +0000236
Davide Italiano4efa3952015-11-17 02:17:35 +0000237Put related tests into a single file rather than having a separate file per
238test. Check if there are files already covering your feature and consider
239adding your code there instead of creating a new file.
240
Sean Silva15ee4082014-11-05 22:17:18 +0000241Extra files
242-----------
243
244If your test requires extra files besides the file containing the ``RUN:``
245lines, the idiomatic place to put them is in a subdirectory ``Inputs``.
246You can then refer to the extra files as ``%S/Inputs/foo.bar``.
247
248For example, consider ``test/Linker/ident.ll``. The directory structure is
249as follows::
250
251 test/
252 Linker/
253 ident.ll
254 Inputs/
255 ident.a.ll
256 ident.b.ll
257
258For convenience, these are the contents:
259
260.. code-block:: llvm
261
262 ;;;;; ident.ll:
263
264 ; RUN: llvm-link %S/Inputs/ident.a.ll %S/Inputs/ident.b.ll -S | FileCheck %s
265
266 ; Verify that multiple input llvm.ident metadata are linked together.
267
268 ; CHECK-DAG: !llvm.ident = !{!0, !1, !2}
269 ; CHECK-DAG: "Compiler V1"
270 ; CHECK-DAG: "Compiler V2"
271 ; CHECK-DAG: "Compiler V3"
272
273 ;;;;; Inputs/ident.a.ll:
274
275 !llvm.ident = !{!0, !1}
276 !0 = metadata !{metadata !"Compiler V1"}
277 !1 = metadata !{metadata !"Compiler V2"}
278
279 ;;;;; Inputs/ident.b.ll:
280
281 !llvm.ident = !{!0}
282 !0 = metadata !{metadata !"Compiler V3"}
283
284For symmetry reasons, ``ident.ll`` is just a dummy file that doesn't
285actually participate in the test besides holding the ``RUN:`` lines.
286
287.. note::
288
289 Some existing tests use ``RUN: true`` in extra files instead of just
290 putting the extra files in an ``Inputs/`` directory. This pattern is
291 deprecated.
292
Dmitri Gribenko12be9282012-12-30 14:51:03 +0000293Fragile tests
294-------------
295
296It is easy to write a fragile test that would fail spuriously if the tool being
297tested outputs a full path to the input file. For example, :program:`opt` by
298default outputs a ``ModuleID``:
299
300.. code-block:: console
301
302 $ cat example.ll
303 define i32 @main() nounwind {
304 ret i32 0
305 }
306
307 $ opt -S /path/to/example.ll
308 ; ModuleID = '/path/to/example.ll'
309
310 define i32 @main() nounwind {
311 ret i32 0
312 }
313
Sylvestre Ledrue6ec4412017-01-14 11:37:01 +0000314``ModuleID`` can unexpectedly match against ``CHECK`` lines. For example:
Dmitri Gribenko12be9282012-12-30 14:51:03 +0000315
316.. code-block:: llvm
317
318 ; RUN: opt -S %s | FileCheck
319
320 define i32 @main() nounwind {
321 ; CHECK-NOT: load
322 ret i32 0
323 }
324
325This test will fail if placed into a ``download`` directory.
326
327To make your tests robust, always use ``opt ... < %s`` in the RUN line.
328:program:`opt` does not output a ``ModuleID`` when input comes from stdin.
329
Renato Golin98c60812013-07-03 20:56:33 +0000330Platform-Specific Tests
331-----------------------
332
333Whenever adding tests that require the knowledge of a specific platform,
334either related to code generated, specific output or back-end features,
335you must make sure to isolate the features, so that buildbots that
336run on different architectures (and don't even compile all back-ends),
337don't fail.
338
339The first problem is to check for target-specific output, for example sizes
340of structures, paths and architecture names, for example:
341
342* Tests containing Windows paths will fail on Linux and vice-versa.
343* Tests that check for ``x86_64`` somewhere in the text will fail anywhere else.
344* Tests where the debug information calculates the size of types and structures.
345
346Also, if the test rely on any behaviour that is coded in any back-end, it must
347go in its own directory. So, for instance, code generator tests for ARM go
348into ``test/CodeGen/ARM`` and so on. Those directories contain a special
349``lit`` configuration file that ensure all tests in that directory will
350only run if a specific back-end is compiled and available.
351
352For instance, on ``test/CodeGen/ARM``, the ``lit.local.cfg`` is:
353
354.. code-block:: python
355
356 config.suffixes = ['.ll', '.c', '.cpp', '.test']
Alp Tokerd3d017c2014-06-09 22:42:55 +0000357 if not 'ARM' in config.root.targets:
Renato Golin98c60812013-07-03 20:56:33 +0000358 config.unsupported = True
359
360Other platform-specific tests are those that depend on a specific feature
361of a specific sub-architecture, for example only to Intel chips that support ``AVX2``.
362
363For instance, ``test/CodeGen/X86/psubus.ll`` tests three sub-architecture
364variants:
365
366.. code-block:: llvm
367
368 ; RUN: llc -mcpu=core2 < %s | FileCheck %s -check-prefix=SSE2
369 ; RUN: llc -mcpu=corei7-avx < %s | FileCheck %s -check-prefix=AVX1
370 ; RUN: llc -mcpu=core-avx2 < %s | FileCheck %s -check-prefix=AVX2
371
372And the checks are different:
373
374.. code-block:: llvm
375
376 ; SSE2: @test1
377 ; SSE2: psubusw LCPI0_0(%rip), %xmm0
378 ; AVX1: @test1
379 ; AVX1: vpsubusw LCPI0_0(%rip), %xmm0, %xmm0
380 ; AVX2: @test1
381 ; AVX2: vpsubusw LCPI0_0(%rip), %xmm0, %xmm0
382
383So, if you're testing for a behaviour that you know is platform-specific or
384depends on special features of sub-architectures, you must add the specific
385triple, test with the specific FileCheck and put it into the specific
386directory that will filter out all other architectures.
387
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000388
Greg Parker17db7702017-01-25 02:26:03 +0000389Constraining test execution
390---------------------------
391
392Some tests can be run only in specific configurations, such as
393with debug builds or on particular platforms. Use ``REQUIRES``
394and ``UNSUPPORTED`` to control when the test is enabled.
395
396Some tests are expected to fail. For example, there may be a known bug
397that the test detect. Use ``XFAIL`` to mark a test as an expected failure.
398An ``XFAIL`` test will be successful if its execution fails, and
399will be a failure if its execution succeeds.
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000400
401.. code-block:: llvm
402
Greg Parker17db7702017-01-25 02:26:03 +0000403 ; This test will be only enabled in the build with asserts.
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000404 ; REQUIRES: asserts
Greg Parker17db7702017-01-25 02:26:03 +0000405 ; This test is disabled on Linux.
406 ; UNSUPPORTED: -linux-
407 ; This test is expected to fail on PowerPC.
408 ; XFAIL: powerpc
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000409
Greg Parker17db7702017-01-25 02:26:03 +0000410``REQUIRES`` and ``UNSUPPORTED`` and ``XFAIL`` all accept a comma-separated
411list of boolean expressions. The values in each expression may be:
Piotr Padlewski7a298c12016-07-08 23:47:29 +0000412
Greg Parker17db7702017-01-25 02:26:03 +0000413- Features added to ``config.available_features`` by
414 configuration files such as ``lit.cfg``.
415- Substrings of the target triple (``UNSUPPORTED`` and ``XFAIL`` only).
416
417| ``REQUIRES`` enables the test if all expressions are true.
418| ``UNSUPPORTED`` disables the test if any expression is true.
419| ``XFAIL`` expects the test to fail if any expression is true.
420
421As a special case, ``XFAIL: *`` is expected to fail everywhere.
422
423.. code-block:: llvm
424
425 ; This test is disabled on Windows,
426 ; and is disabled on Linux, except for Android Linux.
427 ; UNSUPPORTED: windows, linux && !android
428 ; This test is expected to fail on both PowerPC and ARM.
429 ; XFAIL: powerpc || arm
430
Renato Golin98c60812013-07-03 20:56:33 +0000431
Nico Rieckc4e7f302014-02-15 08:35:56 +0000432Substitutions
433-------------
Sean Silvaa89edf62012-11-14 21:09:30 +0000434
Nico Rieckc4e7f302014-02-15 08:35:56 +0000435Besides replacing LLVM tool names the following substitutions are performed in
436RUN lines:
Sean Silvaa89edf62012-11-14 21:09:30 +0000437
Nico Rieckc4e7f302014-02-15 08:35:56 +0000438``%%``
439 Replaced by a single ``%``. This allows escaping other substitutions.
Sean Silvaa89edf62012-11-14 21:09:30 +0000440
Nico Rieckc4e7f302014-02-15 08:35:56 +0000441``%s``
442 File path to the test case's source. This is suitable for passing on the
443 command line as the input to an LLVM tool.
Sean Silvaa89edf62012-11-14 21:09:30 +0000444
Nico Rieckc4e7f302014-02-15 08:35:56 +0000445 Example: ``/home/user/llvm/test/MC/ELF/foo_test.s``
Sean Silvaa89edf62012-11-14 21:09:30 +0000446
Nico Rieckc4e7f302014-02-15 08:35:56 +0000447``%S``
448 Directory path to the test case's source.
Sean Silvaa89edf62012-11-14 21:09:30 +0000449
Nico Rieckc4e7f302014-02-15 08:35:56 +0000450 Example: ``/home/user/llvm/test/MC/ELF``
Sean Silvaa89edf62012-11-14 21:09:30 +0000451
Nico Rieckc4e7f302014-02-15 08:35:56 +0000452``%t``
453 File path to a temporary file name that could be used for this test case.
Sean Silvaa89edf62012-11-14 21:09:30 +0000454 The file name won't conflict with other test cases. You can append to it
455 if you need multiple temporaries. This is useful as the destination of
456 some redirected output.
457
Nico Rieckc4e7f302014-02-15 08:35:56 +0000458 Example: ``/home/user/llvm.build/test/MC/ELF/Output/foo_test.s.tmp``
Sean Silvaa89edf62012-11-14 21:09:30 +0000459
Nico Rieckc4e7f302014-02-15 08:35:56 +0000460``%T``
Kuba Mracek77920a42018-06-19 22:22:48 +0000461 Directory of ``%t``. Deprecated. Shouldn't be used, because it can be easily
462 misused and cause race conditions between tests.
463
464 Use ``rm -rf %t && mkdir %t`` instead if a temporary directory is necessary.
Sean Silvaa89edf62012-11-14 21:09:30 +0000465
Nico Rieckc4e7f302014-02-15 08:35:56 +0000466 Example: ``/home/user/llvm.build/test/MC/ELF/Output``
Sean Silvaa89edf62012-11-14 21:09:30 +0000467
Nico Rieckc4e7f302014-02-15 08:35:56 +0000468``%{pathsep}``
469
470 Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
471
David Bozier9126f542017-02-09 14:12:30 +0000472``%/s, %/S, %/t, %/T:``
473
474 Act like the corresponding substitution above but replace any ``\``
475 character with a ``/``. This is useful to normalize path separators.
476
477 Example: ``%s: C:\Desktop Files/foo_test.s.tmp``
478
479 Example: ``%/s: C:/Desktop Files/foo_test.s.tmp``
480
481``%:s, %:S, %:t, %:T:``
482
483 Act like the corresponding substitution above but remove colons at
484 the beginning of Windows paths. This is useful to allow concatenation
485 of absolute paths on Windows to produce a legal path.
486
487 Example: ``%s: C:\Desktop Files\foo_test.s.tmp``
488
489 Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
490
Nico Rieckc4e7f302014-02-15 08:35:56 +0000491
492**LLVM-specific substitutions:**
493
494``%shlibext``
495 The suffix for the host platforms shared library files. This includes the
496 period as the first character.
497
498 Example: ``.so`` (Linux), ``.dylib`` (OS X), ``.dll`` (Windows)
499
500``%exeext``
501 The suffix for the host platforms executable files. This includes the
502 period as the first character.
503
504 Example: ``.exe`` (Windows), empty on Linux.
505
506``%(line)``, ``%(line+<number>)``, ``%(line-<number>)``
507 The number of the line where this substitution is used, with an optional
508 integer offset. This can be used in tests with multiple RUN lines, which
509 reference test file's line numbers.
510
511
512**Clang-specific substitutions:**
513
514``%clang``
515 Invokes the Clang driver.
516
517``%clang_cpp``
518 Invokes the Clang driver for C++.
519
520``%clang_cl``
521 Invokes the CL-compatible Clang driver.
522
523``%clangxx``
524 Invokes the G++-compatible Clang driver.
525
526``%clang_cc1``
527 Invokes the Clang frontend.
528
529``%itanium_abi_triple``, ``%ms_abi_triple``
530 These substitutions can be used to get the current target triple adjusted to
531 the desired ABI. For example, if the test suite is running with the
532 ``i686-pc-win32`` target, ``%itanium_abi_triple`` will expand to
533 ``i686-pc-mingw32``. This allows a test to run with a specific ABI without
534 constraining it to a specific triple.
535
536To add more substituations, look at ``test/lit.cfg`` or ``lit.local.cfg``.
537
Sean Silvaa89edf62012-11-14 21:09:30 +0000538
Matthias Braun29f3f112015-05-04 21:37:00 +0000539Options
540-------
541
542The llvm lit configuration allows to customize some things with user options:
543
544``llc``, ``opt``, ...
545 Substitute the respective llvm tool name with a custom command line. This
546 allows to specify custom paths and default arguments for these tools.
547 Example:
548
549 % llvm-lit "-Dllc=llc -verify-machineinstrs"
550
551``run_long_tests``
552 Enable the execution of long running tests.
553
554``llvm_site_config``
555 Load the specified lit configuration instead of the default one.
556
557
Sean Silvaa89edf62012-11-14 21:09:30 +0000558Other Features
559--------------
560
Nico Rieckea623c62014-01-08 16:30:03 +0000561To make RUN line writing easier, there are several helper programs. These
562helpers are in the PATH when running tests, so you can just call them using
563their name. For example:
Sean Silvaa89edf62012-11-14 21:09:30 +0000564
Sean Silvaa89edf62012-11-14 21:09:30 +0000565``not``
Nico Rieckea623c62014-01-08 16:30:03 +0000566 This program runs its arguments and then inverts the result code from it.
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000567 Zero result codes become 1. Non-zero result codes become 0.
Sean Silvaa89edf62012-11-14 21:09:30 +0000568
Eli Bendersky0ffc0d42012-12-04 14:34:00 +0000569To make the output more useful, :program:`lit` will scan
Sean Silvaa89edf62012-11-14 21:09:30 +0000570the lines of the test case for ones that contain a pattern that matches
571``PR[0-9]+``. This is the syntax for specifying a PR (Problem Report) number
572that is related to the test case. The number after "PR" specifies the
573LLVM bugzilla number. When a PR number is specified, it will be used in
574the pass/fail reporting. This is useful to quickly get some context when
575a test fails.
576
577Finally, any line that contains "END." will cause the special
578interpretation of lines to terminate. This is generally done right after
579the last RUN: line. This has two side effects:
580
581(a) it prevents special interpretation of lines that are part of the test
582 program, not the instructions to the test case, and
583
584(b) it speeds things up for really big test cases by avoiding
585 interpretation of the remainder of the file.