Skip to content

Commit 7ce92dc

Browse files
committed
[lldb/Test] Bypass LLDB_TEST_COMMON_ARGS for certain dotest args (NFC)
Rather than serializing every argument through LLDB_TEST_COMMON_ARGS, we can pass some of them directly using their CMake variable. Although this does introduce some code duplication between lit's site config and the lldb-dotest utility, it also means that it becomes easier to override these values (WIP).
1 parent a9052b4 commit 7ce92dc

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

lldb/test/API/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ set(LLDB_TEST_USER_ARGS
3636
# hash of filename and .text section, there *will* be conflicts inside
3737
# the build directory.
3838
set(LLDB_TEST_COMMON_ARGS
39-
--arch=${LLDB_TEST_ARCH}
4039
-s
4140
${CMAKE_BINARY_DIR}/lldb-test-traces
4241
-S nm
@@ -66,13 +65,6 @@ if ("${LLDB_TEST_COMPILER}" STREQUAL "")
6665
message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
6766
endif()
6867

69-
list(APPEND LLDB_TEST_COMMON_ARGS
70-
--executable ${LLDB_TEST_EXECUTABLE}
71-
--compiler ${LLDB_TEST_COMPILER}
72-
--dsymutil ${LLDB_TEST_DSYMUTIL}
73-
--filecheck ${LLDB_TEST_FILECHECK}
74-
)
75-
7668
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
7769
# All tests are currently flaky on Windows, so rerun them all once when they fail.
7870
set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --rerun-all-issues)

lldb/test/API/lit.cfg.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
'libclang_rt.asan_osx_dynamic.dylib')
3434
config.environment['DYLD_INSERT_LIBRARIES'] = runtime
3535

36+
3637
def find_shlibpath_var():
3738
if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
3839
yield 'LD_LIBRARY_PATH'
@@ -41,6 +42,7 @@ def find_shlibpath_var():
4142
elif platform.system() == 'Windows':
4243
yield 'PATH'
4344

45+
4446
# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
4547
if config.shared_libs:
4648
for shlibpath_var in find_shlibpath_var():
@@ -64,7 +66,7 @@ def find_shlibpath_var():
6466
# lit.py invocation is close enough.
6567
for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
6668
if os.path.isdir(cachedir):
67-
print("Deleting module cache at %s."%cachedir)
69+
print("Deleting module cache at %s." % cachedir)
6870
shutil.rmtree(cachedir)
6971

7072
# Set a default per-test timeout of 10 minutes. Setting a timeout per test
@@ -78,14 +80,9 @@ def find_shlibpath_var():
7880

7981
# Build dotest command.
8082
dotest_cmd = [config.dotest_path]
83+
dotest_cmd += ['--arch', config.test_arch]
8184
dotest_cmd.extend(config.dotest_args_str.split(';'))
8285

83-
# We don't want to force users passing arguments to lit to use `;` as a
84-
# separator. We use Python's simple lexical analyzer to turn the args into a
85-
# list.
86-
if config.dotest_lit_args_str:
87-
dotest_cmd.extend(shlex.split(config.dotest_lit_args_str))
88-
8986
# Library path may be needed to locate just-built clang.
9087
if config.llvm_libs_dir:
9188
dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir]
@@ -99,6 +96,26 @@ def find_shlibpath_var():
9996
if config.clang_module_cache:
10097
dotest_cmd += ['--clang-module-cache-dir', config.clang_module_cache]
10198

99+
if config.lldb_executable:
100+
dotest_cmd += ['--executable', config.lldb_executable]
101+
102+
if config.test_compiler:
103+
dotest_cmd += ['--compiler', config.test_compiler]
104+
105+
if config.dsymutil:
106+
dotest_cmd += ['--dsymutil', config.dsymutil]
107+
108+
if config.filecheck:
109+
dotest_cmd += ['--filecheck', config.filecheck]
110+
111+
# We don't want to force users passing arguments to lit to use `;` as a
112+
# separator. We use Python's simple lexical analyzer to turn the args into a
113+
# list. Pass there arguments last so they can override anything that was
114+
# already configured.
115+
if config.dotest_lit_args_str:
116+
dotest_cmd.extend(shlex.split(config.dotest_lit_args_str))
117+
118+
102119
# Load LLDB test format.
103120
sys.path.append(os.path.join(config.lldb_src_root, "test", "API"))
104121
import lldbtest

lldb/test/API/lit.site.cfg.py.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
2222
config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
2323
config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
2424
config.dotest_lit_args_str = None
25+
config.lldb_executable = '@LLDB_TEST_EXECUTABLE@'
26+
config.test_arch = '@LLDB_TEST_ARCH@'
27+
config.test_compiler = '@LLDB_TEST_COMPILER@'
28+
config.dsymutil = '@LLDB_TEST_DSYMUTIL@'
29+
config.filecheck = '@LLDB_TEST_FILECHECK@'
2530
# The API tests use their own module caches.
2631
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
2732
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")

lldb/utils/lldb-dotest/lldb-dotest.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@ import sys
55
dotest_path = '@LLDB_SOURCE_DIR@/test/API/dotest.py'
66
build_dir = '@LLDB_TEST_BUILD_DIRECTORY@'
77
dotest_args_str = '@LLDB_DOTEST_ARGS@'
8+
arch = '@LLDB_TEST_ARCH@'
9+
executable = '@LLDB_TEST_EXECUTABLE@'
10+
compiler = '@LLDB_TEST_COMPILER@'
11+
dsymutil = '@LLDB_TEST_DSYMUTIL@'
12+
filecheck = '@LLDB_TEST_FILECHECK@'
813

914
if __name__ == '__main__':
1015
wrapper_args = sys.argv[1:]
1116
dotest_args = dotest_args_str.split(';')
1217
# Build dotest.py command.
1318
cmd = [sys.executable, dotest_path]
19+
cmd.extend(['--arch', arch])
1420
cmd.extend(dotest_args)
1521
cmd.extend(['--build-dir', build_dir])
22+
cmd.extend(['--executable', executable])
23+
cmd.extend(['--compiler', compiler])
24+
cmd.extend(['--dsymutil', dsymutil])
25+
cmd.extend(['--filecheck', filecheck])
1626
cmd.extend(wrapper_args)
1727
# Invoke dotest.py and return exit code.
1828
print(' '.join(cmd))

0 commit comments

Comments
 (0)