2019-10-10 03:22:02 +08:00
# Test runner infrastructure for LLDB. This configures the LLDB test trees
# for use by Lit, and delegates to LLVM's lit test handlers.
2017-03-01 18:08:44 +08:00
2019-10-25 04:19:00 +08:00
# Configure the build directory.
set ( LLDB_TEST_BUILD_DIRECTORY "${PROJECT_BINARY_DIR}/lldb-test-build.noindex" CACHE PATH "The build root for building tests." )
2019-10-11 01:27:09 +08:00
# Configure and create module cache directories.
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." )
file ( MAKE_DIRECTORY ${ LLDB_TEST_MODULE_CACHE_LLDB } )
file ( MAKE_DIRECTORY ${ LLDB_TEST_MODULE_CACHE_CLANG } )
2019-10-10 03:22:02 +08:00
# 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 ( )
2019-10-10 01:35:43 +08:00
2019-10-10 03:22:02 +08:00
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 } )
2019-10-25 04:15:17 +08:00
# Create a custom target to track test dependencies.
add_custom_target ( lldb-test-deps )
set_target_properties ( lldb-test-deps PROPERTIES FOLDER "lldb misc" )
function ( add_lldb_test_dependency )
foreach ( dependency ${ ARGN } )
add_dependencies ( lldb-test-deps ${ dependency } )
endforeach ( )
endfunction ( add_lldb_test_dependency )
# lldb itself and lldb-test is an hard dependency for the testsuites.
add_lldb_test_dependency ( lldb )
add_lldb_test_dependency ( lldb-test )
# On Darwin, darwin-debug is an hard dependency for the testsuites.
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
add_lldb_test_dependency ( darwin-debug )
endif ( )
if ( TARGET lldb-server )
add_lldb_test_dependency ( lldb-server )
endif ( )
if ( TARGET lldb-vscode )
add_lldb_test_dependency ( lldb-vscode )
endif ( )
if ( TARGET lldb-instr )
add_lldb_test_dependency ( lldb-instr )
endif ( )
if ( TARGET liblldb )
add_lldb_test_dependency ( liblldb )
endif ( )
if ( TARGET lldb-framework )
add_lldb_test_dependency ( lldb-framework )
endif ( )
# Add dependencies that are not exported targets when building standalone.
if ( NOT LLDB_BUILT_STANDALONE )
add_lldb_test_dependency (
F i l e C h e c k
c o u n t
d s y m u t i l
l l v m - s t r i p
n o t
y a m l 2 o b j
)
endif ( )
# Add dependencies if we test with the in-tree clang.
# This works with standalone builds as they import the clang target.
if ( TARGET clang )
add_lldb_test_dependency ( clang )
if ( APPLE )
# If we build clang, we should build libcxx.
# FIXME: Standalone builds should import the cxx target as well.
if ( LLDB_BUILT_STANDALONE )
# For now check that the include directory exists.
set ( cxx_dir "${LLVM_BINARY_DIR}/include/c++" )
if ( NOT EXISTS ${ cxx_dir } )
message ( WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}" )
endif ( )
else ( )
# We require libcxx for the test suite, so if we aren't building it,
# try to provide a helpful error about how to resolve the situation.
if ( NOT TARGET cxx )
if ( LLVM_ENABLE_PROJECTS STREQUAL "" )
# If `LLVM_ENABLE_PROJECTS` is not being used (implying that we are
# using the old layout), suggest checking it out.
message ( FATAL_ERROR
" L L D B t e s t s u i t e r e q u i r e s l i b c + + , b u t i t i s c u r r e n t l y d i s a b l e d . "
" P l e a s e c h e c k o u t ` l i b c x x ` i n ` l l v m / p r o j e c t s ` o r d i s a b l e t e s t s "
" v i a ` L L D B _ I N C L U D E _ T E S T S = O F F ` . " )
else ( )
# If `LLVM_ENABLE_PROJECTS` is being used, suggest adding it.
message ( FATAL_ERROR
" L L D B t e s t s u i t e r e q u i r e s l i b c + + , b u t i t i s c u r r e n t l y d i s a b l e d . "
" P l e a s e a d d ` l i b c x x ` t o ` L L V M _ E N A B L E _ P R O J E C T S ` o r d i s a b l e t e s t s "
" v i a ` L L D B _ I N C L U D E _ T E S T S = O F F ` . " )
endif ( )
endif ( )
add_lldb_test_dependency ( cxx )
endif ( )
endif ( )
endif ( )
2019-10-10 03:22:02 +08:00
add_lldb_test_dependency (
l i t - c p u i d
l l c
l l i
l l v m - c o n f i g
l l v m - d w a r f d u m p
l l v m - n m
l l v m - m c
l l v m - o b j c o p y
l l v m - r e a d o b j
)
2018-03-09 03:46:39 +08:00
2019-10-10 03:22:02 +08:00
if ( TARGET lld )
add_lldb_test_dependency ( lld )
else ( )
# LLD is required to link test executables on Windows.
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
message ( WARNING "lld required to test LLDB on Windows" )
2019-10-10 01:35:43 +08:00
endif ( )
2019-10-10 00:38:47 +08:00
endif ( )
2017-07-19 07:45:06 +08:00
2019-10-25 01:54:48 +08:00
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( LLDB_IS_64_BITS 1 )
2019-10-10 04:36:29 +08:00
endif ( )
2019-10-11 05:49:22 +08:00
# These values are not canonicalized within LLVM.
2019-10-10 03:22:02 +08:00
llvm_canonicalize_cmake_booleans (
L L D B _ D I S A B L E _ P Y T H O N
L L V M _ E N A B L E _ Z L I B
L L V M _ E N A B L E _ S H A R E D _ L I B S
L L D B _ I S _ 6 4 _ B I T S )
2019-10-25 01:54:48 +08:00
# Configure the individual test suites.
add_subdirectory ( API )
add_subdirectory ( Shell )
add_subdirectory ( Unit )
2019-10-11 05:49:22 +08:00
# Configure the top level test suite.
configure_lit_site_cfg (
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / l i t . s i t e . c f g . p y . i n
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i t . s i t e . c f g . p y
M A I N _ C O N F I G
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / l i t . c f g . p y )
2019-10-10 03:22:02 +08:00
add_lit_testsuites ( LLDB
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
2019-10-25 01:54:48 +08:00
D E P E N D S l l d b - t e s t - d e p s )
2018-02-22 05:10:44 +08:00
2019-10-10 03:22:02 +08:00
add_lit_testsuite ( check-lldb-lit "Running lldb lit test suite"
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
2019-10-25 01:54:48 +08:00
D E P E N D S l l d b - t e s t - d e p s )
2019-10-10 03:22:02 +08:00
set_target_properties ( check-lldb-lit PROPERTIES FOLDER "lldb tests" )
2019-10-10 01:35:43 +08:00
add_custom_target ( check-lldb )
add_dependencies ( check-lldb lldb-test-deps )
set_target_properties ( check-lldb PROPERTIES FOLDER "lldb misc" )
add_dependencies ( check-lldb check-lldb-lit )