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
2020-03-31 02:34:55 +08:00
if ( LLDB_BUILT_STANDALONE )
# In order to run check-lldb-* we need the correct map_config directives in
# llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB,
# and the lldb mappings are missing. We build our own llvm-lit, and tell LLVM
# to use the llvm-lit in the lldb build directory.
if ( EXISTS ${ LLVM_MAIN_SRC_DIR } /utils/llvm-lit )
set ( LLVM_EXTERNAL_LIT ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } /llvm-lit )
endif ( )
endif ( )
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 )
2019-11-07 07:22:17 +08:00
if ( TARGET asan )
add_lldb_test_dependency ( asan )
endif ( )
if ( TARGET tsan )
add_lldb_test_dependency ( tsan )
endif ( )
2019-10-25 04:15:17 +08:00
if ( APPLE )
# 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 ( )
2020-01-17 10:52:39 +08:00
if ( LLDB_BUILT_STANDALONE )
set ( LLVM_HOST_TRIPLE ${ TARGET_TRIPLE } )
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
2020-02-24 23:45:37 +08:00
l l v m - d w p
2019-10-10 03:22:02 +08:00
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 (
2020-04-04 10:42:58 +08:00
L L D B _ B U I L D _ I N T E L _ P T
2019-12-14 02:37:33 +08:00
L L D B _ E N A B L E _ P Y T H O N
2019-12-08 09:35:31 +08:00
L L D B _ E N A B L E _ L U A
2019-12-21 07:38:46 +08:00
L L D B _ E N A B L E _ L Z M A
2019-10-10 03:22:02 +08:00
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 )
2020-03-31 02:34:55 +08:00
2020-05-29 01:39:45 +08:00
# Add a lit test suite that runs the API & shell test while capturing a
# reproducer.
add_lit_testsuite ( check-lldb-reproducers-capture
" R u n n i n g l l d b t e s t s u i t e w i t h r e p r o d u c e r c a p t u r e "
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / A P I
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S h e l l
P A R A M S " l l d b - r u n - w i t h - r e p r o = c a p t u r e "
E X C L U D E _ F R O M _ C H E C K _ A L L
D E P E N D S l l d b - t e s t - d e p s )
# Add a lit test suite that runs the API & shell test by replaying a
# reproducer.
add_lit_testsuite ( check-lldb-reproducers
" R u n n i n g l l d b t e s t s u i t e w i t h r e p r o d u c e r r e p l a y "
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / A P I
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S h e l l
P A R A M S " l l d b - r u n - w i t h - r e p r o = r e p l a y "
E X C L U D E _ F R O M _ C H E C K _ A L L
D E P E N D S l l d b - t e s t - d e p s )
add_dependencies ( check-lldb-reproducers check-lldb-reproducers-capture )
2020-03-31 02:34:55 +08:00
if ( LLDB_BUILT_STANDALONE )
# This has to happen *AFTER* add_lit_testsuite.
if ( EXISTS ${ LLVM_MAIN_SRC_DIR } /utils/llvm-lit )
add_subdirectory ( ${ LLVM_MAIN_SRC_DIR } /utils/llvm-lit ${ CMAKE_CURRENT_BINARY_DIR } /llvm-lit )
endif ( )
endif ( )