1add_custom_target(lldb-api-test-deps) 2add_dependencies(lldb-api-test-deps lldb-test-deps) 3 4add_lit_testsuites(LLDB-API 5 ${CMAKE_CURRENT_SOURCE_DIR} 6 DEPENDS lldb-api-test-deps) 7 8function(add_python_test_target name test_script args comment) 9 set(PYTHON_TEST_COMMAND 10 ${Python3_EXECUTABLE} 11 ${test_script} 12 ${args} 13 ) 14 15 add_custom_target(${name} 16 COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS} 17 COMMENT "${comment}" 18 USES_TERMINAL 19 ) 20 add_dependencies(${name} lldb-test-deps) 21endfunction() 22 23# The default architecture with which to compile test executables is the 24# default LLVM target architecture, which itself defaults to the host 25# architecture. 26if(NOT LLDB_DEFAULT_TEST_ARCH) 27 string(REGEX MATCH "^[^-]*" LLDB_DEFAULT_TEST_ARCH ${LLVM_HOST_TRIPLE}) 28endif () 29 30# Allow the user to override the default by setting LLDB_TEST_ARCH 31set(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") 34 35# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script 36set(LLDB_TEST_USER_ARGS 37 "" 38 CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'") 39 40# The .noindex suffix is a marker for Spotlight to never index the 41# build directory. LLDB queries Spotlight to locate .dSYM bundles 42# based on the UUID embedded in a binary, and because the UUID is a 43# hash of filename and .text section, there *will* be conflicts inside 44# the build directory. 45set(LLDB_TEST_COMMON_ARGS 46 -u CXXFLAGS 47 -u CFLAGS 48 ) 49 50# Set the path to the default lldb test executable. 51set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}") 52 53set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}") 54 55if (TARGET clang) 56 set(LLDB_DEFAULT_TEST_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}") 57else() 58 set(LLDB_DEFAULT_TEST_COMPILER "") 59endif() 60 61set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb executable used for testing") 62set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors") 63set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles") 64 65if ("${LLDB_TEST_COMPILER}" STREQUAL "") 66 message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.") 67endif() 68 69if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) 70 set(LLDB_TEST_DEBUG_TEST_CRASHES 71 0 72 CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes") 73 74 set(LLDB_TEST_HIDE_CONSOLE_WINDOWS 75 1 76 CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite") 77 78 if (LLDB_TEST_DEBUG_TEST_CRASHES) 79 set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --enable-crash-dialog) 80 endif() 81 82 if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS) 83 set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --show-inferior-console) 84 endif() 85endif() 86 87if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin") 88 list(APPEND LLDB_TEST_COMMON_ARGS 89 --env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY}) 90endif() 91 92if (NOT "${LLDB_LIT_TOOLS_DIR}" STREQUAL "") 93 if (NOT EXISTS "${LLDB_LIT_TOOLS_DIR}") 94 message(WARNING "LLDB_LIT_TOOLS_DIR ${LLDB_LIT_TOOLS_DIR} does not exist.") 95 endif() 96endif() 97 98if(CMAKE_HOST_APPLE) 99 if(LLDB_BUILD_FRAMEWORK) 100 set(LLDB_FRAMEWORK_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework) 101 endif() 102 103 # Use the same identity for testing 104 get_property(code_sign_identity_used GLOBAL PROPERTY LLDB_DEBUGSERVER_CODESIGN_IDENTITY) 105 if(code_sign_identity_used) 106 list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${code_sign_identity_used}") 107 endif() 108 109 if(LLDB_USE_SYSTEM_DEBUGSERVER) 110 lldb_find_system_debugserver(system_debugserver_path) 111 add_custom_target(debugserver 112 COMMAND ${CMAKE_COMMAND} -E copy_if_different 113 ${system_debugserver_path} ${LLVM_RUNTIME_OUTPUT_INTDIR} 114 COMMENT "Copying the system debugserver to LLDB's binaries directory for testing.") 115 message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}") 116 list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver) 117 add_lldb_test_dependency(debugserver) 118 else() 119 message(STATUS "LLDB Tests use just-built debug server") 120 endif() 121endif() 122 123set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS} CACHE INTERNAL STRING) 124set(dotest_args_replacement ${LLVM_BUILD_MODE}) 125 126if(LLDB_BUILT_STANDALONE) 127 # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder. 128 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}) 129 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") 130 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}") 131 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_FRAMEWORK_DIR "${LLDB_FRAMEWORK_DIR}") 132 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}") 133 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}") 134 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}") 135 string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}") 136 137 # Remaining ones must be paths to the provided LLVM build-tree. 138 if(LLVM_CONFIGURATION_TYPES) 139 # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types. 140 # Otherwise, if both use multi-config the default is fine. 141 if(NOT CMAKE_CONFIGURATION_TYPES) 142 if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES) 143 set(dotest_args_replacement RelWithDebInfo) 144 elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES) 145 set(dotest_args_replacement Release) 146 else() 147 list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement) 148 endif() 149 endif() 150 else() 151 # Common case: LLVM used a single-configuration generator like Ninja. 152 set(dotest_args_replacement ".") 153 endif() 154endif() 155 156string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") 157string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}") 158string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}") 159string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}") 160string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}") 161string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}") 162 163configure_lit_site_cfg( 164 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in 165 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py 166 MAIN_CONFIG 167 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) 168 169# Targets for running the test suite on the different Apple simulators. 170add_lit_testsuite(check-lldb-simulator-ios 171 "Running lldb test suite on the iOS simulator" 172 ${CMAKE_CURRENT_BINARY_DIR} 173 PARAMS "lldb-run-with-simulator=ios" 174 EXCLUDE_FROM_CHECK_ALL 175 DEPENDS lldb-api-test-deps) 176 177add_lit_testsuite(check-lldb-simulator-watchos 178 "Running lldb test suite on the watchOS simulator" 179 ${CMAKE_CURRENT_BINARY_DIR} 180 PARAMS "lldb-run-with-simulator=watchos" 181 EXCLUDE_FROM_CHECK_ALL 182 DEPENDS lldb-api-test-deps) 183 184add_lit_testsuite(check-lldb-simulator-tvos 185 "Running lldb test suite on the tvOS simulator" 186 ${CMAKE_CURRENT_BINARY_DIR} 187 PARAMS "lldb-run-with-simulator=tvos" 188 EXCLUDE_FROM_CHECK_ALL 189 DEPENDS lldb-api-test-deps) 190 191add_lit_testsuite(check-lldb-api "Running lldb api test suite" 192 ${CMAKE_CURRENT_BINARY_DIR} 193 EXCLUDE_FROM_CHECK_ALL 194 DEPENDS lldb-api-test-deps) 195