Cleanup docs about lit substitutions

llvm-svn: 201464
This commit is contained in:
Nico Rieck 2014-02-15 08:35:56 +00:00
parent 17b586d7c5
commit 4165fe44e3

View File

@ -337,69 +337,90 @@ triple, test with the specific FileCheck and put it into the specific
directory that will filter out all other architectures.
Variables and substitutions
---------------------------
Substitutions
-------------
With a RUN line there are a number of substitutions that are permitted.
To make a substitution just write the variable's name preceded by a ``$``.
Additionally, for compatibility reasons with previous versions of the
test library, certain names can be accessed with an alternate syntax: a
% prefix. These alternates are deprecated and may go away in a future
version.
Besides replacing LLVM tool names the following substitutions are performed in
RUN lines:
Here are the available variable names. The alternate syntax is listed in
parentheses.
``%%``
Replaced by a single ``%``. This allows escaping other substitutions.
``$test`` (``%s``)
The full path to the test case's source. This is suitable for passing on
the command line as the input to an LLVM tool.
``%s``
File path to the test case's source. This is suitable for passing on the
command line as the input to an LLVM tool.
``%(line)``, ``%(line+<number>)``, ``%(line-<number>)``
The number of the line where this variable is used, with an optional
integer offset. This can be used in tests with multiple RUN lines,
which reference test file's line numbers.
Example: ``/home/user/llvm/test/MC/ELF/foo_test.s``
``$srcdir``
The source directory from where the ``make check`` was run.
``%S``
Directory path to the test case's source.
``objdir``
The object directory that corresponds to the ``$srcdir``.
Example: ``/home/user/llvm/test/MC/ELF``
``subdir``
A partial path from the ``test`` directory that contains the
sub-directory that contains the test source being executed.
``srcroot``
The root directory of the LLVM src tree.
``objroot``
The root directory of the LLVM object tree. This could be the same as
the srcroot.
``path``
The path to the directory that contains the test case source. This is
for locating any supporting files that are not generated by the test,
but used by the test.
``tmp``
The path to a temporary file name that could be used for this test case.
``%t``
File path to a temporary file name that could be used for this test case.
The file name won't conflict with other test cases. You can append to it
if you need multiple temporaries. This is useful as the destination of
some redirected output.
``target_triplet`` (``%target_triplet``)
The target triplet that corresponds to the current host machine (the one
running the test cases). This should probably be called "host".
Example: ``/home/user/llvm.build/test/MC/ELF/Output/foo_test.s.tmp``
``link`` (``%link``)
This full link command used to link LLVM executables. This has all the
configured ``-I``, ``-L`` and ``-l`` options.
``%T``
Directory of ``%t``.
``shlibext`` (``%shlibext``)
The suffix for the host platforms shared library (DLL) files. This
includes the period as the first character.
Example: ``/home/user/llvm.build/test/MC/ELF/Output``
``%{pathsep}``
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
**LLVM-specific substitutions:**
``%shlibext``
The suffix for the host platforms shared library files. This includes the
period as the first character.
Example: ``.so`` (Linux), ``.dylib`` (OS X), ``.dll`` (Windows)
``%exeext``
The suffix for the host platforms executable files. This includes the
period as the first character.
Example: ``.exe`` (Windows), empty on Linux.
``%(line)``, ``%(line+<number>)``, ``%(line-<number>)``
The number of the line where this substitution is used, with an optional
integer offset. This can be used in tests with multiple RUN lines, which
reference test file's line numbers.
**Clang-specific substitutions:**
``%clang``
Invokes the Clang driver.
``%clang_cpp``
Invokes the Clang driver for C++.
``%clang_cl``
Invokes the CL-compatible Clang driver.
``%clangxx``
Invokes the G++-compatible Clang driver.
``%clang_cc1``
Invokes the Clang frontend.
``%itanium_abi_triple``, ``%ms_abi_triple``
These substitutions can be used to get the current target triple adjusted to
the desired ABI. For example, if the test suite is running with the
``i686-pc-win32`` target, ``%itanium_abi_triple`` will expand to
``i686-pc-mingw32``. This allows a test to run with a specific ABI without
constraining it to a specific triple.
To add more substituations, look at ``test/lit.cfg`` or ``lit.local.cfg``.
To add more variables, look at ``test/lit.cfg``.
Other Features
--------------