brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.9 KiB · c719ac3 Raw
238 lines · plain
1add_custom_target(lldb-api-test-deps)2set_target_properties(lldb-api-test-deps PROPERTIES FOLDER "LLDB/Tests")3add_dependencies(lldb-api-test-deps lldb-test-depends)4 5add_lit_testsuites(LLDB-API6  ${CMAKE_CURRENT_SOURCE_DIR}7  DEPENDS lldb-api-test-deps)8 9function(add_python_test_target name test_script args comment)10  set(PYTHON_TEST_COMMAND11    ${Python3_EXECUTABLE}12    ${test_script}13    ${args}14    )15 16  add_custom_target(${name}17    COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS}18    COMMENT "${comment}"19    USES_TERMINAL20    )21  add_dependencies(${name} lldb-test-depends)22endfunction()23 24# The default architecture with which to compile test executables is the25# default LLVM target architecture, which itself defaults to the host26# architecture.27if(NOT LLDB_DEFAULT_TEST_ARCH)28  string(REGEX MATCH "^[^-]*" LLDB_DEFAULT_TEST_ARCH ${LLVM_HOST_TRIPLE})29endif ()30 31# Allow the user to override the default by setting LLDB_TEST_ARCH32set(LLDB_TEST_ARCH33  ${LLDB_DEFAULT_TEST_ARCH}34  CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64).  Determines whether tests are compiled with -m32 or -m64")35 36# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script37set(LLDB_TEST_USER_ARGS38  ""39  CACHE STRING "Specify additional arguments to pass to test runner. Separate \40items with \";\". For example: '-C;gcc;-C;clang;-A;i386;-A;x86_64'")41 42set(LLDB_TEST_COMMON_ARGS_VAR43  -u CXXFLAGS44  -u CFLAGS45  )46 47# Set the path to the default lldb test executable.48set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}")49 50set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")51 52if(LLDB_TEST_MAKE)53  set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})54else()55  # Prefer gmake as it will be a version of GNU make. 'make' could be GNU compatible or not.56  set(MAKE_NAMES "gmake" "make")57  find_program(LLDB_DEFAULT_TEST_MAKE NAMES ${MAKE_NAMES})58  if(LLDB_DEFAULT_TEST_MAKE)59    message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")60    execute_process(COMMAND ${LLDB_DEFAULT_TEST_MAKE} --version OUTPUT_VARIABLE MAKE_VERSION61           ERROR_QUIET)62    if(NOT MAKE_VERSION MATCHES "^GNU Make")63      message(WARNING "'make' tool ${LLDB_DEFAULT_TEST_MAKE} may not be GNU make compatible. "64             "Some tests may fail to build. Provide a GNU compatible 'make' tool by setting "65             "LLDB_TEST_MAKE.")66    endif()67  else()68    list(JOIN "${MAKE_NAMES}" " " MAKE_NAMES_SPACES)69    string(REPLACE ";" " " MAKE_NAMES_SPACES "${MAKE_NAMES}")70    message(STATUS "Did not find one of: ${MAKE_NAMES_SPACES}")71    message(WARNING72          "Many LLDB API tests require a 'make' tool. Please provide it in Path "73          "or pass via LLDB_TEST_MAKE.")74  endif()75endif()76 77find_program(LLDB_DIRNAME_PATH dirname)78if(LLDB_DIRNAME_PATH)79  message(STATUS "Found dirname: ${LLDB_DIRNAME_PATH}")80else()81  message(STATUS "Could NOT find 'dirname'")82  message(WARNING83        "Many LLDB API tests require the GNU coreutils tools. Please make "84        "sure they are installed and in PATH.")85endif()86 87if (TARGET clang)88  set(LLDB_DEFAULT_TEST_COMPILER "${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")89else()90  set(LLDB_DEFAULT_TEST_COMPILER "")91endif()92 93set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb executable used for testing")94set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors")95set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles")96set(LLDB_TEST_MAKE "${LLDB_DEFAULT_TEST_MAKE}" CACHE PATH "make tool used for building test executables")97 98if ("${LLDB_TEST_COMPILER}" STREQUAL "")99  message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")100endif()101 102if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )103  set(LLDB_TEST_DEBUG_TEST_CRASHES104    0105    CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes")106 107  set(LLDB_TEST_HIDE_CONSOLE_WINDOWS108    1109    CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite")110 111  if (LLDB_TEST_DEBUG_TEST_CRASHES)112    set(LLDB_TEST_COMMON_ARGS_VAR ${LLDB_TEST_COMMON_ARGS_VAR} --enable-crash-dialog)113  endif()114 115  if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS)116    set(LLDB_TEST_COMMON_ARGS_VAR ${LLDB_TEST_COMMON_ARGS_VAR} --show-inferior-console)117  endif()118endif()119 120if (NOT "${LLDB_LIT_TOOLS_DIR}" STREQUAL "")121  if (NOT EXISTS "${LLDB_LIT_TOOLS_DIR}")122    message(WARNING "LLDB_LIT_TOOLS_DIR ${LLDB_LIT_TOOLS_DIR} does not exist.")123  endif()124endif()125 126if(CMAKE_HOST_APPLE)127  if(LLDB_BUILD_FRAMEWORK)128    set(LLDB_FRAMEWORK_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)129  endif()130 131  if(LLDB_USE_SYSTEM_DEBUGSERVER)132    lldb_find_system_debugserver(system_debugserver_path)133    if(LLDB_BUILD_FRAMEWORK)134      add_custom_target(debugserver135        COMMAND ${CMAKE_COMMAND} -E copy_if_different136        ${system_debugserver_path} $<TARGET_FILE_DIR:liblldb>/Resources137        COMMENT "Copying the system debugserver to LLDB.framework's resource directory for testing.")138    else()139      add_custom_target(debugserver140        COMMAND ${CMAKE_COMMAND} -E copy_if_different141        ${system_debugserver_path} ${LLVM_RUNTIME_OUTPUT_INTDIR}142        COMMENT "Copying the system debugserver to LLDB's binaries directory for testing.")143    endif()144    message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}")145    list(APPEND LLDB_TEST_COMMON_ARGS_VAR --out-of-tree-debugserver)146    add_lldb_test_dependency(debugserver)147  else()148    message(STATUS "LLDB tests use just-built debug server")149  endif()150endif()151 152if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL Debug)153  if(${CMAKE_VERSION} VERSION_LESS "3.30")154    message(WARNING "CMake version is inferior to 3.30. Some lldb tests will fail.")155    set(LLDB_PYTHON_API_TEST_EXECUTABLE "${Python3_EXECUTABLE}")156  else()157    set(LLDB_PYTHON_API_TEST_EXECUTABLE "${Python3_EXECUTABLE_DEBUG}")158  endif()159else()160  set(LLDB_PYTHON_API_TEST_EXECUTABLE "${Python3_EXECUTABLE}")161endif()162 163set(dotest_args_replacement ${LLVM_BUILD_MODE})164 165if(LLDB_BUILT_STANDALONE)166  # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.167  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})168  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMMON_ARGS_VAR "${LLDB_TEST_COMMON_ARGS_VAR}")169  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_USER_ARGS "${LLDB_TEST_USER_ARGS}")170  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")171  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_FRAMEWORK_DIR "${LLDB_FRAMEWORK_DIR}")172  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")173  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")174  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")175  string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")176 177  # Remaining ones must be paths to the provided LLVM build-tree.178  if(LLVM_CONFIGURATION_TYPES)179    # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types.180    # Otherwise, if both use multi-config the default is fine.181    if(NOT CMAKE_CONFIGURATION_TYPES)182      if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES)183        set(dotest_args_replacement RelWithDebInfo)184      elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES)185        set(dotest_args_replacement Release)186      else()187        list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement)188      endif()189    endif()190  else()191    # Common case: LLVM used a single-configuration generator like Ninja.192    set(dotest_args_replacement ".")193  endif()194endif()195 196string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMMON_ARGS_VAR "${LLDB_TEST_COMMON_ARGS_VAR}")197string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_USER_ARGS "${LLDB_TEST_USER_ARGS}")198string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")199string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")200string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")201string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")202string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")203 204set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS_VAR} CACHE INTERNAL STRING)205 206configure_lit_site_cfg(207  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in208  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py209  MAIN_CONFIG210  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)211 212# Targets for running the test suite on the different Apple simulators.213add_lit_testsuite(check-lldb-simulator-ios214  "Running lldb test suite on the iOS simulator"215  ${CMAKE_CURRENT_BINARY_DIR}216  PARAMS "lldb-run-with-simulator=ios"217  EXCLUDE_FROM_CHECK_ALL218  DEPENDS lldb-api-test-deps)219 220add_lit_testsuite(check-lldb-simulator-watchos221  "Running lldb test suite on the watchOS simulator"222  ${CMAKE_CURRENT_BINARY_DIR}223  PARAMS "lldb-run-with-simulator=watchos"224  EXCLUDE_FROM_CHECK_ALL225  DEPENDS lldb-api-test-deps)226 227add_lit_testsuite(check-lldb-simulator-tvos228  "Running lldb test suite on the tvOS simulator"229  ${CMAKE_CURRENT_BINARY_DIR}230  PARAMS "lldb-run-with-simulator=tvos"231  EXCLUDE_FROM_CHECK_ALL232  DEPENDS lldb-api-test-deps)233 234add_lit_testsuite(check-lldb-api "Running lldb api test suite"235  ${CMAKE_CURRENT_BINARY_DIR}236  EXCLUDE_FROM_CHECK_ALL237  DEPENDS lldb-api-test-deps)238