[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / lldb / test / Shell / lit.cfg.py
blobd75c1f532e147f6c75780aaf406df93c1701de25
1 # -*- Python -*-
3 import os
4 import platform
5 import re
6 import shutil
7 import site
8 import subprocess
9 import sys
11 import lit.formats
12 from lit.llvm import llvm_config
13 from lit.llvm.subst import FindTool
14 from lit.llvm.subst import ToolSubst
16 site.addsitedir(os.path.dirname(__file__))
17 from helper import toolchain
19 # name: The name of this test suite.
20 config.name = "lldb-shell"
22 # testFormat: The test format to use to interpret tests.
23 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
25 # suffixes: A list of file extensions to treat as test files. This is overriden
26 # by individual lit.local.cfg files in the test subdirectories.
27 config.suffixes = [".test", ".cpp", ".s", ".m"]
29 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
30 # subdirectories contain auxiliary inputs for various tests in their parent
31 # directories.
32 config.excludes = ["Inputs", "CMakeLists.txt", "README.txt", "LICENSE.txt"]
34 # test_source_root: The root path where tests are located.
35 config.test_source_root = os.path.dirname(__file__)
37 # test_exec_root: The root path where tests should be run.
38 config.test_exec_root = os.path.join(config.lldb_obj_root, "test", "Shell")
40 # Propagate environment vars.
41 llvm_config.with_system_environment(
43 "FREEBSD_LEGACY_PLUGIN",
44 "HOME",
45 "TEMP",
46 "TMP",
47 "XDG_CACHE_HOME",
51 # Enable sanitizer runtime flags.
52 config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
53 config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
55 # Support running the test suite under the lldb-repro wrapper. This makes it
56 # possible to capture a test suite run and then rerun all the test from the
57 # just captured reproducer.
58 lldb_repro_mode = lit_config.params.get("lldb-run-with-repro", None)
59 if lldb_repro_mode:
60 config.available_features.add("lldb-repro")
61 lit_config.note("Running Shell tests in {} mode.".format(lldb_repro_mode))
62 toolchain.use_lldb_repro_substitutions(config, lldb_repro_mode)
64 llvm_config.use_default_substitutions()
65 toolchain.use_lldb_substitutions(config)
66 toolchain.use_support_substitutions(config)
68 if re.match(r"^arm(hf.*-linux)|(.*-linux-gnuabihf)", config.target_triple):
69 config.available_features.add("armhf-linux")
71 if re.match(r".*-(windows-msvc)$", config.target_triple):
72 config.available_features.add("windows-msvc")
74 if re.match(r".*-(windows-gnu|mingw32)$", config.target_triple):
75 config.available_features.add("windows-gnu")
78 def calculate_arch_features(arch_string):
79 # This will add a feature such as x86, arm, mips, etc for each built
80 # target
81 features = []
82 for arch in arch_string.split():
83 features.append(arch.lower())
84 return features
87 # Run llvm-config and add automatically add features for whether we have
88 # assertions enabled, whether we are in debug mode, and what targets we
89 # are built for.
90 llvm_config.feature_config(
92 ("--assertion-mode", {"ON": "asserts"}),
93 ("--build-mode", {"DEBUG": "debug"}),
94 ("--targets-built", calculate_arch_features),
98 # Clean the module caches in the test build directory. This is necessary in an
99 # incremental build whenever clang changes underneath, so doing it once per
100 # lit.py invocation is close enough.
101 for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
102 if os.path.isdir(cachedir):
103 lit_config.note("Deleting module cache at %s." % cachedir)
104 shutil.rmtree(cachedir)
106 # Set a default per-test timeout of 10 minutes. Setting a timeout per test
107 # requires that killProcessAndChildren() is supported on the platform and
108 # lit complains if the value is set but it is not supported.
109 supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
110 if supported:
111 lit_config.maxIndividualTestTime = 600
112 else:
113 lit_config.warning("Could not set a default per-test timeout. " + errormsg)
116 # If running tests natively, check for CPU features needed for some tests.
118 if "native" in config.available_features:
119 cpuid_exe = lit.util.which("lit-cpuid", config.lldb_tools_dir)
120 if cpuid_exe is None:
121 lit_config.warning(
122 "lit-cpuid not found, tests requiring CPU extensions will be skipped"
124 else:
125 out, err, exitcode = lit.util.executeCommand([cpuid_exe])
126 if exitcode == 0:
127 for x in out.split():
128 config.available_features.add("native-cpu-%s" % x)
129 else:
130 lit_config.warning("lit-cpuid failed: %s" % err)
132 if config.lldb_enable_python:
133 config.available_features.add("python")
135 if config.lldb_enable_lua:
136 config.available_features.add("lua")
138 if config.lldb_enable_lzma:
139 config.available_features.add("lzma")
141 if shutil.which("xz") != None:
142 config.available_features.add("xz")
144 if config.lldb_system_debugserver:
145 config.available_features.add("system-debugserver")
147 if config.have_lldb_server:
148 config.available_features.add("lldb-server")
150 if config.objc_gnustep_dir:
151 config.available_features.add("objc-gnustep")
152 if platform.system() == "Windows":
153 # objc.dll must be in PATH since Windows has no rpath
154 config.environment["PATH"] = os.path.pathsep.join(
156 os.path.join(config.objc_gnustep_dir, "lib"),
157 config.environment.get("PATH", ""),
161 # NetBSD permits setting dbregs either if one is root
162 # or if user_set_dbregs is enabled
163 can_set_dbregs = True
164 if platform.system() == "NetBSD" and os.geteuid() != 0:
165 try:
166 output = (
167 subprocess.check_output(
168 ["/sbin/sysctl", "-n", "security.models.extensions.user_set_dbregs"]
170 .decode()
171 .strip()
173 if output != "1":
174 can_set_dbregs = False
175 except subprocess.CalledProcessError:
176 can_set_dbregs = False
177 if can_set_dbregs:
178 config.available_features.add("dbregs-set")
180 if "LD_PRELOAD" in os.environ:
181 config.available_features.add("ld_preload-present")