From 566e34829fb6825a8909d19e68a7ca6f62ffda96 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Mon, 12 Dec 2022 11:51:41 -0800 Subject: [PATCH] [lit] Document the 'target=' feature Differential Revision: https://reviews.llvm.org/D139869 --- compiler-rt/docs/TestingGuide.rst | 21 +++++++++++---------- llvm/docs/TestingGuide.rst | 23 +++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/compiler-rt/docs/TestingGuide.rst b/compiler-rt/docs/TestingGuide.rst index 4edda67..a1419ed 100644 --- a/compiler-rt/docs/TestingGuide.rst +++ b/compiler-rt/docs/TestingGuide.rst @@ -31,23 +31,24 @@ REQUIRES, XFAIL, etc. Sometimes it is necessary to restrict a test to a specific target or mark it as an "expected fail" or XFAIL. This is normally achieved using ``REQUIRES:`` or -``XFAIL:`` with a substring of LLVM's default target triple. Unfortunately, the +``XFAIL:`` and the ``target=`` feature, typically with a regular +expression matching an appropriate substring of the triple. Unfortunately, the behaviour of this is somewhat quirky in compiler-rt. There are two main pitfalls to avoid. -The first pitfall is that these directives perform a substring match on the -triple and as such ``XFAIL: mips`` affects more triples than expected. For -example, ``mips-linux-gnu``, ``mipsel-linux-gnu``, ``mips64-linux-gnu``, and -``mips64el-linux-gnu`` will all match a ``XFAIL: mips`` directive. Including a -trailing ``-`` such as in ``XFAIL: mips-`` can help to mitigate this quirk but -even that has issues as described below. +The first pitfall is that these regular expressions may inadvertently match +more triples than expected. For example, ``XFAIL: target=mips{{.*}}`` matches +``mips-linux-gnu``, ``mipsel-linux-gnu``, ``mips64-linux-gnu``, and +``mips64el-linux-gnu``. Including a trailing ``-`` such as in +``XFAIL: target=mips-{{.*}}`` can help to mitigate this quirk but even that has +issues as described below. The second pitfall is that the default target triple is often inappropriate for compiler-rt tests since compiler-rt tests may be compiled for multiple targets. For example, a typical build on an ``x86_64-linux-gnu`` host will often run the -tests for both x86_64 and i386. In this situation ``XFAIL: x86_64`` will mark -both the x86_64 and i386 tests as an expected failure while ``XFAIL: i386`` -will have no effect at all. +tests for both x86_64 and i386. In this situation ``XFAIL: target=x86_64{{{.*}}`` +will mark both the x86_64 and i386 tests as an expected failure while +``XFAIL: target=i386{{.*}}`` will have no effect at all. To remedy both pitfalls, compiler-rt tests provide a feature string which can be used to specify a single target. This string is of the form diff --git a/llvm/docs/TestingGuide.rst b/llvm/docs/TestingGuide.rst index 24437d0..f610747 100644 --- a/llvm/docs/TestingGuide.rst +++ b/llvm/docs/TestingGuide.rst @@ -499,10 +499,10 @@ will be a failure if its execution succeeds. ; This test will be only enabled in the build with asserts. ; REQUIRES: asserts - ; This test is disabled on Linux. - ; UNSUPPORTED: -linux- - ; This test is expected to fail on PowerPC. - ; XFAIL: powerpc + ; This test is disabled when running on Linux. + ; UNSUPPORTED: system-linux + ; This test is expected to fail when targeting PowerPC. + ; XFAIL: target=powerpc{{.*}} ``REQUIRES`` and ``UNSUPPORTED`` and ``XFAIL`` all accept a comma-separated list of boolean expressions. The values in each expression may be: @@ -513,7 +513,10 @@ list of boolean expressions. The values in each expression may be: expression is satisfied if any feature matches the regular expression. Regular expressions can appear inside an identifier, so for example ``he{{l+}}o`` would match ``helo``, ``hello``, ``helllo``, and so on. -- Substrings of the target triple (``UNSUPPORTED`` and ``XFAIL`` only). +- The default target triple, preceded by the string ``target=`` (for example, + ``target=x86_64-pc-windows-msvc``). Typically regular expressions are used + to match parts of the triple (for example, ``target={{.*}}-windows{{.*}}`` + to match any Windows target triple). | ``REQUIRES`` enables the test if all expressions are true. | ``UNSUPPORTED`` disables the test if any expression is true. @@ -523,11 +526,11 @@ As a special case, ``XFAIL: *`` is expected to fail everywhere. .. code-block:: llvm - ; This test is disabled on Windows, - ; and is disabled on Linux, except for Android Linux. - ; UNSUPPORTED: windows, linux && !android - ; This test is expected to fail on both PowerPC and ARM. - ; XFAIL: powerpc || arm + ; This test is disabled when running on Windows, + ; and is disabled when targeting Linux, except for Android Linux. + ; UNSUPPORTED: system-windows, target={{.*linux.*}} && !target={{.*android.*}} + ; This test is expected to fail when targeting PowerPC or running on Darwin. + ; XFAIL: target=powerpc{{.*}}, system-darwin Substitutions -- 2.7.4