Skip to content

Commit 98d9f2d

Browse files
committed
[lldb/test] Reduce API test tools configuration boilerplate
Replace the dotest command line options and various cmake variables, which are used for passing the locations of llvm tools to the API tests with a single variable, which points to the directory these tools are placed in. Besides reducing repetition, this also makes things more similar to how "normal" llvm tests are configured. Differential Revision: https://reviews.llvm.org/D95261
1 parent 6c097f7 commit 98d9f2d

File tree

7 files changed

+15
-47
lines changed

7 files changed

+15
-47
lines changed

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import os
3030
import platform
3131
import re
32+
import shutil
3233
import signal
3334
import subprocess
3435
import sys
@@ -272,21 +273,13 @@ def parseOptionsAndInitTestdirs():
272273
elif platform_system == 'Darwin':
273274
configuration.dsymutil = seven.get_command_output(
274275
'xcrun -find -toolchain default dsymutil')
275-
276-
277-
# The lldb-dotest script produced by the CMake build passes in a path to a
278-
# working FileCheck and yaml2obj binary. So does one specific Xcode
279-
# project target. However, when invoking dotest.py directly, a valid
280-
# --filecheck and --yaml2obj option needs to be given.
281-
if args.filecheck:
282-
configuration.filecheck = os.path.abspath(args.filecheck)
283-
284-
if args.yaml2obj:
285-
configuration.yaml2obj = os.path.abspath(args.yaml2obj)
276+
if args.llvm_tools_dir:
277+
configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir)
278+
configuration.yaml2obj = shutil.which("yaml2obj", path=args.llvm_tools_dir)
286279

287280
if not configuration.get_filecheck_path():
288281
logging.warning('No valid FileCheck executable; some tests may fail...')
289-
logging.warning('(Double-check the --filecheck argument to dotest.py)')
282+
logging.warning('(Double-check the --llvm-tools-dir argument to dotest.py)')
290283

291284
if args.channels:
292285
lldbtest_config.channels = args.channels

lldb/packages/Python/lldbsuite/test/dotest_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def create_parser():
5151
suggestions: do not lump the "-A arch1 -A arch2" together such that the -E option applies to only one of the architectures'''))
5252

5353
group.add_argument('--dsymutil', metavar='dsymutil', dest='dsymutil', help=textwrap.dedent('Specify which dsymutil to use.'))
54-
group.add_argument('--yaml2obj', metavar='yaml2obj', dest='yaml2obj', help=textwrap.dedent('Specify which yaml2obj binary to use.'))
55-
group.add_argument('--filecheck', metavar='filecheck', dest='filecheck', help=textwrap.dedent('Specify which FileCheck binary to use.'))
54+
group.add_argument('--llvm-tools-dir', metavar='dir', dest='llvm_tools_dir',
55+
help=textwrap.dedent('The location of llvm tools used for testing (yaml2obj, FileCheck, etc.).'))
5656

5757
# Test filtering options
5858
group = parser.add_argument_group('Test filtering options')

lldb/test/API/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ set(LLDB_TEST_COMMON_ARGS
4343
# Set the path to the default lldb test executable.
4444
set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}")
4545

46-
# Set the paths to default llvm tools.
4746
set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
48-
set(LLDB_DEFAULT_TEST_FILECHECK "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/FileCheck${CMAKE_EXECUTABLE_SUFFIX}")
49-
set(LLDB_DEFAULT_TEST_YAML2OBJ "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/yaml2obj${CMAKE_EXECUTABLE_SUFFIX}")
5047

5148
if (TARGET clang)
5249
set(LLDB_DEFAULT_TEST_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
@@ -57,8 +54,6 @@ endif()
5754
set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb executable used for testing")
5855
set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors")
5956
set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles")
60-
set(LLDB_TEST_FILECHECK "${LLDB_DEFAULT_TEST_FILECHECK}" CACHE PATH "FileCheck used for testing purposes")
61-
set(LLDB_TEST_YAML2OBJ "${LLDB_DEFAULT_TEST_YAML2OBJ}" CACHE PATH "yaml2obj used for testing purposes")
6257

6358
if ("${LLDB_TEST_COMPILER}" STREQUAL "")
6459
message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
@@ -141,8 +136,6 @@ if(LLDB_BUILT_STANDALONE)
141136
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
142137
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
143138
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
144-
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_FILECHECK "${LLDB_TEST_FILECHECK}")
145-
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_YAML2OBJ "${LLDB_TEST_YAML2OBJ}")
146139
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_SERVER "${LLDB_TEST_SERVER}")
147140

148141
# Remaining ones must be paths to the provided LLVM build-tree.
@@ -170,8 +163,6 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_BUILD_DI
170163
string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
171164
string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
172165
string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
173-
string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_FILECHECK "${LLDB_TEST_FILECHECK}")
174-
string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_YAML2OBJ "${LLDB_TEST_YAML2OBJ}")
175166
string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_SERVER "${LLDB_TEST_SERVER}")
176167

177168
# Configure the API test suite.

lldb/test/API/lit.cfg.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,8 @@ def delete_module_cache(path):
208208
if is_configured('dsymutil'):
209209
dotest_cmd += ['--dsymutil', config.dsymutil]
210210

211-
if is_configured('filecheck'):
212-
dotest_cmd += ['--filecheck', config.filecheck]
213-
214-
if is_configured('yaml2obj'):
215-
dotest_cmd += ['--yaml2obj', config.yaml2obj]
211+
if is_configured('llvm_tools_dir'):
212+
dotest_cmd += ['--llvm-tools-dir', config.llvm_tools_dir]
216213

217214
if is_configured('server'):
218215
dotest_cmd += ['--server', config.server]

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ config.lldb_executable = '@LLDB_TEST_EXECUTABLE@'
2929
config.test_arch = '@LLDB_TEST_ARCH@'
3030
config.test_compiler = '@LLDB_TEST_COMPILER@'
3131
config.dsymutil = '@LLDB_TEST_DSYMUTIL@'
32-
config.filecheck = '@LLDB_TEST_FILECHECK@'
33-
config.yaml2obj = '@LLDB_TEST_YAML2OBJ@'
3432
config.server = '@LLDB_TEST_SERVER@'
3533
# The API tests use their own module caches.
3634
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
@@ -57,9 +55,6 @@ try:
5755
config.lldb_executable = config.lldb_executable % lit_config.params
5856
config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params
5957
config.test_compiler = config.test_compiler % lit_config.params
60-
config.dsymutil = config.dsymutil % lit_config.params
61-
config.filecheck = config.filecheck % lit_config.params
62-
config.yaml2obj = config.yaml2obj % lit_config.params
6358
config.server = config.server % lit_config.params
6459
config.lldb_framework_dir = config.lldb_framework_dir % lit_config.params
6560
config.dotest_args_str = config.dotest_args_str % lit_config.params

lldb/utils/lldb-dotest/CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ if(LLDB_BUILT_STANDALONE)
2626
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
2727
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
2828
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
29-
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_FILECHECK_CONFIGURED "${LLDB_TEST_FILECHECK}")
30-
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_YAML2OBJ_CONFIGURED "${LLDB_TEST_YAML2OBJ}")
3129
string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
3230

3331
# Remaining ones must be paths to the provided LLVM build-tree.
@@ -40,10 +38,9 @@ if(LLDB_BUILT_STANDALONE)
4038
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
4139
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
4240
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
43-
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_FILECHECK_CONFIGURED "${LLDB_TEST_FILECHECK}")
44-
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_YAML2OBJ_CONFIGURED "${LLDB_TEST_YAML2OBJ}")
4541
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
4642
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
43+
string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
4744
else()
4845
# Single-configuration generator like Ninja.
4946
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_DOTEST_ARGS_CONFIGURED "${LLDB_DOTEST_ARGS}")
@@ -53,10 +50,9 @@ if(LLDB_BUILT_STANDALONE)
5350
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
5451
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
5552
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
56-
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_FILECHECK_CONFIGURED "${LLDB_TEST_FILECHECK}")
57-
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_YAML2OBJ_CONFIGURED "${LLDB_TEST_YAML2OBJ}")
5853
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
5954
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
55+
string(REPLACE ${CMAKE_CFG_INTDIR} "." LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
6056
endif()
6157

6258
configure_file(
@@ -74,10 +70,9 @@ elseif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
7470
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
7571
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
7672
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
77-
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_FILECHECK_CONFIGURED "${LLDB_TEST_FILECHECK}")
78-
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_YAML2OBJ_CONFIGURED "${LLDB_TEST_YAML2OBJ}")
7973
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
8074
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
75+
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
8176

8277
configure_file(
8378
lldb-dotest.in
@@ -92,10 +87,9 @@ else()
9287
set(LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
9388
set(LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
9489
set(LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
95-
set(LLDB_TEST_FILECHECK_CONFIGURED "${LLDB_TEST_FILECHECK}")
96-
set(LLDB_TEST_YAML2OBJ_CONFIGURED "${LLDB_TEST_YAML2OBJ}")
9790
set(LLDB_TEST_SERVER_CONFIGURED "${LLDB_TEST_SERVER}")
9891
set(LLDB_LIBS_DIR_CONFIGURED "${LLDB_LIBS_DIR}")
92+
set(LLVM_TOOLS_DIR_CONFIGURED "${LLVM_TOOLS_BINARY_DIR}")
9993

10094
configure_file(
10195
lldb-dotest.in

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ arch = '@LLDB_TEST_ARCH@'
88
executable = '@LLDB_TEST_EXECUTABLE_CONFIGURED@'
99
compiler = '@LLDB_TEST_COMPILER_CONFIGURED@'
1010
dsymutil = '@LLDB_TEST_DSYMUTIL_CONFIGURED@'
11-
filecheck = '@LLDB_TEST_FILECHECK_CONFIGURED@'
12-
yaml2obj = '@LLDB_TEST_YAML2OBJ_CONFIGURED@'
1311
server = '@LLDB_TEST_SERVER_CONFIGURED@'
1412
lldb_build_dir = '@LLDB_TEST_BUILD_DIRECTORY_CONFIGURED@'
1513
lldb_build_intel_pt = "@LLDB_BUILD_INTEL_PT@"
1614
lldb_framework_dir = "@LLDB_FRAMEWORK_DIR_CONFIGURED@"
1715
lldb_libs_dir = "@LLDB_LIBS_DIR_CONFIGURED@"
16+
llvm_tools_dir = "@LLVM_TOOLS_DIR_CONFIGURED@"
1817

1918
if __name__ == '__main__':
2019
wrapper_args = sys.argv[1:]
@@ -27,9 +26,8 @@ if __name__ == '__main__':
2726
cmd.extend(['--executable', executable])
2827
cmd.extend(['--compiler', compiler])
2928
cmd.extend(['--dsymutil', dsymutil])
30-
cmd.extend(['--yaml2obj', yaml2obj])
31-
cmd.extend(['--filecheck', filecheck])
3229
cmd.extend(['--lldb-libs-dir', lldb_libs_dir])
30+
cmd.extend(['--llvm-tools-dir', llvm_tools_dir])
3331
if server:
3432
cmd.extend(['--server', server])
3533
if lldb_framework_dir:

0 commit comments

Comments
 (0)