Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 1 | import os |
| 2 | import platform |
| 3 | import re |
| 4 | import subprocess |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 5 | import sys |
Thomas Lively | 7062094 | 2022-03-17 15:22:17 -0700 | [diff] [blame] | 6 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 7 | import lit.formats |
| 8 | import lit.util |
| 9 | |
| 10 | from lit.llvm import llvm_config |
| 11 | from lit.llvm.subst import ToolSubst |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 12 | |
| 13 | # Configuration file for the 'lit' test runner. |
| 14 | |
| 15 | # name: The name of this test suite. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 16 | config.name = "cross-project-tests" |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 17 | |
| 18 | # testFormat: The test format to use to interpret tests. |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 19 | config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) |
| 20 | |
| 21 | # suffixes: A list of file extensions to treat as test files. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 22 | config.suffixes = [".c", ".cl", ".cpp", ".m"] |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 23 | |
| 24 | # excludes: A list of directories to exclude from the testsuite. The 'Inputs' |
| 25 | # subdirectories contain auxiliary inputs for various tests in their parent |
| 26 | # directories. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 27 | config.excludes = ["Inputs"] |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 28 | |
| 29 | # test_source_root: The root path where tests are located. |
James Henderson | 24af099 | 2021-02-11 15:41:32 +0000 | [diff] [blame] | 30 | config.test_source_root = config.cross_project_tests_src_root |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 31 | |
| 32 | # test_exec_root: The root path where tests should be run. |
James Henderson | 24af099 | 2021-02-11 15:41:32 +0000 | [diff] [blame] | 33 | config.test_exec_root = config.cross_project_tests_obj_root |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 34 | |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 35 | llvm_config.use_default_substitutions() |
| 36 | |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 37 | tools = [ |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 38 | ToolSubst( |
| 39 | "%test_debuginfo", |
| 40 | command=os.path.join( |
| 41 | config.cross_project_tests_src_root, |
| 42 | "debuginfo-tests", |
| 43 | "llgdb-tests", |
| 44 | "test_debuginfo.pl", |
| 45 | ), |
| 46 | ), |
Christian Sigg | 60346bd | 2020-01-11 08:47:41 +0100 | [diff] [blame] | 47 | ToolSubst("%llvm_src_root", config.llvm_src_root), |
| 48 | ToolSubst("%llvm_tools_dir", config.llvm_tools_dir), |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 49 | ] |
| 50 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 51 | |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 52 | def get_required_attr(config, attr_name): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 53 | attr_value = getattr(config, attr_name, None) |
Eisuke Kawashima | ca92bdf | 2025-01-13 21:03:04 +0900 | [diff] [blame] | 54 | if attr_value is None: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 55 | lit_config.fatal( |
| 56 | "No attribute %r in test configuration! You may need to run " |
| 57 | "tests from your build directory or add this attribute " |
| 58 | "to lit.site.cfg " % attr_name |
| 59 | ) |
| 60 | return attr_value |
| 61 | |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 62 | |
| 63 | # If this is an MSVC environment, the tests at the root of the tree are |
| 64 | # unsupported. The local win_cdb test suite, however, is supported. |
| 65 | is_msvc = get_required_attr(config, "is_msvc") |
| 66 | if is_msvc: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 67 | config.available_features.add("msvc") |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 68 | # FIXME: We should add some llvm lit utility code to find the Windows SDK |
| 69 | # and set up the environment appopriately. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 70 | win_sdk = "C:/Program Files (x86)/Windows Kits/10/" |
| 71 | arch = "x64" |
| 72 | llvm_config.with_system_environment(["LIB", "LIBPATH", "INCLUDE"]) |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 73 | # Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from |
| 74 | # the network. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 75 | llvm_config.with_environment("_NT_SYMBOL_PATH", "") |
| 76 | tools.append( |
| 77 | ToolSubst("%cdb", '"%s"' % os.path.join(win_sdk, "Debuggers", arch, "cdb.exe")) |
| 78 | ) |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 79 | |
James Henderson | 4446a72 | 2021-02-09 14:57:03 +0000 | [diff] [blame] | 80 | # clang_src_dir and lld_src_dir are not used by these tests, but are required by |
| 81 | # use_clang() and use_lld() respectively, so set them to "", if needed. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 82 | if not hasattr(config, "clang_src_dir"): |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 83 | config.clang_src_dir = "" |
Amir Ayupov | 9fec33a | 2024-01-18 19:59:09 -0800 | [diff] [blame] | 84 | llvm_config.use_clang(required=("clang" in config.llvm_enabled_projects)) |
James Henderson | 3827600 | 2021-02-09 15:19:27 +0000 | [diff] [blame] | 85 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 86 | if not hasattr(config, "lld_src_dir"): |
James Henderson | 4446a72 | 2021-02-09 14:57:03 +0000 | [diff] [blame] | 87 | config.lld_src_dir = "" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 88 | llvm_config.use_lld(required=("lld" in config.llvm_enabled_projects)) |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 89 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 90 | if "compiler-rt" in config.llvm_enabled_projects: |
| 91 | config.available_features.add("compiler-rt") |
OCHyams | ac0f329 | 2022-02-09 17:08:43 +0000 | [diff] [blame] | 92 | |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 93 | # Check which debuggers are available: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 94 | lldb_path = llvm_config.use_llvm_tool("lldb", search_env="LLDB") |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 95 | |
| 96 | if lldb_path is not None: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 97 | config.available_features.add("lldb") |
| 98 | |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 99 | |
| 100 | def configure_dexter_substitutions(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 101 | """Configure substitutions for host platform and return list of dependencies""" |
| 102 | # Produce dexter path, lldb path, and combine into the %dexter substitution |
| 103 | # for running a test. |
| 104 | dexter_path = os.path.join( |
| 105 | config.cross_project_tests_src_root, "debuginfo-tests", "dexter", "dexter.py" |
| 106 | ) |
| 107 | dexter_test_cmd = '"{}" "{}" test'.format(sys.executable, dexter_path) |
| 108 | if lldb_path is not None: |
| 109 | dexter_test_cmd += ' --lldb-executable "{}"'.format(lldb_path) |
| 110 | tools.append(ToolSubst("%dexter", dexter_test_cmd)) |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 111 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 112 | # For testing other bits of dexter that aren't under the "test" subcommand, |
| 113 | # have a %dexter_base substitution. |
| 114 | dexter_base_cmd = '"{}" "{}"'.format(sys.executable, dexter_path) |
| 115 | tools.append(ToolSubst("%dexter_base", dexter_base_cmd)) |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 116 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 117 | # Set up commands for DexTer regression tests. |
| 118 | # Builder, debugger, optimisation level and several other flags differ |
| 119 | # depending on whether we're running a unix like or windows os. |
| 120 | if platform.system() == "Windows": |
| 121 | # The Windows builder script uses lld. |
| 122 | dependencies = ["clang", "lld-link"] |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 123 | dexter_regression_test_builder = "clang-cl" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 124 | dexter_regression_test_debugger = "dbgeng" |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 125 | dexter_regression_test_flags = "/Zi /Od" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 126 | else: |
| 127 | # Use lldb as the debugger on non-Windows platforms. |
| 128 | dependencies = ["clang", "lldb"] |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 129 | dexter_regression_test_builder = "clang++" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 130 | dexter_regression_test_debugger = "lldb" |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 131 | dexter_regression_test_flags = "-O0 -glldb -std=gnu++11" |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 132 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 133 | tools.append( |
| 134 | ToolSubst("%dexter_regression_test_builder", dexter_regression_test_builder) |
| 135 | ) |
| 136 | tools.append( |
| 137 | ToolSubst("%dexter_regression_test_debugger", dexter_regression_test_debugger) |
| 138 | ) |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 139 | # We don't need to distinguish cflags and ldflags because for Dexter |
| 140 | # regression tests we use clang to drive the linker, and so all flags will be |
| 141 | # passed in a single command. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 142 | tools.append( |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 143 | ToolSubst("%dexter_regression_test_flags", dexter_regression_test_flags) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 144 | ) |
OCHyams | de3f815 | 2022-01-26 11:09:21 +0000 | [diff] [blame] | 145 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 146 | # Typical command would take the form: |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 147 | # ./path_to_py/python.exe ./path_to_dex/dexter.py test --fail-lt 1.0 -w --binary %t --debugger lldb --cflags '-O0 -g' |
| 148 | dexter_regression_test_run = " ".join( |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 149 | # "python", "dexter.py", test, fail_mode, builder, debugger, cflags, ldflags |
| 150 | [ |
| 151 | '"{}"'.format(sys.executable), |
| 152 | '"{}"'.format(dexter_path), |
| 153 | "test", |
| 154 | "--fail-lt 1.0 -w", |
| 155 | "--debugger", |
| 156 | dexter_regression_test_debugger, |
| 157 | ] |
| 158 | ) |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 159 | tools.append(ToolSubst("%dexter_regression_test_run", dexter_regression_test_run)) |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 160 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 161 | # Include build flags for %dexter_regression_test. |
| 162 | dexter_regression_test_build = " ".join( |
| 163 | [ |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 164 | dexter_regression_test_builder, |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 165 | dexter_regression_test_flags, |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 166 | ] |
| 167 | ) |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 168 | tools.append(ToolSubst("%dexter_regression_test_build", dexter_regression_test_build)) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 169 | return dependencies |
| 170 | |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 171 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 172 | def add_host_triple(clang): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 173 | return "{} --target={}".format(clang, config.host_triple) |
| 174 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 175 | |
| 176 | # The set of arches we can build. |
| 177 | targets = set(config.targets_to_build) |
| 178 | # Add aliases to the target set. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 179 | if "AArch64" in targets: |
| 180 | targets.add("arm64") |
| 181 | if "ARM" in config.targets_to_build: |
| 182 | targets.add("thumbv7") |
| 183 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 184 | |
| 185 | def can_target_host(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 186 | # Check if the targets set contains anything that looks like our host arch. |
| 187 | # The arch name in the triple and targets set may be spelled differently |
| 188 | # (e.g. x86 vs X86). |
| 189 | return any(config.host_triple.lower().startswith(x.lower()) for x in targets) |
| 190 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 191 | |
| 192 | # Dexter tests run on the host machine. If the host arch is supported add |
| 193 | # 'dexter' as an available feature and force the dexter tests to use the host |
| 194 | # triple. |
| 195 | if can_target_host(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 196 | if config.host_triple != config.target_triple: |
| 197 | print("Forcing dexter tests to use host triple {}.".format(config.host_triple)) |
| 198 | dependencies = configure_dexter_substitutions() |
| 199 | if all(d in config.available_features for d in dependencies): |
| 200 | config.available_features.add("dexter") |
| 201 | llvm_config.with_environment( |
| 202 | "PATHTOCLANG", add_host_triple(llvm_config.config.clang) |
| 203 | ) |
| 204 | llvm_config.with_environment( |
| 205 | "PATHTOCLANGPP", add_host_triple(llvm_config.use_llvm_tool("clang++")) |
| 206 | ) |
| 207 | llvm_config.with_environment( |
| 208 | "PATHTOCLANGCL", add_host_triple(llvm_config.use_llvm_tool("clang-cl")) |
| 209 | ) |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 210 | else: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 211 | print( |
| 212 | "Host triple {} not supported. Skipping dexter tests in the " |
| 213 | "debuginfo-tests project.".format(config.host_triple) |
| 214 | ) |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 215 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 216 | tool_dirs = [config.llvm_tools_dir] |
| 217 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 218 | llvm_config.add_tool_substitutions(tools, tool_dirs) |
| 219 | |
| 220 | lit.util.usePlatformSdkOnDarwin(config, lit_config) |
Vedant Kumar | efab30c | 2018-08-04 00:02:48 +0000 | [diff] [blame] | 221 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 222 | if platform.system() == "Darwin": |
| 223 | xcode_lldb_vers = subprocess.check_output(["xcrun", "lldb", "--version"]).decode( |
| 224 | "utf-8" |
| 225 | ) |
Eisuke Kawashima | a1a3e01 | 2025-01-13 21:15:22 +0900 | [diff] [blame] | 226 | match = re.search(r"lldb-(\d+)", xcode_lldb_vers) |
Vedant Kumar | efab30c | 2018-08-04 00:02:48 +0000 | [diff] [blame] | 227 | if match: |
| 228 | apple_lldb_vers = int(match.group(1)) |
| 229 | if apple_lldb_vers < 1000: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 230 | config.available_features.add("apple-lldb-pre-1000") |
| 231 | |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 232 | |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 233 | def get_gdb_version_string(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 234 | """Return gdb's version string, or None if gdb cannot be found or the |
| 235 | --version output is formatted unexpectedly. |
| 236 | """ |
| 237 | # See if we can get a gdb version, e.g. |
| 238 | # $ gdb --version |
| 239 | # GNU gdb (GDB) 10.2 |
| 240 | # ...More stuff... |
| 241 | try: |
| 242 | gdb_vers_lines = ( |
| 243 | subprocess.check_output(["gdb", "--version"]).decode().splitlines() |
| 244 | ) |
| 245 | except: |
| 246 | return None # We coudln't find gdb or something went wrong running it. |
| 247 | if len(gdb_vers_lines) < 1: |
| 248 | print("Unkown GDB version format (too few lines)", file=sys.stderr) |
| 249 | return None |
Eisuke Kawashima | a1a3e01 | 2025-01-13 21:15:22 +0900 | [diff] [blame] | 250 | match = re.search(r"GNU gdb \(.*?\) ((\d|\.)+)", gdb_vers_lines[0].strip()) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 251 | if match is None: |
| 252 | print(f"Unkown GDB version format: {gdb_vers_lines[0]}", file=sys.stderr) |
| 253 | return None |
| 254 | return match.group(1) |
| 255 | |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 256 | |
| 257 | def get_clang_default_dwarf_version_string(triple): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 258 | """Return the default dwarf version string for clang on this (host) platform |
| 259 | or None if we can't work it out. |
| 260 | """ |
| 261 | # Get the flags passed by the driver and look for -dwarf-version. |
| 262 | cmd = f'{llvm_config.use_llvm_tool("clang")} -g -xc -c - -v -### --target={triple}' |
| 263 | stderr = subprocess.run(cmd.split(), stderr=subprocess.PIPE).stderr.decode() |
Eisuke Kawashima | a1a3e01 | 2025-01-13 21:15:22 +0900 | [diff] [blame] | 264 | match = re.search(r"-dwarf-version=(\d+)", stderr) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 265 | if match is None: |
| 266 | print("Cannot determine default dwarf version", file=sys.stderr) |
| 267 | return None |
| 268 | return match.group(1) |
| 269 | |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 270 | |
| 271 | # Some cross-project-tests use gdb, but not all versions of gdb are compatible |
| 272 | # with clang's dwarf. Add feature `gdb-clang-incompatibility` to signal that |
| 273 | # there's an incompatibility between clang's default dwarf version for this |
| 274 | # platform and the installed gdb version. |
| 275 | dwarf_version_string = get_clang_default_dwarf_version_string(config.host_triple) |
| 276 | gdb_version_string = get_gdb_version_string() |
| 277 | if dwarf_version_string and gdb_version_string: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 278 | if int(dwarf_version_string) >= 5: |
dyung | 9374216 | 2024-07-22 11:28:11 -0700 | [diff] [blame] | 279 | try: |
| 280 | from packaging import version |
| 281 | except: |
| 282 | lit_config.fatal("Running gdb tests requires the packaging package") |
| 283 | if version.parse(gdb_version_string) < version.parse("10.1"): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 284 | # Example for llgdb-tests, which use lldb on darwin but gdb elsewhere: |
| 285 | # XFAIL: !system-darwin && gdb-clang-incompatibility |
| 286 | config.available_features.add("gdb-clang-incompatibility") |
| 287 | print( |
| 288 | "XFAIL some tests: use gdb version >= 10.1 to restore test coverage", |
| 289 | file=sys.stderr, |
| 290 | ) |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 291 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 292 | llvm_config.feature_config([("--build-mode", {"Debug|RelWithDebInfo": "debug-info"})]) |
Thomas Lively | 7062094 | 2022-03-17 15:22:17 -0700 | [diff] [blame] | 293 | |
| 294 | # Allow 'REQUIRES: XXX-registered-target' in tests. |
| 295 | for arch in config.targets_to_build: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 296 | config.available_features.add(arch.lower() + "-registered-target") |