mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 22:30:13 +00:00
[CMake] Unify and relayer testing
This patch restructures part of LLDB's testing configuration: 1. I moved the test dependencies up the chain so every dotest dependency becomes a lit dependency as well. It wouldn't make sense for dotest to have other dependencies when it's being run by lit. Lit on the other hand can still specify extra dependencies. 2. I replaced as much generator expressions with variables as possible. This is consistent with the rest of LLVM and doesn't break generators that support multiple targets (MSVC, Xcode). This wasn't a problem before, but now we need to expand the dotest arguments in the lit configuration and there's only one test suite even with multiple targets. 3. I moved lldb-dotest into it's own directory under utils since there's no need anymore for it to located under `test/`. Differential revision: https://reviews.llvm.org/D46334 llvm-svn: 331463
This commit is contained in:
parent
c42fa4be1f
commit
52721286b2
@ -85,9 +85,43 @@ if(LLDB_INCLUDE_TESTS)
|
||||
message(FATAL_ERROR "LLDB test compilers not specified. Tests will not run")
|
||||
endif()
|
||||
|
||||
set(LLDB_TEST_DEPS lldb)
|
||||
|
||||
# darwin-debug is an hard dependency for the testsuite.
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
list(APPEND LLDB_TEST_DEPS darwin-debug)
|
||||
endif()
|
||||
|
||||
if(TARGET lldb-server)
|
||||
list(APPEND LLDB_TEST_DEPS lldb-server)
|
||||
endif()
|
||||
|
||||
if(TARGET debugserver)
|
||||
if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
|
||||
list(APPEND LLDB_TEST_DEPS debugserver)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET lldb-mi)
|
||||
list(APPEND LLDB_TEST_DEPS lldb-mi)
|
||||
endif()
|
||||
|
||||
if(NOT LLDB_BUILT_STANDALONE)
|
||||
list(APPEND LLDB_TEST_DEPS yaml2obj dsymutil)
|
||||
endif()
|
||||
|
||||
if(TARGET liblldb)
|
||||
list(APPEND LLDB_TEST_DEPS liblldb)
|
||||
endif()
|
||||
|
||||
if(TARGET clang)
|
||||
list(APPEND LLDB_TEST_DEPS clang)
|
||||
endif()
|
||||
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(unittests)
|
||||
add_subdirectory(lit)
|
||||
add_subdirectory(utils/lldb-dotest)
|
||||
endif()
|
||||
|
||||
if (NOT LLDB_DISABLE_PYTHON)
|
||||
|
@ -15,10 +15,13 @@ if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER)
|
||||
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_CXX_COMPILER ${LLDB_TEST_CXX_COMPILER})
|
||||
endif ()
|
||||
|
||||
get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
|
||||
|
||||
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})
|
||||
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
|
||||
|
||||
set(LLDB_TEST_DEPS
|
||||
list(APPEND LLDB_TEST_DEPS
|
||||
LLDBUnitTests
|
||||
dsymutil
|
||||
lldb
|
||||
@ -35,7 +38,6 @@ else()
|
||||
set(LLDB_HAVE_LLD 0)
|
||||
endif()
|
||||
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(ENABLE_SHARED 1)
|
||||
else()
|
||||
@ -51,24 +53,16 @@ configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
|
||||
)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg)
|
||||
|
||||
if(NOT LLDB_BUILT_STANDALONE)
|
||||
list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)
|
||||
endif()
|
||||
|
||||
# lldb-server is not built on every platform.
|
||||
if (TARGET lldb-server)
|
||||
list(APPEND LLDB_TEST_DEPS lldb-server)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND LLDB_TEST_DEPS debugserver)
|
||||
endif()
|
||||
|
||||
if(TARGET clang)
|
||||
list(APPEND LLDB_TEST_DEPS clang)
|
||||
list(APPEND LLDB_TEST_DEPS
|
||||
FileCheck
|
||||
not
|
||||
)
|
||||
endif()
|
||||
|
||||
set(LLDB_TEST_PARAMS
|
||||
|
@ -12,7 +12,7 @@ config.lldb_src_root = "@LLDB_SOURCE_DIR@"
|
||||
config.target_triple = "@TARGET_TRIPLE@"
|
||||
config.python_executable = "@PYTHON_EXECUTABLE@"
|
||||
config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
|
||||
config.dotest_args_str = "@LLDB_DOTEST_ARGS_STR@"
|
||||
config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
|
||||
|
||||
# Support substitution of the tools and libs dirs with user parameters. This is
|
||||
# used when we can't determine the tool dir at configuration time.
|
||||
|
@ -13,35 +13,6 @@ function(add_python_test_target name test_script args comment)
|
||||
)
|
||||
endfunction()
|
||||
|
||||
set(LLDB_TEST_DEPS lldb)
|
||||
|
||||
# darwin-debug is an hard dependency for the testsuite.
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
list(APPEND LLDB_TEST_DEPS darwin-debug)
|
||||
endif()
|
||||
|
||||
if(TARGET lldb-server)
|
||||
list(APPEND LLDB_TEST_DEPS lldb-server)
|
||||
endif()
|
||||
|
||||
if(TARGET debugserver)
|
||||
if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
|
||||
list(APPEND LLDB_TEST_DEPS debugserver)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET lldb-mi)
|
||||
list(APPEND LLDB_TEST_DEPS lldb-mi)
|
||||
endif()
|
||||
|
||||
if(NOT LLDB_BUILT_STANDALONE)
|
||||
list(APPEND LLDB_TEST_DEPS yaml2obj dsymutil)
|
||||
endif()
|
||||
|
||||
if(TARGET liblldb)
|
||||
list(APPEND LLDB_TEST_DEPS liblldb)
|
||||
endif()
|
||||
|
||||
# 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)
|
||||
@ -75,28 +46,12 @@ set(LLDB_TEST_COMMON_ARGS
|
||||
-u CFLAGS
|
||||
)
|
||||
|
||||
# We need two properties here, because they are used for different purposes. When we are generating
|
||||
# one file per configuration for lldb-dotest, we want the paths to be configuration specific. However,
|
||||
# when we are generating a single lit file, the file itself should not be per configuration and the paths
|
||||
# contained inside should be generic also.
|
||||
set(LLDB_EXECUTABLE_PATH_ARGS
|
||||
--executable $<TARGET_FILE:lldb>
|
||||
--dsymutil $<TARGET_FILE:dsymutil>
|
||||
)
|
||||
set(LLDB_EXECUTABLE_PATH_ARGS_STR
|
||||
list(APPEND LLDB_TEST_COMMON_ARGS
|
||||
--executable ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}
|
||||
--dsymutil ${LLVM_RUNTIME_OUTPUT_INTDIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}
|
||||
-C ${LLDB_TEST_C_COMPILER}
|
||||
)
|
||||
|
||||
# There's an additional complication which is that when the compiler is NOT a custom compiler, we need to
|
||||
# make sure to get the configuration specific path as well
|
||||
if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER)
|
||||
list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C $<TARGET_FILE:clang>)
|
||||
else()
|
||||
list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C ${LLDB_TEST_C_COMPILER})
|
||||
endif()
|
||||
|
||||
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)
|
||||
@ -122,11 +77,8 @@ if(LLDB_CODESIGN_IDENTITY)
|
||||
list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
|
||||
endif()
|
||||
|
||||
# The framework path is passed to the test arguments as $<TARGET_FILE_DIR:liblldb>. This won't work in the
|
||||
# LLDB_DOTEST_ARGS_STR when using a generator that supports multiple configurations such as Visual Studio,
|
||||
# but since the framework is currently confined to Darwin/Apple, we can leave it as is.
|
||||
if(LLDB_BUILD_FRAMEWORK)
|
||||
list(APPEND LLDB_TEST_COMMON_ARGS --framework $<TARGET_FILE_DIR:liblldb>)
|
||||
list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLVM_LIBRARY_OUTPUT_INTDIR})
|
||||
endif()
|
||||
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
|
||||
@ -134,9 +86,6 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
|
||||
--env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY})
|
||||
endif()
|
||||
|
||||
# In some cases, DEBUGSERVER_PATH is expressed as $<TARGET_FILE:debugserver>. This won't work in the
|
||||
# LLDB_DOTEST_ARGS_STR when using a generator that supports multiple configurations such as Visual Studio,
|
||||
# but since debugserver is currently confined to Darwin/Apple, we can leave it as is.
|
||||
if(CMAKE_HOST_APPLE)
|
||||
list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
|
||||
endif()
|
||||
@ -145,8 +94,8 @@ if(SKIP_DEBUGSERVER)
|
||||
list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
|
||||
endif()
|
||||
|
||||
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_EXECUTABLE_PATH_ARGS};${LLDB_TEST_USER_ARGS})
|
||||
set(LLDB_DOTEST_ARGS_STR ${LLDB_TEST_COMMON_ARGS};${LLDB_EXECUTABLE_PATH_ARGS_STR};${LLDB_TEST_USER_ARGS})
|
||||
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
|
||||
set_property(GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY ${LLDB_DOTEST_ARGS})
|
||||
|
||||
add_python_test_target(check-lldb-single
|
||||
${LLDB_SOURCE_DIR}/test/dotest.py
|
||||
@ -158,38 +107,6 @@ add_python_test_target(check-lldb-single
|
||||
# output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target.
|
||||
add_custom_target(check-lldb)
|
||||
|
||||
# Generate a wrapper for dotest.py in the bin directory.
|
||||
# We need configure_file to substitute variables.
|
||||
configure_file(
|
||||
lldb-dotest.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lldb-dotest.configured
|
||||
)
|
||||
# We need this to expand the generator expressions. TARGET_FILE_DIR is OK here because we want to
|
||||
# generate a copy of lldb-dotest per configuration.
|
||||
file(GENERATE
|
||||
OUTPUT
|
||||
$<TARGET_FILE_DIR:lldb>/lldb-dotest
|
||||
INPUT
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lldb-dotest.configured
|
||||
)
|
||||
# Make this a custom target.
|
||||
add_custom_target(lldb-dotest)
|
||||
add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
|
||||
|
||||
if (CMAKE_CFG_INTDIR STREQUAL ".")
|
||||
set(LLVM_BUILD_MODE ".")
|
||||
else ()
|
||||
set(LLVM_BUILD_MODE "%(build_mode)s")
|
||||
endif ()
|
||||
|
||||
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})
|
||||
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS_STR "${LLDB_DOTEST_ARGS_STR}")
|
||||
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../lit/Suite/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg)
|
||||
|
||||
# If we're building with an in-tree clang, then list clang as a dependency
|
||||
# to run tests.
|
||||
if (TARGET clang)
|
||||
|
@ -77,7 +77,7 @@ set(lldbDebugserverCommonSources
|
||||
RNBSocket.cpp
|
||||
SysSignal.cpp
|
||||
TTYState.cpp
|
||||
|
||||
|
||||
MacOSX/CFBundle.cpp
|
||||
MacOSX/CFString.cpp
|
||||
MacOSX/Genealogy.cpp
|
||||
@ -99,7 +99,7 @@ set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
|
||||
CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
|
||||
|
||||
if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
|
||||
set(DEBUGSERVER_PATH $<TARGET_FILE:debugserver> CACHE PATH "Path to debugserver.")
|
||||
set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
|
||||
set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
|
||||
else()
|
||||
execute_process(
|
||||
|
22
lldb/utils/lldb-dotest/CMakeLists.txt
Normal file
22
lldb/utils/lldb-dotest/CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
# Make lldb-dotest a custom target.
|
||||
add_custom_target(lldb-dotest)
|
||||
add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
|
||||
|
||||
get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
|
||||
|
||||
# Generate wrapper for each build mode.
|
||||
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
|
||||
foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
|
||||
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
|
||||
configure_file(
|
||||
lldb-dotest.in
|
||||
${LLDB_DOTEST_DIR}/lldb-dotest
|
||||
)
|
||||
endforeach()
|
||||
else()
|
||||
configure_file(
|
||||
lldb-dotest.in
|
||||
${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-dotest
|
||||
)
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user