2013-03-01 07:11:46 +08:00
|
|
|
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}"
|
2016-10-13 04:26:13 +08:00
|
|
|
DEPENDS ${LLDB_TEST_DEPS}
|
|
|
|
USES_TERMINAL
|
2013-03-01 07:11:46 +08:00
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2016-10-13 04:26:13 +08:00
|
|
|
set(LLDB_TEST_DEPS lldb)
|
|
|
|
|
|
|
|
if(TARGET lldb-server)
|
|
|
|
list(APPEND LLDB_TEST_DEPS lldb-server)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET debugserver)
|
|
|
|
list(APPEND LLDB_TEST_DEPS debugserver)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET lldb-mi)
|
|
|
|
list(APPEND LLDB_TEST_DEPS lldb-mi)
|
|
|
|
endif()
|
|
|
|
|
2014-07-19 06:46:22 +08:00
|
|
|
if ("${LLDB_TEST_COMPILER}" STREQUAL "")
|
|
|
|
string(REGEX REPLACE ".*ccache\ +" "" LLDB_TEST_COMPILER ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
|
|
|
|
endif()
|
2013-03-07 08:50:54 +08:00
|
|
|
|
2014-08-01 05:07:41 +08:00
|
|
|
# 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}
|
2014-08-02 00:57:46 +08:00
|
|
|
CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64). Determines whether tests are compiled with -m32 or -m64")
|
2014-08-01 05:07:41 +08:00
|
|
|
|
2016-10-19 07:54:28 +08:00
|
|
|
# Scrub LLDB_TEST_COMPILER out of the CMake caches
|
|
|
|
# TODO: remove the replace lines and the FORCE parameter in a few days once the
|
|
|
|
# change has made its way through bots to clean up their CMake caches.
|
|
|
|
string(REPLACE "-C;${LLDB_TEST_COMPILER}" "" LLDB_TEST_USER_ARGS_New "${LLDB_TEST_USER_ARGS}")
|
|
|
|
|
2016-11-03 01:19:26 +08:00
|
|
|
if(LLDB_TEST_CLANG)
|
|
|
|
set(LLDB_TEST_COMPILER $<TARGET_FILE:clang>)
|
|
|
|
endif()
|
|
|
|
|
2014-08-01 05:07:41 +08:00
|
|
|
# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script
|
|
|
|
set(LLDB_TEST_USER_ARGS
|
2016-10-19 07:54:28 +08:00
|
|
|
"${LLDB_TEST_USER_ARGS_New}"
|
|
|
|
CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'" FORCE)
|
2014-08-01 05:07:41 +08:00
|
|
|
|
|
|
|
set(LLDB_TEST_COMMON_ARGS
|
|
|
|
--arch=${LLDB_TEST_ARCH}
|
2016-10-13 04:26:13 +08:00
|
|
|
--executable $<TARGET_FILE:lldb>
|
2013-03-01 07:11:46 +08:00
|
|
|
-s
|
2014-08-01 05:07:41 +08:00
|
|
|
${CMAKE_BINARY_DIR}/lldb-test-traces
|
2016-05-18 02:02:34 +08:00
|
|
|
-S nm
|
2013-05-14 05:41:35 +08:00
|
|
|
-u CXXFLAGS
|
|
|
|
-u CFLAGS
|
2016-10-19 07:54:28 +08:00
|
|
|
-C ${LLDB_TEST_COMPILER}
|
2013-03-01 07:11:46 +08:00
|
|
|
)
|
|
|
|
|
2014-12-13 02:10:52 +08:00
|
|
|
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
|
2016-05-24 01:32:04 +08:00
|
|
|
# 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)
|
|
|
|
|
2014-12-13 02:10:52 +08:00
|
|
|
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()
|
|
|
|
|
2016-10-22 06:13:55 +08:00
|
|
|
if(LLDB_CODESIGN_IDENTITY)
|
|
|
|
list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
|
|
|
|
endif()
|
|
|
|
|
2016-10-31 12:48:10 +08:00
|
|
|
if(LLDB_BUILD_FRAMEWORK)
|
|
|
|
list(APPEND LLDB_TEST_COMMON_ARGS --framework $<TARGET_FILE_DIR:liblldb>)
|
|
|
|
endif()
|
|
|
|
|
2013-03-01 07:11:46 +08:00
|
|
|
add_python_test_target(check-lldb-single
|
|
|
|
${LLDB_SOURCE_DIR}/test/dotest.py
|
2015-09-04 02:58:44 +08:00
|
|
|
"--no-multiprocess;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
|
2014-08-01 05:07:41 +08:00
|
|
|
"Testing LLDB with args: ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
|
2013-03-01 07:11:46 +08:00
|
|
|
)
|
|
|
|
|
2015-09-04 02:58:44 +08:00
|
|
|
set(LLDB_DOTEST_ARGS -q;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
|
2013-03-01 07:11:46 +08:00
|
|
|
|
|
|
|
# If tests crash cause LLDB to crash, or things are otherwise unstable, or if machine-parsable
|
2014-12-13 02:10:52 +08:00
|
|
|
# output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target.
|
2013-03-01 07:11:46 +08:00
|
|
|
add_python_test_target(check-lldb
|
2015-09-04 02:58:44 +08:00
|
|
|
${LLDB_SOURCE_DIR}/test/dotest.py
|
|
|
|
"${LLDB_DOTEST_ARGS}"
|
|
|
|
"Testing LLDB (parallel execution, with a separate subprocess per test)"
|
2013-03-01 07:11:46 +08:00
|
|
|
)
|