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()
|
|
|
|
|
2018-04-12 17:25:32 +08:00
|
|
|
set(LLDB_TEST_DEPS lldb dsymutil)
|
2016-10-13 04:26:13 +08:00
|
|
|
|
2017-12-16 07:27:10 +08:00
|
|
|
# darwin-debug is an hard dependency for the testsuite.
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
|
|
list(APPEND LLDB_TEST_DEPS darwin-debug)
|
|
|
|
endif()
|
|
|
|
|
2016-10-13 04:26:13 +08:00
|
|
|
if(TARGET lldb-server)
|
|
|
|
list(APPEND LLDB_TEST_DEPS lldb-server)
|
|
|
|
endif()
|
2018-03-05 18:03:44 +08:00
|
|
|
|
2016-10-13 04:26:13 +08:00
|
|
|
if(TARGET debugserver)
|
2018-01-18 09:16:30 +08:00
|
|
|
if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
|
|
|
|
list(APPEND LLDB_TEST_DEPS debugserver)
|
|
|
|
endif()
|
2016-10-13 04:26:13 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET lldb-mi)
|
|
|
|
list(APPEND LLDB_TEST_DEPS lldb-mi)
|
|
|
|
endif()
|
|
|
|
|
[lldb] Generic base for testing gdb-remote behavior
Summary:
Adds new utilities that make it easier to write test cases for lldb acting as a client over a gdb-remote connection.
- A GDBRemoteTestBase class that starts a mock GDB server and provides an easy way to check client packets
- A MockGDBServer that, via MockGDBServerResponder, can be made to issue server responses that test client behavior.
- Utility functions for handling common data encoding/decoding
- Utility functions for creating dummy targets from YAML files
----
Split from the review at https://reviews.llvm.org/D42145, which was a new feature that necessitated the new testing capabilities.
Reviewers: clayborg, labath
Reviewed By: clayborg, labath
Subscribers: hintonda, davide, jingham, krytarowski, mgorny, lldb-commits
Differential Revision: https://reviews.llvm.org/D42195
Patch by Owen Shaw <llvm@owenpshaw.net>
llvm-svn: 323636
2018-01-29 18:02:40 +08:00
|
|
|
if(NOT LLDB_BUILT_STANDALONE)
|
|
|
|
list(APPEND LLDB_TEST_DEPS yaml2obj)
|
|
|
|
endif()
|
|
|
|
|
2018-03-15 09:09:13 +08:00
|
|
|
if(TARGET liblldb)
|
|
|
|
list(APPEND LLDB_TEST_DEPS liblldb)
|
|
|
|
endif()
|
|
|
|
|
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
|
|
|
|
|
|
|
# Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script
|
|
|
|
set(LLDB_TEST_USER_ARGS
|
2017-07-19 07:45:06 +08:00
|
|
|
""
|
|
|
|
CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'")
|
2014-08-01 05:07:41 +08:00
|
|
|
|
2018-02-03 02:32:29 +08:00
|
|
|
# The .nodindex 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.
|
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>
|
2018-04-12 17:25:32 +08:00
|
|
|
--dsymutil $<TARGET_FILE:dsymutil>
|
2013-03-01 07:11:46 +08:00
|
|
|
-s
|
2014-08-01 05:07:41 +08:00
|
|
|
${CMAKE_BINARY_DIR}/lldb-test-traces
|
2018-01-31 02:29:16 +08:00
|
|
|
--build-dir
|
2018-02-03 02:32:29 +08:00
|
|
|
${CMAKE_BINARY_DIR}/lldb-test-build.noindex
|
2016-05-18 02:02:34 +08:00
|
|
|
-S nm
|
2013-05-14 05:41:35 +08:00
|
|
|
-u CXXFLAGS
|
|
|
|
-u CFLAGS
|
2017-10-27 10:24:04 +08:00
|
|
|
-C ${LLDB_TEST_C_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)
|
2018-03-05 18:03:44 +08:00
|
|
|
|
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()
|
|
|
|
|
2017-03-01 18:08:44 +08:00
|
|
|
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
|
|
|
|
list(APPEND LLDB_TEST_COMMON_ARGS
|
|
|
|
--env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY})
|
|
|
|
endif()
|
|
|
|
|
2017-03-15 04:04:46 +08:00
|
|
|
if(CMAKE_HOST_APPLE)
|
2018-01-18 09:16:30 +08:00
|
|
|
list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
|
2017-03-15 04:04:46 +08:00
|
|
|
endif()
|
|
|
|
|
2018-03-09 03:46:39 +08:00
|
|
|
if(SKIP_DEBUGSERVER)
|
|
|
|
list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
|
|
|
|
endif()
|
|
|
|
|
2017-07-19 07:45:06 +08:00
|
|
|
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
|
|
|
|
|
2013-03-01 07:11:46 +08:00
|
|
|
add_python_test_target(check-lldb-single
|
|
|
|
${LLDB_SOURCE_DIR}/test/dotest.py
|
2017-07-19 07:45:06 +08:00
|
|
|
"--no-multiprocess;${LLDB_DOTEST_ARGS}"
|
|
|
|
"Testing LLDB with args: ${LLDB_DOTEST_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.
|
2018-04-19 01:08:49 +08:00
|
|
|
add_custom_target(check-lldb)
|
2017-03-15 04:04:46 +08:00
|
|
|
|
2018-03-05 18:03:44 +08:00
|
|
|
# Generate a wrapper for dotest.py in the bin directory.
|
2018-03-21 19:13:56 +08:00
|
|
|
# We need configure_file to substitute variables.
|
2018-03-05 18:03:44 +08:00
|
|
|
configure_file(
|
2018-03-14 23:36:32 +08:00
|
|
|
lldb-dotest.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lldb-dotest.configured
|
2018-03-05 18:03:44 +08:00
|
|
|
)
|
|
|
|
# We need this to expand the generator expressions.
|
|
|
|
file(GENERATE
|
|
|
|
OUTPUT
|
2018-03-14 23:36:32 +08:00
|
|
|
$<TARGET_FILE_DIR:lldb>/lldb-dotest
|
2018-03-05 18:03:44 +08:00
|
|
|
INPUT
|
2018-03-14 23:36:32 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lldb-dotest.configured
|
2018-03-05 18:03:44 +08:00
|
|
|
)
|
2018-03-14 23:36:32 +08:00
|
|
|
# Make this a custom target.
|
|
|
|
add_custom_target(lldb-dotest)
|
|
|
|
add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
|
2018-03-05 18:03:44 +08:00
|
|
|
|
2018-04-19 01:08:49 +08:00
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../lit/Suite/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
|
|
|
|
)
|
|
|
|
file(GENERATE
|
|
|
|
OUTPUT
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
|
|
|
|
INPUT
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
|
|
|
|
)
|
|
|
|
|
2017-10-28 05:22:57 +08:00
|
|
|
# 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()
|
|
|
|
|
2017-11-07 03:25:33 +08:00
|
|
|
# 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 ()
|
|
|
|
|
2018-02-22 05:10:44 +08:00
|
|
|
# Run the lit-style tests and the unittests as part of the check-lldb target.
|
|
|
|
add_dependencies(check-lldb check-lldb-lit)
|
|
|
|
|
2017-03-15 04:04:46 +08:00
|
|
|
add_custom_target(lldb-test-depends DEPENDS ${LLDB_TEST_DEPENDS})
|
|
|
|
# This will add LLDB's test dependencies to the depenednecies for check-all and
|
|
|
|
# include them in the test-depends target.
|
|
|
|
set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS})
|