2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
8 Selecting targets to which a test applies
9 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 Several test directives include :samp:`{selector}` s to limit the targets
12 for which a test is run or to declare that a test is expected to fail
13 on particular targets.
17 * one or more target triplets, possibly including wildcard characters;
18 use :samp:`*-*-*` to match any target
20 * a single effective-target keyword (see :ref:`effective-target-keywords`)
22 * a list of compiler options that should be included or excluded
23 (as described in more detail below)
25 * a logical expression
27 Depending on the context, the selector specifies whether a test is
28 skipped and reported as unsupported or is expected to fail. A context
29 that allows either :samp:`target` or :samp:`xfail` also allows
30 :samp:`{ target {selector1} xfail {selector2} }`
31 to skip the test for targets that don't match :samp:`{selector1}` and the
32 test to fail for targets that match :samp:`{selector2}`.
34 A selector expression appears within curly braces and uses a single
35 logical operator: one of :samp:`!`, :samp:`&&`, or :samp:`||`. An
36 operand is one of the following:
38 * another selector expression, in curly braces
40 * an effective-target keyword, such as ``lp64``
42 * a single target triplet
44 * a list of target triplets within quotes or curly braces
46 * one of the following:
48 :samp:`{ any-opts {opt1} ... {optn} }`
49 Each of :samp:`{opt1}` to :samp:`{optn}` is a space-separated list of option globs.
50 The selector expression evaluates to true if, for one of these strings,
51 every glob in the string matches an option that was passed to the compiler.
56 { any-opts "-O3 -flto" "-O[2g]" }
58 is true if any of the following are true:
60 * :option:`-O2` was passed to the compiler
62 * :option:`-Og` was passed to the compiler
64 * both :option:`-O3` and :option:`-flto` were passed to the compiler
66 This kind of selector can only be used within ``dg-final`` directives.
67 Use ``dg-skip-if``, ``dg-xfail-if`` or ``dg-xfail-run-if`` to
68 skip whole tests based on options, or to mark them as expected to fail
71 :samp:`{ no-opts {opt1} ... {optn} }`
72 As for ``any-opts`` above, each of :samp:`{opt1}` to :samp:`{optn}` is a
73 space-separated list of option globs. The selector expression
74 evaluates to true if, for all of these strings, there is at least
75 one glob that does not match an option that was passed to the compiler.
80 { ! { any-opts opt1 ... optn } }
86 { no-opts "-O3 -flto" "-O[2g]" }
88 is true if all of the following are true:
90 * :option:`-O2` was not passed to the compiler
92 * :option:`-Og` was not passed to the compiler
94 * at least one of :option:`-O3` or :option:`-flto` was not passed to the compiler
96 Like ``any-opts``, this kind of selector can only be used within
97 ``dg-final`` directives.
99 Here are some examples of full target selectors:
103 { target { ! "hppa*-*-* ia64*-*-*" } }
104 { target { powerpc*-*-* && lp64 } }
105 { xfail { lp64 || vect_no_align } }
106 { xfail { aarch64*-*-* && { any-opts "-O2" } } }