Index: lldb/CMakeLists.txt =================================================================== --- lldb/CMakeLists.txt +++ lldb/CMakeLists.txt @@ -180,7 +180,6 @@ add_subdirectory(test) add_subdirectory(unittests) - add_subdirectory(lit) add_subdirectory(utils/lit-cpuid) add_subdirectory(utils/lldb-dotest) endif() Index: lldb/lit/CMakeLists.txt =================================================================== --- lldb/lit/CMakeLists.txt +++ /dev/null @@ -1,119 +0,0 @@ -# Test runner infrastructure for LLDB. This configures the LLDB test trees -# for use by Lit, and delegates to LLVM's lit test handlers. - -# LLVM_BUILD_MODE is used in lit.site.cfg -if (CMAKE_CFG_INTDIR STREQUAL ".") - set(LLVM_BUILD_MODE ".") -else () - set(LLVM_BUILD_MODE "%(build_mode)s") -endif () - -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(LLDB_IS_64_BITS 1) -endif() - -get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY) -set(dotest_args_replacement ${LLVM_BUILD_MODE}) - -set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.") -set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.") - -if(LLDB_BUILT_STANDALONE) - # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder. - string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}) - string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") - - # Remaining ones must be paths to the provided LLVM build-tree. - if(LLVM_CONFIGURATION_TYPES) - # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types. - # Otherwise, if both use multi-config the default is fine. - if(NOT CMAKE_CONFIGURATION_TYPES) - if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES) - set(dotest_args_replacement RelWithDebInfo) - elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES) - set(dotest_args_replacement Release) - else() - list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement) - endif() - endif() - else() - # Common case: LLVM used a single-configuration generator like Ninja. - set(dotest_args_replacement ".") - endif() -endif() - -string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) -string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - -list(APPEND LLDB_TEST_DEPS - LLDBUnitTests - dsymutil - lit-cpuid - llc - lldb - lldb-test - lli - llvm-config - llvm-dwarfdump - llvm-nm - llvm-mc - llvm-objcopy - llvm-readobj - llvm-strip - ) - -if(TARGET lld) - list(APPEND LLDB_TEST_DEPS lld) -endif() - -# the value is not canonicalized within LLVM -llvm_canonicalize_cmake_booleans( - LLDB_DISABLE_PYTHON - LLVM_ENABLE_ZLIB - LLVM_ENABLE_SHARED_LIBS - LLDB_IS_64_BITS) - -configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py - MAIN_CONFIG - ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) -configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py - MAIN_CONFIG - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py) -configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/lit-lldb-init.in - ${CMAKE_CURRENT_BINARY_DIR}/lit-lldb-init) - -if(NOT LLDB_BUILT_STANDALONE) - list(APPEND LLDB_TEST_DEPS - FileCheck - count - not - ) -endif() - -add_lit_testsuite(check-lldb-lit "Running lldb lit test suite" - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${LLDB_TEST_DEPS} - ) - -set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests") - -# If we're building with an in-tree clang, then list clang as a dependency -# to run tests. -if (TARGET clang) - add_dependencies(check-lldb-lit clang) -endif() - -add_lit_testsuites(LLDB - ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${LLDB_TEST_DEPS} - ) Index: lldb/test/API/CMakeLists.txt =================================================================== --- /dev/null +++ lldb/test/API/CMakeLists.txt @@ -0,0 +1,157 @@ +function(add_python_test_target name test_script args comment) + set(PYTHON_TEST_COMMAND + ${PYTHON_EXECUTABLE} + ${test_script} + ${args} + ) + + add_custom_target(${name} + COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS} + COMMENT "${comment}" + USES_TERMINAL + ) + add_dependencies(${name} ${LLDB_TEST_DEPS}) +endfunction() + +# The default architecture with which to compile test executables is the default LLVM target +# architecture, which itself defaults to the host architecture. +string(TOLOWER "${LLVM_TARGET_ARCH}" LLDB_DEFAULT_TEST_ARCH) +if( LLDB_DEFAULT_TEST_ARCH STREQUAL "host" ) + string(REGEX MATCH "^[^-]*" LLDB_DEFAULT_TEST_ARCH ${LLVM_HOST_TRIPLE}) +endif () + +# Allow the user to override the default by setting LLDB_TEST_ARCH +set(LLDB_TEST_ARCH + ${LLDB_DEFAULT_TEST_ARCH} + CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64). Determines whether tests are compiled with -m32 or -m64") + +# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script +set(LLDB_TEST_USER_ARGS + "" + CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'") + +# The .noindex suffix is a marker for Spotlight to never index the +# build directory. LLDB queries Spotlight to locate .dSYM bundles +# based on the UUID embedded in a binary, and because the UUID is a +# hash of filename and .text section, there *will* be conflicts inside +# the build directory. +set(LLDB_TEST_COMMON_ARGS + --arch=${LLDB_TEST_ARCH} + -s + ${CMAKE_BINARY_DIR}/lldb-test-traces + -S nm + -u CXXFLAGS + -u CFLAGS + ) + +list(APPEND LLDB_TEST_COMMON_ARGS + --executable ${LLDB_TEST_EXECUTABLE} + --dsymutil ${LLDB_TEST_DSYMUTIL} + --filecheck ${LLDB_TEST_FILECHECK} + -C ${LLDB_TEST_C_COMPILER} + ) + +if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) + # All tests are currently flaky on Windows, so rerun them all once when they fail. + set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --rerun-all-issues) + + set(LLDB_TEST_DEBUG_TEST_CRASHES + 0 + CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes") + + set(LLDB_TEST_HIDE_CONSOLE_WINDOWS + 1 + CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite") + + if (LLDB_TEST_DEBUG_TEST_CRASHES) + set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --enable-crash-dialog) + endif() + + if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS) + set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --show-inferior-console) + endif() +endif() + +if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin") + list(APPEND LLDB_TEST_COMMON_ARGS + --env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY}) +endif() + +if (NOT "${LLDB_LIT_TOOLS_DIR}" STREQUAL "") + if (NOT EXISTS "${LLDB_LIT_TOOLS_DIR}") + message(WARNING "LLDB_LIT_TOOLS_DIR ${LLDB_LIT_TOOLS_DIR} does not exist.") + endif() +endif() + +if(CMAKE_HOST_APPLE) + if(LLDB_BUILD_FRAMEWORK) + get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY) + list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_build_dir}/LLDB.framework) + endif() + + # Use the same identity for testing + get_property(code_sign_identity_used GLOBAL PROPERTY LLDB_DEBUGSERVER_CODESIGN_IDENTITY) + if(code_sign_identity_used) + list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${code_sign_identity_used}") + endif() + + if(LLDB_USE_SYSTEM_DEBUGSERVER) + lldb_find_system_debugserver(system_debugserver_path) + add_custom_target(debugserver + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${system_debugserver_path} ${LLVM_RUNTIME_OUTPUT_INTDIR} + COMMENT "Copying the system debugserver to LLDB's binaries directory for testing.") + # The custom target for the system debugserver has no install target, so we + # need to remove it from the LLVM_DISTRIBUTION_COMPONENTS list. + if (LLVM_DISTRIBUTION_COMPONENTS) + list(REMOVE_ITEM LLVM_DISTRIBUTION_COMPONENTS debugserver) + set(LLVM_DISTRIBUTION_COMPONENTS ${LLVM_DISTRIBUTION_COMPONENTS} PARENT_SCOPE) + endif() + message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}") + list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver) + add_dependencies(lldb-test-deps debugserver) + elseif(TARGET debugserver) + set(debugserver_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver) + message(STATUS "LLDB Tests use just-built debugserver: ${debugserver_path}") + list(APPEND LLDB_TEST_COMMON_ARGS --server ${debugserver_path}) + add_dependencies(lldb-test-deps debugserver) + elseif(TARGET lldb-server) + set(lldb_server_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-server) + message(STATUS "LLDB Tests use just-built lldb-server: ${lldb_server_path}") + list(APPEND LLDB_TEST_COMMON_ARGS --server ${lldb_server_path}) + add_dependencies(lldb-test-deps lldb-server) + else() + message(WARNING "LLDB Tests enabled, but no server available") + endif() +endif() + +set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}) +set_property(GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY ${LLDB_DOTEST_ARGS}) + +# If tests crash cause LLDB to crash, or things are otherwise unstable, or if machine-parsable +# output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target. +add_custom_target(check-lldb) +add_dependencies(check-lldb lldb-test-deps) +set_target_properties(check-lldb PROPERTIES FOLDER "lldb misc") + +# If we're building with an in-tree clang, then list clang as a dependency +# to run tests. +if (TARGET clang) + add_dependencies(check-lldb clang) +endif() + +# LLD is required to link test executables on Windows. +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + if (TARGET lld) + add_dependencies(check-lldb lld) + else () + message(WARNING "lld required to test LLDB on Windows") + endif () +endif () + +# Run the lit-style tests and the unittests as part of the check-lldb target. +add_dependencies(check-lldb check-lldb-lit) + +# This will add LLDB's test dependencies to the dependencies for check-all and +# include them in the test-depends target. +set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS}) Index: lldb/test/API/README.md =================================================================== --- /dev/null +++ lldb/test/API/README.md @@ -0,0 +1,4 @@ +# LLDB API Tests + +This directory only exists for the lit test driver. The actual tests live in +the `tests` directory in top level LLDB directory. Index: lldb/test/API/lit.cfg =================================================================== --- lldb/test/API/lit.cfg +++ lldb/test/API/lit.cfg @@ -9,7 +9,7 @@ import lit.formats # name: The name of this test suite. -config.name = 'lldb-Suite' +config.name = 'lldb-api' # suffixes: A list of file extensions to treat as test files. config.suffixes = ['.py'] @@ -73,7 +73,7 @@ dotest_cmd += ['--module-cache-dir', config.lldb_module_cache] # Load LLDB test format. -sys.path.append(os.path.join(config.lldb_src_root, "lit", "Suite")) +sys.path.append(os.path.join(config.lldb_src_root, "test", "API")) import lldbtest # testFormat: The test format to use to interpret tests. Index: lldb/test/API/lit.site.cfg.in =================================================================== --- lldb/test/API/lit.site.cfg.in +++ lldb/test/API/lit.site.cfg.in @@ -20,7 +20,7 @@ config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@" config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@" config.python_executable = "@PYTHON_EXECUTABLE@" -config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py" +config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py" config.dotest_args_str = "@LLDB_DOTEST_ARGS@" config.lldb_disable_python = @LLDB_DISABLE_PYTHON@ config.dotest_lit_args_str = None @@ -43,4 +43,4 @@ lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) # Let the main config do the real work. -lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Suite/lit.cfg") +lit_config.load_config(config, "@LLDB_SOURCE_DIR@/test/API/lit.cfg") Index: lldb/test/CMakeLists.txt =================================================================== --- lldb/test/CMakeLists.txt +++ lldb/test/CMakeLists.txt @@ -1,157 +1,121 @@ -function(add_python_test_target name test_script args comment) - set(PYTHON_TEST_COMMAND - ${PYTHON_EXECUTABLE} - ${test_script} - ${args} - ) +# Test runner infrastructure for LLDB. This configures the LLDB test trees +# for use by Lit, and delegates to LLVM's lit test handlers. - add_custom_target(${name} - COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS} - COMMENT "${comment}" - USES_TERMINAL - ) - add_dependencies(${name} ${LLDB_TEST_DEPS}) -endfunction() +add_subdirectory(API) -# The default architecture with which to compile test executables is the default LLVM target -# architecture, which itself defaults to the host architecture. -string(TOLOWER "${LLVM_TARGET_ARCH}" LLDB_DEFAULT_TEST_ARCH) -if( LLDB_DEFAULT_TEST_ARCH STREQUAL "host" ) - string(REGEX MATCH "^[^-]*" LLDB_DEFAULT_TEST_ARCH ${LLVM_HOST_TRIPLE}) +# LLVM_BUILD_MODE is used in lit.site.cfg +if (CMAKE_CFG_INTDIR STREQUAL ".") + set(LLVM_BUILD_MODE ".") +else () + set(LLVM_BUILD_MODE "%(build_mode)s") endif () -# Allow the user to override the default by setting LLDB_TEST_ARCH -set(LLDB_TEST_ARCH - ${LLDB_DEFAULT_TEST_ARCH} - CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64). Determines whether tests are compiled with -m32 or -m64") - -# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script -set(LLDB_TEST_USER_ARGS - "" - CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'") - -# The .noindex suffix is a marker for Spotlight to never index the -# build directory. LLDB queries Spotlight to locate .dSYM bundles -# based on the UUID embedded in a binary, and because the UUID is a -# hash of filename and .text section, there *will* be conflicts inside -# the build directory. -set(LLDB_TEST_COMMON_ARGS - --arch=${LLDB_TEST_ARCH} - -s - ${CMAKE_BINARY_DIR}/lldb-test-traces - -S nm - -u CXXFLAGS - -u CFLAGS - ) - -list(APPEND LLDB_TEST_COMMON_ARGS - --executable ${LLDB_TEST_EXECUTABLE} - --dsymutil ${LLDB_TEST_DSYMUTIL} - --filecheck ${LLDB_TEST_FILECHECK} - -C ${LLDB_TEST_C_COMPILER} - ) - -if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) - # All tests are currently flaky on Windows, so rerun them all once when they fail. - set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --rerun-all-issues) - - set(LLDB_TEST_DEBUG_TEST_CRASHES - 0 - CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes") - - set(LLDB_TEST_HIDE_CONSOLE_WINDOWS - 1 - CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite") - - if (LLDB_TEST_DEBUG_TEST_CRASHES) - set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --enable-crash-dialog) - endif() - - if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS) - set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --show-inferior-console) - endif() -endif() - -if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin") - list(APPEND LLDB_TEST_COMMON_ARGS - --env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY}) +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(LLDB_IS_64_BITS 1) endif() -if (NOT "${LLDB_LIT_TOOLS_DIR}" STREQUAL "") - if (NOT EXISTS "${LLDB_LIT_TOOLS_DIR}") - message(WARNING "LLDB_LIT_TOOLS_DIR ${LLDB_LIT_TOOLS_DIR} does not exist.") - endif() -endif() - -if(CMAKE_HOST_APPLE) - if(LLDB_BUILD_FRAMEWORK) - get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY) - list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_build_dir}/LLDB.framework) - endif() - - # Use the same identity for testing - get_property(code_sign_identity_used GLOBAL PROPERTY LLDB_DEBUGSERVER_CODESIGN_IDENTITY) - if(code_sign_identity_used) - list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${code_sign_identity_used}") - endif() - - if(LLDB_USE_SYSTEM_DEBUGSERVER) - lldb_find_system_debugserver(system_debugserver_path) - add_custom_target(debugserver - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${system_debugserver_path} ${LLVM_RUNTIME_OUTPUT_INTDIR} - COMMENT "Copying the system debugserver to LLDB's binaries directory for testing.") - # The custom target for the system debugserver has no install target, so we - # need to remove it from the LLVM_DISTRIBUTION_COMPONENTS list. - if (LLVM_DISTRIBUTION_COMPONENTS) - list(REMOVE_ITEM LLVM_DISTRIBUTION_COMPONENTS debugserver) - set(LLVM_DISTRIBUTION_COMPONENTS ${LLVM_DISTRIBUTION_COMPONENTS} PARENT_SCOPE) +get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY) +set(dotest_args_replacement ${LLVM_BUILD_MODE}) + +set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.") +set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.") + +if(LLDB_BUILT_STANDALONE) + # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder. + string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}) + string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") + + # Remaining ones must be paths to the provided LLVM build-tree. + if(LLVM_CONFIGURATION_TYPES) + # LLDB uses single-config; LLVM multi-config; pick one and prefer Release types. + # Otherwise, if both use multi-config the default is fine. + if(NOT CMAKE_CONFIGURATION_TYPES) + if(RelWithDebInfo IN_LIST LLVM_CONFIGURATION_TYPES) + set(dotest_args_replacement RelWithDebInfo) + elseif(Release IN_LIST LLVM_CONFIGURATION_TYPES) + set(dotest_args_replacement Release) + else() + list(GET LLVM_CONFIGURATION_TYPES 0 dotest_args_replacement) + endif() endif() - message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}") - list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver) - add_dependencies(lldb-test-deps debugserver) - elseif(TARGET debugserver) - set(debugserver_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver) - message(STATUS "LLDB Tests use just-built debugserver: ${debugserver_path}") - list(APPEND LLDB_TEST_COMMON_ARGS --server ${debugserver_path}) - add_dependencies(lldb-test-deps debugserver) - elseif(TARGET lldb-server) - set(lldb_server_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-server) - message(STATUS "LLDB Tests use just-built lldb-server: ${lldb_server_path}") - list(APPEND LLDB_TEST_COMMON_ARGS --server ${lldb_server_path}) - add_dependencies(lldb-test-deps lldb-server) else() - message(WARNING "LLDB Tests enabled, but no server available") + # Common case: LLVM used a single-configuration generator like Ninja. + set(dotest_args_replacement ".") endif() endif() -set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}) -set_property(GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY ${LLDB_DOTEST_ARGS}) - -# If tests crash cause LLDB to crash, or things are otherwise unstable, or if machine-parsable -# output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target. -add_custom_target(check-lldb) -add_dependencies(check-lldb lldb-test-deps) -set_target_properties(check-lldb PROPERTIES FOLDER "lldb misc") +string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) + +list(APPEND LLDB_TEST_DEPS + LLDBUnitTests + dsymutil + lit-cpuid + llc + lldb + lldb-test + lli + llvm-config + llvm-dwarfdump + llvm-nm + llvm-mc + llvm-objcopy + llvm-readobj + llvm-strip + ) + +if(TARGET lld) + list(APPEND LLDB_TEST_DEPS lld) +endif() + +# the value is not canonicalized within LLVM +llvm_canonicalize_cmake_booleans( + LLDB_DISABLE_PYTHON + LLVM_ENABLE_ZLIB + LLVM_ENABLE_SHARED_LIBS + LLDB_IS_64_BITS) + +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Shell/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Shell/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/Shell/lit.cfg.py) +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py) +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/API/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/API/lit.site.cfg) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Shell/lit-lldb-init.in + ${CMAKE_CURRENT_BINARY_DIR}/Shell/lit-lldb-init) + +if(NOT LLDB_BUILT_STANDALONE) + list(APPEND LLDB_TEST_DEPS + FileCheck + count + not + ) +endif() + +add_lit_testsuite(check-lldb-lit "Running lldb lit test suite" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${LLDB_TEST_DEPS} + ) + +set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests") # If we're building with an in-tree clang, then list clang as a dependency # to run tests. if (TARGET clang) - add_dependencies(check-lldb clang) + add_dependencies(check-lldb-lit clang) endif() -# LLD is required to link test executables on Windows. -if (CMAKE_SYSTEM_NAME MATCHES "Windows") - if (TARGET lld) - add_dependencies(check-lldb lld) - else () - message(WARNING "lld required to test LLDB on Windows") - endif () -endif () - -# Run the lit-style tests and the unittests as part of the check-lldb target. -add_dependencies(check-lldb check-lldb-lit) - -# This will add LLDB's test dependencies to the dependencies for check-all and -# include them in the test-depends target. -set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS}) +add_lit_testsuites(LLDB + ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${LLDB_TEST_DEPS} + ) Index: lldb/test/Shell/Python/crashlog.test =================================================================== --- lldb/test/Shell/Python/crashlog.test +++ lldb/test/Shell/Python/crashlog.test @@ -1,6 +1,6 @@ # -*- python -*- # REQUIRES: system-darwin -# RUN: cd %S/../../examples/python && cat %s | %lldb | FileCheck %s +# RUN: cd %S/../../../examples/python && cat %s | %lldb | FileCheck %s # CHECK-LABEL: {{S}}KIP BEYOND CHECKS script import crashlog @@ -44,7 +44,7 @@ # CHECK: (0) # CHECK: 01234 # CHECK: /tmp/MyApp Pro.app/MyApp Pro - + "0x7fff63f20000 - 0x7fff63f77ff7 libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib" # CHECK: 0x7fff63f20000 # CHECK: 0x7fff63f77ff7 Index: lldb/test/Shell/helper/toolchain.py =================================================================== --- lldb/test/Shell/helper/toolchain.py +++ lldb/test/Shell/helper/toolchain.py @@ -29,7 +29,7 @@ if config.llvm_libs_dir: build_script_args.append('--libs-dir={0}'.format(config.llvm_libs_dir)) - lldb_init = os.path.join(config.test_exec_root, 'lit-lldb-init') + lldb_init = os.path.join(config.test_exec_root, 'Shell', 'lit-lldb-init') primary_tools = [ ToolSubst('%lldb', Index: lldb/test/Shell/lit.cfg.py =================================================================== --- lldb/test/Shell/lit.cfg.py +++ lldb/test/Shell/lit.cfg.py @@ -17,7 +17,7 @@ from helper import toolchain # name: The name of this test suite. -config.name = 'LLDB' +config.name = 'lldb-shell' # testFormat: The test format to use to interpret tests. config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) Index: lldb/test/Shell/lit.site.cfg.py.in =================================================================== --- lldb/test/Shell/lit.site.cfg.py.in +++ lldb/test/Shell/lit.site.cfg.py.in @@ -41,4 +41,4 @@ lit.llvm.initialize(lit_config, config) # Let the main config do the real work. -lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/lit.cfg.py") +lit_config.load_config(config, "@LLDB_SOURCE_DIR@/test/Shell/lit.cfg.py") Index: lldb/test/Unit/README.md =================================================================== --- /dev/null +++ lldb/test/Unit/README.md @@ -0,0 +1,4 @@ +# LLDB Unit Tests + +This directory only exists for the lit test driver. The actual tests live in +the `unittest` directory in top level LLDB directory. Index: lldb/test/Unit/lit.cfg.py =================================================================== --- lldb/test/Unit/lit.cfg.py +++ lldb/test/Unit/lit.cfg.py @@ -9,7 +9,7 @@ from lit.llvm import llvm_config # name: The name of this test suite. -config.name = 'lldb-Unit' +config.name = 'lldb-unit' # suffixes: A list of file extensions to treat as test files. config.suffixes = [] Index: lldb/test/Unit/lit.site.cfg.py.in =================================================================== --- lldb/test/Unit/lit.site.cfg.py.in +++ lldb/test/Unit/lit.site.cfg.py.in @@ -26,4 +26,4 @@ lit.llvm.initialize(lit_config, config) # Let the main config do the real work. -lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Unit/lit.cfg.py") +lit_config.load_config(config, "@LLDB_SOURCE_DIR@/test/Unit/lit.cfg.py") Index: lldb/test/lit.cfg.py =================================================================== --- /dev/null +++ lldb/test/lit.cfg.py @@ -0,0 +1,41 @@ +# -*- Python -*- + +import os +import platform +import re +import shutil +import site +import sys + +import lit.formats +from lit.llvm import llvm_config +from lit.llvm.subst import FindTool +from lit.llvm.subst import ToolSubst +from distutils.spawn import find_executable + +# This is the top level configuration. Most of these configuration options will +# be overriden by individual lit configuration files in the test +# subdirectories. + +# name: The name of this test suite. +config.name = 'lldb' + +# testFormat: The test format to use to interpret tests. +config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) + +# suffixes: A list of file extensions to treat as test files. This is overriden +# by individual lit.local.cfg files in the test subdirectories. +config.suffixes = ['.test', '.cpp', '.s'] + +# excludes: A list of directories to exclude from the testsuite. The 'Inputs' +# subdirectories contain auxiliary inputs for various tests in their parent +# directories. +config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt'] + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) + +# test_exec_root: The root path where tests should be run. +config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit') + +llvm_config.use_default_substitutions()