1 add_custom_target(lldb-api-test-deps)
2 add_dependencies(lldb-api-test-deps lldb-test-depends)
4 add_lit_testsuites(LLDB-API
5 ${CMAKE_CURRENT_SOURCE_DIR}
6 DEPENDS lldb-api-test-deps)
8 function(add_python_test_target name test_script args comment)
9 set(PYTHON_TEST_COMMAND
15 add_custom_target(${name}
16 COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS}
20 add_dependencies(${name} lldb-test-depends)
23 # The default architecture with which to compile test executables is the
24 # default LLVM target architecture, which itself defaults to the host
26 if(NOT LLDB_DEFAULT_TEST_ARCH)
27 string(REGEX MATCH "^[^-]*" LLDB_DEFAULT_TEST_ARCH ${LLVM_HOST_TRIPLE})
30 # Allow the user to override the default by setting LLDB_TEST_ARCH
32 ${LLDB_DEFAULT_TEST_ARCH}
33 CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64). Determines whether tests are compiled with -m32 or -m64")
35 # Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script
36 set(LLDB_TEST_USER_ARGS
38 CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'")
40 set(LLDB_TEST_COMMON_ARGS_VAR
45 # Set the path to the default lldb test executable.
46 set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}")
48 set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
51 set(LLDB_DEFAULT_TEST_COMPILER "${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
53 set(LLDB_DEFAULT_TEST_COMPILER "")
56 set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb executable used for testing")
57 set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors")
58 set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles")
60 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
61 message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
64 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
65 set(LLDB_TEST_DEBUG_TEST_CRASHES
67 CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes")
69 set(LLDB_TEST_HIDE_CONSOLE_WINDOWS
71 CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite")
73 if (LLDB_TEST_DEBUG_TEST_CRASHES)
74 set(LLDB_TEST_COMMON_ARGS_VAR ${LLDB_TEST_COMMON_ARGS_VAR} --enable-crash-dialog)
77 if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS)
78 set(LLDB_TEST_COMMON_ARGS_VAR ${LLDB_TEST_COMMON_ARGS_VAR} --show-inferior-console)
82 if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
83 list(APPEND LLDB_TEST_COMMON_ARGS_VAR
84 --env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY})
86 list(APPEND LLDB_TEST_COMMON_ARGS_VAR
87 --env OBJCOPY=${LLVM_TOOLS_BINARY_DIR}/llvm-objcopy${CMAKE_EXECUTABLE_SUFFIX})
90 if (NOT "${LLDB_LIT_TOOLS_DIR}" STREQUAL "")
91 if (NOT EXISTS "${LLDB_LIT_TOOLS_DIR}")
92 message(WARNING "LLDB_LIT_TOOLS_DIR ${LLDB_LIT_TOOLS_DIR} does not exist.")
97 if(LLDB_BUILD_FRAMEWORK)
98 set(LLDB_FRAMEWORK_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
101 # Use the same identity for testing
102 get_property(code_sign_identity_used GLOBAL PROPERTY LLDB_DEBUGSERVER_CODESIGN_IDENTITY)
103 if(code_sign_identity_used)
104 list(APPEND LLDB_TEST_COMMON_ARGS_VAR --codesign-identity "${code_sign_identity_used}")
107 if(LLDB_USE_SYSTEM_DEBUGSERVER)
108 lldb_find_system_debugserver(system_debugserver_path)
109 if(LLDB_BUILD_FRAMEWORK)
110 add_custom_target(debugserver
111 COMMAND ${CMAKE_COMMAND} -E copy_if_different
112 ${system_debugserver_path} $<TARGET_FILE_DIR:liblldb>/Resources
113 COMMENT "Copying the system debugserver to LLDB.framework's resource directory for testing.")
115 add_custom_target(debugserver
116 COMMAND ${CMAKE_COMMAND} -E copy_if_different
117 ${system_debugserver_path} ${LLVM_RUNTIME_OUTPUT_INTDIR}
118 COMMENT "Copying the system debugserver to LLDB's binaries directory for testing.")
120 message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}")
121 list(APPEND LLDB_TEST_COMMON_ARGS_VAR --out-of-tree-debugserver)
122 add_lldb_test_dependency(debugserver)
124 message(STATUS "LLDB tests use just-built debug server")
128 set(dotest_args_replacement ${LLVM_BUILD_MODE})
130 if(LLDB_BUILT_STANDALONE)
131 # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.
132 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
133 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMMON_ARGS_VAR "${LLDB_TEST_COMMON_ARGS_VAR}")
134 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_USER_ARGS "${LLDB_TEST_USER_ARGS}")
135 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")
136 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_FRAMEWORK_DIR "${LLDB_FRAMEWORK_DIR}")
137 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
138 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
139 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
140 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
142 # Remaining ones must be paths to the provided LLVM build-tree.
143 if(LLVM_CONFIGURATION_TYPES)
144 # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types.
145 # Otherwise, if both use multi-config the default is fine.
146 if(NOT CMAKE_CONFIGURATION_TYPES)
147 if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES)
148 set(dotest_args_replacement RelWithDebInfo)
149 elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES)
150 set(dotest_args_replacement Release)
152 list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement)
156 # Common case: LLVM used a single-configuration generator like Ninja.
157 set(dotest_args_replacement ".")
161 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMMON_ARGS_VAR "${LLDB_TEST_COMMON_ARGS_VAR}")
162 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_USER_ARGS "${LLDB_TEST_USER_ARGS}")
163 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")
164 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
165 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
166 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
167 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
169 set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS_VAR} CACHE INTERNAL STRING)
171 configure_lit_site_cfg(
172 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
173 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
175 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
177 # Targets for running the test suite on the different Apple simulators.
178 add_lit_testsuite(check-lldb-simulator-ios
179 "Running lldb test suite on the iOS simulator"
180 ${CMAKE_CURRENT_BINARY_DIR}
181 PARAMS "lldb-run-with-simulator=ios"
182 EXCLUDE_FROM_CHECK_ALL
183 DEPENDS lldb-api-test-deps)
185 add_lit_testsuite(check-lldb-simulator-watchos
186 "Running lldb test suite on the watchOS simulator"
187 ${CMAKE_CURRENT_BINARY_DIR}
188 PARAMS "lldb-run-with-simulator=watchos"
189 EXCLUDE_FROM_CHECK_ALL
190 DEPENDS lldb-api-test-deps)
192 add_lit_testsuite(check-lldb-simulator-tvos
193 "Running lldb test suite on the tvOS simulator"
194 ${CMAKE_CURRENT_BINARY_DIR}
195 PARAMS "lldb-run-with-simulator=tvos"
196 EXCLUDE_FROM_CHECK_ALL
197 DEPENDS lldb-api-test-deps)
199 add_lit_testsuite(check-lldb-api "Running lldb api test suite"
200 ${CMAKE_CURRENT_BINARY_DIR}
201 EXCLUDE_FROM_CHECK_ALL
202 DEPENDS lldb-api-test-deps)