|
| 1 | +# ===----------------------------------------------------------------------===## |
| 2 | +# |
| 3 | +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +# See https://llvm.org/LICENSE.txt for license information. |
| 5 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +# |
| 7 | +# ===----------------------------------------------------------------------===## |
| 8 | + |
| 9 | +from libcxx.test.dsl import Feature |
| 10 | +from lit.BooleanExpression import BooleanExpression |
| 11 | + |
| 12 | +# Helpers to define correspondances between LLVM versions and vendor system versions. |
| 13 | +# Those are used for backdeployment features below, do not use directly in tests. |
| 14 | +features = [ |
| 15 | + Feature( |
| 16 | + name="_target-has-llvm-22", |
| 17 | + when=lambda cfg: BooleanExpression.evaluate( |
| 18 | + "TBD", |
| 19 | + cfg.available_features, |
| 20 | + ), |
| 21 | + ), |
| 22 | + Feature( |
| 23 | + name="_target-has-llvm-21", |
| 24 | + when=lambda cfg: BooleanExpression.evaluate( |
| 25 | + "TBD", |
| 26 | + cfg.available_features, |
| 27 | + ), |
| 28 | + ), |
| 29 | + Feature( |
| 30 | + name="_target-has-llvm-20", |
| 31 | + when=lambda cfg: BooleanExpression.evaluate( |
| 32 | + "_target-has-llvm-21 || target={{.+}}-apple-macosx{{26.[0-9](.\d+)?}}", |
| 33 | + cfg.available_features, |
| 34 | + ), |
| 35 | + ), |
| 36 | + Feature( |
| 37 | + name="_target-has-llvm-19", |
| 38 | + when=lambda cfg: BooleanExpression.evaluate( |
| 39 | + "_target-has-llvm-20 || target={{.+}}-apple-macosx{{15.[4-9](.\d+)?}}", |
| 40 | + cfg.available_features, |
| 41 | + ), |
| 42 | + ), |
| 43 | + Feature( |
| 44 | + name="_target-has-llvm-18", |
| 45 | + when=lambda cfg: BooleanExpression.evaluate( |
| 46 | + "_target-has-llvm-19 || target={{.+}}-apple-macosx{{15.[0-3](.\d+)?}}", |
| 47 | + cfg.available_features, |
| 48 | + ), |
| 49 | + ), |
| 50 | + Feature( |
| 51 | + name="_target-has-llvm-17", |
| 52 | + when=lambda cfg: BooleanExpression.evaluate( |
| 53 | + "_target-has-llvm-18 || target={{.+}}-apple-macosx{{14.[4-9](.\d+)?}}", |
| 54 | + cfg.available_features, |
| 55 | + ), |
| 56 | + ), |
| 57 | + Feature( |
| 58 | + name="_target-has-llvm-16", |
| 59 | + when=lambda cfg: BooleanExpression.evaluate( |
| 60 | + "_target-has-llvm-17 || target={{.+}}-apple-macosx{{14.[0-3](.[0-9]+)?}}", |
| 61 | + cfg.available_features, |
| 62 | + ), |
| 63 | + ), |
| 64 | + Feature( |
| 65 | + name="_target-has-llvm-15", |
| 66 | + when=lambda cfg: BooleanExpression.evaluate( |
| 67 | + "_target-has-llvm-16 || target={{.+}}-apple-macosx{{13.[4-9](.[0-9]+)?}}", |
| 68 | + cfg.available_features, |
| 69 | + ), |
| 70 | + ), |
| 71 | + Feature( |
| 72 | + name="_target-has-llvm-14", |
| 73 | + when=lambda cfg: BooleanExpression.evaluate( |
| 74 | + "_target-has-llvm-15", |
| 75 | + cfg.available_features, |
| 76 | + ), |
| 77 | + ), |
| 78 | + Feature( |
| 79 | + name="_target-has-llvm-13", |
| 80 | + when=lambda cfg: BooleanExpression.evaluate( |
| 81 | + "_target-has-llvm-14 || target={{.+}}-apple-macosx{{13.[0-3](.[0-9]+)?}}", |
| 82 | + cfg.available_features, |
| 83 | + ), |
| 84 | + ), |
| 85 | + Feature( |
| 86 | + name="_target-has-llvm-12", |
| 87 | + when=lambda cfg: BooleanExpression.evaluate( |
| 88 | + "_target-has-llvm-13 || target={{.+}}-apple-macosx{{12.[3-9](.[0-9]+)?}}", |
| 89 | + cfg.available_features, |
| 90 | + ), |
| 91 | + ), |
| 92 | +] |
| 93 | + |
| 94 | +# Define features for back-deployment testing. |
| 95 | +# |
| 96 | +# These features can be used to XFAIL tests that fail when deployed on (or compiled |
| 97 | +# for) an older system. For example, if a test exhibits a bug in the libc++ on a |
| 98 | +# particular system version, or if it uses a symbol that is not available on an |
| 99 | +# older version of the dylib, it can be marked as XFAIL with these features. |
| 100 | +# |
| 101 | +# We have two families of Lit features: |
| 102 | +# |
| 103 | +# The first one is `using-built-library-before-llvm-XYZ`. These features encode the |
| 104 | +# fact that the test suite is being *run* against a version of the shared/static library |
| 105 | +# that predates LLVM version XYZ. This is useful to represent the use case of compiling |
| 106 | +# a program against the latest libc++ but then deploying it and running it on an older |
| 107 | +# system with an older version of the (usually shared) library. |
| 108 | +# |
| 109 | +# This feature is built up using the target triple passed to the compiler and the |
| 110 | +# `stdlib=system` Lit feature, which encodes that we're running against the same library |
| 111 | +# as described by the target triple. |
| 112 | +# |
| 113 | +# The second set of features is `availability-<FEATURE>-missing`. This family of Lit |
| 114 | +# features encodes the presence of availability markup in the libc++ headers. This is |
| 115 | +# useful to check that a test fails specifically when compiled for a given deployment |
| 116 | +# target, such as when testing availability markup where we want to make sure that |
| 117 | +# using the annotated facility on a deployment target that doesn't support it will fail |
| 118 | +# at compile time. This can be achieved by creating a `.verify.cpp` test that checks for |
| 119 | +# the right errors and marking the test as `REQUIRES: availability-<FEATURE>-missing`. |
| 120 | +# |
| 121 | +# This feature is built up using the presence of availability markup detected inside |
| 122 | +# __config, the flavor of the library being tested and the target triple passed to the |
| 123 | +# compiler. |
| 124 | +# |
| 125 | +# Note that both families of Lit features are similar but different in important ways. |
| 126 | +# For example, tests for availability markup should be expected to produce diagnostics |
| 127 | +# regardless of whether we're running against a system library, as long as we're using |
| 128 | +# a libc++ flavor that enables availability markup. Similarly, a test could fail when |
| 129 | +# run against the system library of an older version of FreeBSD, even though FreeBSD |
| 130 | +# doesn't provide availability markup at the time of writing this. |
| 131 | +for version in ("12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22"): |
| 132 | + features.append( |
| 133 | + Feature( |
| 134 | + name="using-built-library-before-llvm-{}".format(version), |
| 135 | + when=lambda cfg, v=version: BooleanExpression.evaluate( |
| 136 | + "stdlib=system && !_target-has-llvm-{}".format(v), |
| 137 | + cfg.available_features, |
| 138 | + ), |
| 139 | + ) |
| 140 | + ) |
| 141 | + |
| 142 | +features += [ |
| 143 | + # Tests that require https://wg21.link/P0482 support in the built library |
| 144 | + Feature( |
| 145 | + name="availability-char8_t_support-missing", |
| 146 | + when=lambda cfg: BooleanExpression.evaluate( |
| 147 | + "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && !_target-has-llvm-12)", |
| 148 | + cfg.available_features, |
| 149 | + ), |
| 150 | + ), |
| 151 | + # Tests that require std::to_chars(floating-point) in the built library |
| 152 | + Feature( |
| 153 | + name="availability-fp_to_chars-missing", |
| 154 | + when=lambda cfg: BooleanExpression.evaluate( |
| 155 | + "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && !_target-has-llvm-14)", |
| 156 | + cfg.available_features, |
| 157 | + ), |
| 158 | + ), |
| 159 | + # Tests that require __libcpp_verbose_abort support in the built library |
| 160 | + Feature( |
| 161 | + name="availability-verbose_abort-missing", |
| 162 | + when=lambda cfg: BooleanExpression.evaluate( |
| 163 | + "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && !_target-has-llvm-15)", |
| 164 | + cfg.available_features, |
| 165 | + ), |
| 166 | + ), |
| 167 | + # Tests that require std::pmr support in the built library |
| 168 | + Feature( |
| 169 | + name="availability-pmr-missing", |
| 170 | + when=lambda cfg: BooleanExpression.evaluate( |
| 171 | + "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && !_target-has-llvm-16)", |
| 172 | + cfg.available_features, |
| 173 | + ), |
| 174 | + ), |
| 175 | + # Tests that require support for <print> and std::print in <ostream> in the built library. |
| 176 | + Feature( |
| 177 | + name="availability-print-missing", |
| 178 | + when=lambda cfg: BooleanExpression.evaluate( |
| 179 | + "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && !_target-has-llvm-18)", |
| 180 | + cfg.available_features, |
| 181 | + ), |
| 182 | + ), |
| 183 | + # Tests that require time zone database support in the built library |
| 184 | + Feature( |
| 185 | + name="availability-tzdb-missing", |
| 186 | + when=lambda cfg: BooleanExpression.evaluate( |
| 187 | + "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && !_target-has-llvm-19)", |
| 188 | + cfg.available_features, |
| 189 | + ), |
| 190 | + ), |
| 191 | + # Tests that require std::from_chars(floating-point) in the built library |
| 192 | + Feature( |
| 193 | + name="availability-fp_from_chars-missing", |
| 194 | + when=lambda cfg: BooleanExpression.evaluate( |
| 195 | + "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && !_target-has-llvm-20)", |
| 196 | + cfg.available_features, |
| 197 | + ), |
| 198 | + ), |
| 199 | +] |
0 commit comments