2018-04-18 17:08:49 +00:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
import os
|
2019-02-26 19:46:29 +00:00
|
|
|
import platform
|
2018-07-04 17:14:52 +00:00
|
|
|
import shlex
|
2019-10-10 17:27:09 +00:00
|
|
|
import shutil
|
2020-07-31 10:52:49 -07:00
|
|
|
import subprocess
|
2024-06-17 10:20:52 -07:00
|
|
|
import sys
|
2018-04-18 17:08:49 +00:00
|
|
|
|
|
|
|
import lit.formats
|
|
|
|
|
|
|
|
# name: The name of this test suite.
|
2019-10-09 19:22:02 +00:00
|
|
|
config.name = "lldb-api"
|
2018-04-18 17:08:49 +00:00
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
|
|
|
config.suffixes = [".py"]
|
|
|
|
|
|
|
|
# test_source_root: The root path where tests are located.
|
2021-03-19 17:57:17 -07:00
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
2018-04-18 17:08:49 +00:00
|
|
|
|
2021-03-22 15:13:15 +01:00
|
|
|
# test_exec_root: The root path where tests should be run.
|
|
|
|
config.test_exec_root = os.path.join(config.lldb_obj_root, "test", "API")
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-06-11 15:39:49 -07:00
|
|
|
|
2020-06-11 19:29:26 -07:00
|
|
|
def mkdir_p(path):
|
2020-08-28 18:05:01 -07:00
|
|
|
import errno
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
try:
|
|
|
|
os.makedirs(path)
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno != errno.EEXIST:
|
|
|
|
raise
|
|
|
|
if not os.path.isdir(path):
|
|
|
|
raise OSError(errno.ENOTDIR, "%s is not a directory" % path)
|
2020-06-11 19:29:26 -07:00
|
|
|
|
|
|
|
|
2020-06-11 15:39:49 -07:00
|
|
|
def find_sanitizer_runtime(name):
|
|
|
|
resource_dir = (
|
|
|
|
subprocess.check_output([config.cmake_cxx_compiler, "-print-resource-dir"])
|
|
|
|
.decode("utf-8")
|
|
|
|
.strip()
|
2023-05-25 08:48:57 -07:00
|
|
|
)
|
2020-06-11 15:39:49 -07:00
|
|
|
return os.path.join(resource_dir, "lib", "darwin", name)
|
2018-08-20 22:00:31 +00:00
|
|
|
|
2020-01-10 14:38:19 -08:00
|
|
|
|
2019-02-26 19:46:29 +00:00
|
|
|
def find_shlibpath_var():
|
2023-12-01 16:06:22 -05:00
|
|
|
if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]:
|
2019-02-26 19:46:29 +00:00
|
|
|
yield "LD_LIBRARY_PATH"
|
|
|
|
elif platform.system() == "Darwin":
|
|
|
|
yield "DYLD_LIBRARY_PATH"
|
|
|
|
elif platform.system() == "Windows":
|
|
|
|
yield "PATH"
|
|
|
|
|
2020-01-10 14:38:19 -08:00
|
|
|
|
2020-06-11 19:29:26 -07:00
|
|
|
# On macOS, we can't do the DYLD_INSERT_LIBRARIES trick with a shim python
|
|
|
|
# binary as the ASan interceptors get loaded too late. Also, when SIP is
|
|
|
|
# enabled, we can't inject libraries into system binaries at all, so we need a
|
|
|
|
# copy of the "real" python to work with.
|
|
|
|
def find_python_interpreter():
|
2024-06-14 11:52:27 -07:00
|
|
|
# This is only necessary when using DYLD_INSERT_LIBRARIES.
|
|
|
|
if "DYLD_INSERT_LIBRARIES" not in config.environment:
|
|
|
|
return None
|
|
|
|
|
2024-06-17 14:52:40 -07:00
|
|
|
# If we're running in a virtual environment, we have to copy Python into
|
|
|
|
# the virtual environment for it to work.
|
2024-06-17 10:20:52 -07:00
|
|
|
if sys.prefix != sys.base_prefix:
|
2024-06-17 14:52:40 -07:00
|
|
|
copied_python = os.path.join(sys.prefix, "bin", "copied-python")
|
|
|
|
else:
|
|
|
|
copied_python = os.path.join(config.lldb_build_directory, "copied-python")
|
2024-06-14 11:52:27 -07:00
|
|
|
|
2020-06-11 19:29:26 -07:00
|
|
|
# Avoid doing any work if we already copied the binary.
|
|
|
|
if os.path.isfile(copied_python):
|
|
|
|
return copied_python
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-06-11 19:29:26 -07:00
|
|
|
# Find the "real" python binary.
|
|
|
|
real_python = (
|
|
|
|
subprocess.check_output(
|
2023-05-25 08:48:57 -07:00
|
|
|
[
|
2020-06-11 19:29:26 -07:00
|
|
|
config.python_executable,
|
2019-08-28 00:32:19 +00:00
|
|
|
os.path.join(
|
2020-06-11 19:29:26 -07:00
|
|
|
os.path.dirname(os.path.realpath(__file__)),
|
|
|
|
"get_darwin_real_python.py",
|
2023-05-25 08:48:57 -07:00
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
2020-06-11 19:29:26 -07:00
|
|
|
.decode("utf-8")
|
2023-05-25 08:48:57 -07:00
|
|
|
.strip()
|
|
|
|
)
|
|
|
|
|
2020-06-11 19:29:26 -07:00
|
|
|
shutil.copy(real_python, copied_python)
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-06-11 19:29:26 -07:00
|
|
|
# Now make sure the copied Python works. The Python in Xcode has a relative
|
|
|
|
# RPATH and cannot be copied.
|
2023-05-25 08:48:57 -07:00
|
|
|
try:
|
2020-06-11 19:29:26 -07:00
|
|
|
# We don't care about the output, just make sure it runs.
|
2024-06-14 11:52:27 -07:00
|
|
|
subprocess.check_call([copied_python, "-V"])
|
2020-06-11 19:29:26 -07:00
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
# The copied Python didn't work. Assume we're dealing with the Python
|
|
|
|
# interpreter in Xcode. Given that this is not a system binary SIP
|
2024-06-18 08:07:49 -07:00
|
|
|
# won't prevent us form injecting the interceptors, but when running in
|
|
|
|
# a virtual environment, we can't use it directly. Create a symlink
|
|
|
|
# instead.
|
2020-06-11 19:29:26 -07:00
|
|
|
os.remove(copied_python)
|
2024-06-18 08:07:49 -07:00
|
|
|
os.symlink(real_python, copied_python)
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-06-11 19:29:26 -07:00
|
|
|
# The copied Python works.
|
|
|
|
return copied_python
|
|
|
|
|
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
def is_configured(attr):
|
|
|
|
"""Return the configuration attribute if it exists and None otherwise.
|
|
|
|
|
|
|
|
This allows us to check if the attribute exists before trying to access it."""
|
|
|
|
return getattr(config, attr, None)
|
|
|
|
|
|
|
|
|
|
|
|
def delete_module_cache(path):
|
|
|
|
"""Clean the module caches in the test build directory.
|
|
|
|
|
|
|
|
This is necessary in an incremental build whenever clang changes underneath,
|
|
|
|
so doing it once per lit.py invocation is close enough."""
|
|
|
|
if os.path.isdir(path):
|
2022-01-07 13:34:06 -08:00
|
|
|
lit_config.note("Deleting module cache at %s." % path)
|
2020-08-28 18:05:01 -07:00
|
|
|
shutil.rmtree(path)
|
2020-06-11 15:39:49 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
|
|
|
|
if is_configured("llvm_use_sanitizer"):
|
2024-11-06 09:58:32 -08:00
|
|
|
config.environment["MallocNanoZone"] = "0"
|
2020-08-28 18:05:01 -07:00
|
|
|
if "Address" in config.llvm_use_sanitizer:
|
|
|
|
config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1"
|
2021-12-01 20:01:45 -08:00
|
|
|
if "Darwin" in config.host_os:
|
2020-08-28 18:05:01 -07:00
|
|
|
config.environment["DYLD_INSERT_LIBRARIES"] = find_sanitizer_runtime(
|
|
|
|
"libclang_rt.asan_osx_dynamic.dylib"
|
|
|
|
)
|
2020-06-11 15:39:49 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if "Thread" in config.llvm_use_sanitizer:
|
2023-08-07 11:26:28 -07:00
|
|
|
config.environment["TSAN_OPTIONS"] = "halt_on_error=1"
|
2021-12-01 20:01:45 -08:00
|
|
|
if "Darwin" in config.host_os:
|
2020-08-28 18:05:01 -07:00
|
|
|
config.environment["DYLD_INSERT_LIBRARIES"] = find_sanitizer_runtime(
|
|
|
|
"libclang_rt.tsan_osx_dynamic.dylib"
|
2023-05-25 08:48:57 -07:00
|
|
|
)
|
|
|
|
|
2024-06-14 11:52:27 -07:00
|
|
|
if platform.system() == "Darwin":
|
|
|
|
python_executable = find_python_interpreter()
|
|
|
|
if python_executable:
|
|
|
|
lit_config.note(
|
|
|
|
"Using {} instead of {}".format(python_executable, config.python_executable)
|
|
|
|
)
|
|
|
|
config.python_executable = python_executable
|
2020-06-11 19:29:26 -07:00
|
|
|
|
2019-08-30 23:16:02 +00:00
|
|
|
# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("shared_libs"):
|
2019-08-28 00:32:19 +00:00
|
|
|
for shlibpath_var in find_shlibpath_var():
|
|
|
|
# In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
|
|
|
|
# llvm_libs_dir specifies LLVM's lib directory.
|
|
|
|
shlibpath = os.path.pathsep.join(
|
2019-08-30 23:16:02 +00:00
|
|
|
(
|
|
|
|
config.llvm_shlib_dir,
|
|
|
|
config.llvm_libs_dir,
|
|
|
|
config.environment.get(shlibpath_var, ""),
|
|
|
|
)
|
2023-05-25 08:48:57 -07:00
|
|
|
)
|
2019-08-28 00:32:19 +00:00
|
|
|
config.environment[shlibpath_var] = shlibpath
|
|
|
|
else:
|
2019-08-30 23:16:02 +00:00
|
|
|
lit_config.warning(
|
|
|
|
"unable to inject shared library path on '{}'".format(platform.system())
|
|
|
|
)
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-10-13 16:50:40 +02:00
|
|
|
lldb_use_simulator = lit_config.params.get("lldb-run-with-simulator", None)
|
|
|
|
if lldb_use_simulator:
|
|
|
|
if lldb_use_simulator == "ios":
|
|
|
|
lit_config.note("Running API tests on iOS simulator")
|
|
|
|
config.available_features.add("lldb-simulator-ios")
|
|
|
|
elif lldb_use_simulator == "watchos":
|
|
|
|
lit_config.note("Running API tests on watchOS simulator")
|
|
|
|
config.available_features.add("lldb-simulator-watchos")
|
|
|
|
elif lldb_use_simulator == "tvos":
|
|
|
|
lit_config.note("Running API tests on tvOS simulator")
|
|
|
|
config.available_features.add("lldb-simulator-tvos")
|
|
|
|
else:
|
|
|
|
lit_config.error("Unknown simulator id '{}'".format(lldb_use_simulator))
|
|
|
|
|
2019-10-10 19:51:50 +00:00
|
|
|
# Set a default per-test timeout of 10 minutes. Setting a timeout per test
|
|
|
|
# requires that killProcessAndChildren() is supported on the platform and
|
|
|
|
# lit complains if the value is set but it is not supported.
|
|
|
|
supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
|
|
|
|
if supported:
|
2019-11-05 10:12:05 -08:00
|
|
|
lit_config.maxIndividualTestTime = 600
|
2019-10-10 19:51:50 +00:00
|
|
|
else:
|
2019-11-05 10:12:05 -08:00
|
|
|
lit_config.warning("Could not set a default per-test timeout. " + errormsg)
|
2019-10-10 19:51:50 +00:00
|
|
|
|
2018-04-18 17:08:49 +00:00
|
|
|
# Build dotest command.
|
2020-08-28 15:42:43 -07:00
|
|
|
dotest_cmd = [os.path.join(config.lldb_src_root, "test", "API", "dotest.py")]
|
2020-08-28 18:05:01 -07:00
|
|
|
|
[lldb] Fix dotest argument order
When running LLDB API tests, a user can override test arguments with
LLDB_TEST_USER_ARGS. However, these flags used to be concatenated with a
CMake-derived variable LLDB_TEST_COMMON_ARGS, as below:
```
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}
CACHE INTERNAL STRING)
```
This is problematic, because LLDB_TEST_COMMON_ARGS must be processed
first, while LLDB_TEST_USER_ARGS args must be processed last, so that
user overrides are respected. Currently, if a user attempts to override
one of the "inferred" flags, the user's request is ignored. This is the
case, for example, with `--libcxx-include-dir` and
`--libcxx-library-dir`. Both flags are needed by the greendragon bots.
This commit removes the concatenation above, keeping the two original
variables throughout the entire flow, processing the user's flag last.
The variable LLDB_TEST_COMMON_ARGS needs to be a CACHE property, but it
is modified throughout the CMake file with `set` or `list` or `string`
commands, which don't work with properties. As such, a temporary
variable `LLDB_TEST_COMMON_ARGS_VAR` is created.
This was tested locally by invoking CMake with:
-DLLDB_TEST_USER_ARGS="--libcxx-include-dir=blah --libcxx-library-dir=blah2"
and checking that tests failed appropriately.
Differential Revision: https://reviews.llvm.org/D132642
2022-08-23 11:11:06 -04:00
|
|
|
if is_configured("dotest_common_args_str"):
|
|
|
|
dotest_cmd.extend(config.dotest_common_args_str.split(";"))
|
2018-04-18 17:08:49 +00:00
|
|
|
|
2022-07-11 14:03:53 -07:00
|
|
|
# Library path may be needed to locate just-built clang and libcxx.
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("llvm_libs_dir"):
|
2019-03-06 14:03:18 +00:00
|
|
|
dotest_cmd += ["--env", "LLVM_LIBS_DIR=" + config.llvm_libs_dir]
|
|
|
|
|
2022-07-11 14:03:53 -07:00
|
|
|
# Include path may be needed to locate just-built libcxx.
|
|
|
|
if is_configured("llvm_include_dir"):
|
|
|
|
dotest_cmd += ["--env", "LLVM_INCLUDE_DIR=" + config.llvm_include_dir]
|
|
|
|
|
2022-07-05 10:50:37 +02:00
|
|
|
# This path may be needed to locate required llvm tools
|
|
|
|
if is_configured("llvm_tools_dir"):
|
|
|
|
dotest_cmd += ["--env", "LLVM_TOOLS_DIR=" + config.llvm_tools_dir]
|
|
|
|
|
2022-07-11 14:03:53 -07:00
|
|
|
# If we have a just-built libcxx, prefer it over the system one.
|
2022-09-10 07:21:27 -04:00
|
|
|
if is_configured("has_libcxx") and config.has_libcxx:
|
|
|
|
if platform.system() != "Windows":
|
2022-10-26 12:07:22 -07:00
|
|
|
if is_configured("libcxx_include_dir") and is_configured("libcxx_libs_dir"):
|
|
|
|
dotest_cmd += ["--libcxx-include-dir", config.libcxx_include_dir]
|
|
|
|
if is_configured("libcxx_include_target_dir"):
|
|
|
|
dotest_cmd += [
|
|
|
|
"--libcxx-include-target-dir",
|
|
|
|
config.libcxx_include_target_dir,
|
|
|
|
]
|
|
|
|
dotest_cmd += ["--libcxx-library-dir", config.libcxx_libs_dir]
|
2022-07-11 14:03:53 -07:00
|
|
|
|
2019-12-11 16:19:08 -08:00
|
|
|
# Forward ASan-specific environment variables to tests, as a test may load an
|
|
|
|
# ASan-ified dylib.
|
|
|
|
for env_var in ("ASAN_OPTIONS", "DYLD_INSERT_LIBRARIES"):
|
|
|
|
if env_var in config.environment:
|
|
|
|
dotest_cmd += ["--inferior-env", env_var + "=" + config.environment[env_var]]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("test_arch"):
|
|
|
|
dotest_cmd += ["--arch", config.test_arch]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("lldb_build_directory"):
|
2019-08-29 18:37:05 +00:00
|
|
|
dotest_cmd += ["--build-dir", config.lldb_build_directory]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("lldb_module_cache"):
|
|
|
|
delete_module_cache(config.lldb_module_cache)
|
2019-10-10 17:27:09 +00:00
|
|
|
dotest_cmd += ["--lldb-module-cache-dir", config.lldb_module_cache]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("clang_module_cache"):
|
|
|
|
delete_module_cache(config.clang_module_cache)
|
2019-10-10 17:27:09 +00:00
|
|
|
dotest_cmd += ["--clang-module-cache-dir", config.clang_module_cache]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("lldb_executable"):
|
2020-01-10 14:38:19 -08:00
|
|
|
dotest_cmd += ["--executable", config.lldb_executable]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("test_compiler"):
|
2020-01-10 14:38:19 -08:00
|
|
|
dotest_cmd += ["--compiler", config.test_compiler]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("dsymutil"):
|
2020-01-10 14:38:19 -08:00
|
|
|
dotest_cmd += ["--dsymutil", config.dsymutil]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2024-10-10 12:55:31 +02:00
|
|
|
if is_configured("make"):
|
|
|
|
dotest_cmd += ["--make", config.make]
|
|
|
|
|
2021-01-22 21:48:17 +01:00
|
|
|
if is_configured("llvm_tools_dir"):
|
|
|
|
dotest_cmd += ["--llvm-tools-dir", config.llvm_tools_dir]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-09-29 13:26:09 -07:00
|
|
|
if is_configured("server"):
|
|
|
|
dotest_cmd += ["--server", config.server]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2024-04-29 13:26:24 -07:00
|
|
|
if is_configured("lldb_obj_root"):
|
|
|
|
dotest_cmd += ["--lldb-obj-root", config.lldb_obj_root]
|
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("lldb_libs_dir"):
|
2020-01-31 09:35:34 +01:00
|
|
|
dotest_cmd += ["--lldb-libs-dir", config.lldb_libs_dir]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:15:28 -07:00
|
|
|
if is_configured("lldb_framework_dir"):
|
|
|
|
dotest_cmd += ["--framework", config.lldb_framework_dir]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-10-13 16:50:40 +02:00
|
|
|
if "lldb-simulator-ios" in config.available_features:
|
|
|
|
dotest_cmd += ["--apple-sdk", "iphonesimulator", "--platform-name", "ios-simulator"]
|
|
|
|
elif "lldb-simulator-watchos" in config.available_features:
|
|
|
|
dotest_cmd += [
|
|
|
|
"--apple-sdk",
|
|
|
|
"watchsimulator",
|
|
|
|
"--platform-name",
|
|
|
|
"watchos-simulator",
|
|
|
|
]
|
|
|
|
elif "lldb-simulator-tvos" in config.available_features:
|
|
|
|
dotest_cmd += [
|
|
|
|
"--apple-sdk",
|
|
|
|
"appletvsimulator",
|
|
|
|
"--platform-name",
|
|
|
|
"tvos-simulator",
|
|
|
|
]
|
2023-05-25 08:48:57 -07:00
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("enabled_plugins"):
|
2020-04-03 19:42:58 -07:00
|
|
|
for plugin in config.enabled_plugins:
|
|
|
|
dotest_cmd += ["--enable-plugin", plugin]
|
|
|
|
|
[lldb] Fix dotest argument order
When running LLDB API tests, a user can override test arguments with
LLDB_TEST_USER_ARGS. However, these flags used to be concatenated with a
CMake-derived variable LLDB_TEST_COMMON_ARGS, as below:
```
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}
CACHE INTERNAL STRING)
```
This is problematic, because LLDB_TEST_COMMON_ARGS must be processed
first, while LLDB_TEST_USER_ARGS args must be processed last, so that
user overrides are respected. Currently, if a user attempts to override
one of the "inferred" flags, the user's request is ignored. This is the
case, for example, with `--libcxx-include-dir` and
`--libcxx-library-dir`. Both flags are needed by the greendragon bots.
This commit removes the concatenation above, keeping the two original
variables throughout the entire flow, processing the user's flag last.
The variable LLDB_TEST_COMMON_ARGS needs to be a CACHE property, but it
is modified throughout the CMake file with `set` or `list` or `string`
commands, which don't work with properties. As such, a temporary
variable `LLDB_TEST_COMMON_ARGS_VAR` is created.
This was tested locally by invoking CMake with:
-DLLDB_TEST_USER_ARGS="--libcxx-include-dir=blah --libcxx-library-dir=blah2"
and checking that tests failed appropriately.
Differential Revision: https://reviews.llvm.org/D132642
2022-08-23 11:11:06 -04:00
|
|
|
# `dotest` args come from three different sources:
|
|
|
|
# 1. Derived by CMake based on its configs (LLDB_TEST_COMMON_ARGS), which end
|
|
|
|
# up in `dotest_common_args_str`.
|
|
|
|
# 2. CMake user parameters (LLDB_TEST_USER_ARGS), which end up in
|
|
|
|
# `dotest_user_args_str`.
|
|
|
|
# 3. With `llvm-lit "--param=dotest-args=..."`, which end up in
|
|
|
|
# `dotest_lit_args_str`.
|
|
|
|
# Check them in this order, so that more specific overrides are visited last.
|
|
|
|
# In particular, (1) is visited at the top of the file, since the script
|
|
|
|
# derives other information from it.
|
|
|
|
|
2024-10-07 20:31:33 +02:00
|
|
|
if is_configured("lldb_platform_url"):
|
|
|
|
dotest_cmd += ["--platform-url", config.lldb_platform_url]
|
|
|
|
if is_configured("lldb_platform_working_dir"):
|
|
|
|
dotest_cmd += ["--platform-working-dir", config.lldb_platform_working_dir]
|
|
|
|
if is_configured("cmake_sysroot"):
|
|
|
|
dotest_cmd += ["--sysroot", config.cmake_sysroot]
|
|
|
|
|
[lldb] Fix dotest argument order
When running LLDB API tests, a user can override test arguments with
LLDB_TEST_USER_ARGS. However, these flags used to be concatenated with a
CMake-derived variable LLDB_TEST_COMMON_ARGS, as below:
```
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}
CACHE INTERNAL STRING)
```
This is problematic, because LLDB_TEST_COMMON_ARGS must be processed
first, while LLDB_TEST_USER_ARGS args must be processed last, so that
user overrides are respected. Currently, if a user attempts to override
one of the "inferred" flags, the user's request is ignored. This is the
case, for example, with `--libcxx-include-dir` and
`--libcxx-library-dir`. Both flags are needed by the greendragon bots.
This commit removes the concatenation above, keeping the two original
variables throughout the entire flow, processing the user's flag last.
The variable LLDB_TEST_COMMON_ARGS needs to be a CACHE property, but it
is modified throughout the CMake file with `set` or `list` or `string`
commands, which don't work with properties. As such, a temporary
variable `LLDB_TEST_COMMON_ARGS_VAR` is created.
This was tested locally by invoking CMake with:
-DLLDB_TEST_USER_ARGS="--libcxx-include-dir=blah --libcxx-library-dir=blah2"
and checking that tests failed appropriately.
Differential Revision: https://reviews.llvm.org/D132642
2022-08-23 11:11:06 -04:00
|
|
|
if is_configured("dotest_user_args_str"):
|
|
|
|
dotest_cmd.extend(config.dotest_user_args_str.split(";"))
|
|
|
|
|
2020-08-28 18:05:01 -07:00
|
|
|
if is_configured("dotest_lit_args_str"):
|
|
|
|
# We don't want to force users passing arguments to lit to use `;` as a
|
|
|
|
# separator. We use Python's simple lexical analyzer to turn the args into a
|
|
|
|
# list. Pass there arguments last so they can override anything that was
|
|
|
|
# already configured.
|
2020-01-10 14:38:19 -08:00
|
|
|
dotest_cmd.extend(shlex.split(config.dotest_lit_args_str))
|
|
|
|
|
2018-04-18 17:08:49 +00:00
|
|
|
# Load LLDB test format.
|
2019-10-09 19:22:02 +00:00
|
|
|
sys.path.append(os.path.join(config.lldb_src_root, "test", "API"))
|
2018-04-18 17:08:49 +00:00
|
|
|
import lldbtest
|
|
|
|
|
|
|
|
# testFormat: The test format to use to interpret tests.
|
|
|
|
config.test_format = lldbtest.LLDBTest(dotest_cmd)
|
2020-10-23 18:08:56 +02:00
|
|
|
|
2022-03-21 19:18:29 -07:00
|
|
|
# Propagate TERM or default to vt100.
|
|
|
|
config.environment["TERM"] = os.getenv("TERM", default="vt100")
|
|
|
|
|
2020-11-04 10:16:30 +01:00
|
|
|
# Propagate FREEBSD_LEGACY_PLUGIN
|
|
|
|
if "FREEBSD_LEGACY_PLUGIN" in os.environ:
|
|
|
|
config.environment["FREEBSD_LEGACY_PLUGIN"] = os.environ["FREEBSD_LEGACY_PLUGIN"]
|
2021-03-09 09:49:33 -08:00
|
|
|
|
|
|
|
# Propagate XDG_CACHE_HOME
|
|
|
|
if "XDG_CACHE_HOME" in os.environ:
|
|
|
|
config.environment["XDG_CACHE_HOME"] = os.environ["XDG_CACHE_HOME"]
|