1 function(add_python_test_target name test_script args comment)
2 set(PYTHON_TEST_COMMAND
8 add_custom_target(${name}
9 COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS}
11 DEPENDS ${LLDB_TEST_DEPS}
16 set(LLDB_TEST_DEPS lldb)
18 if(TARGET lldb-server)
19 list(APPEND LLDB_TEST_DEPS lldb-server)
22 if(TARGET debugserver)
23 list(APPEND LLDB_TEST_DEPS debugserver)
27 list(APPEND LLDB_TEST_DEPS lldb-mi)
30 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
31 string(REGEX REPLACE ".*ccache\ +" "" LLDB_TEST_COMPILER ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
34 # The default architecture with which to compile test executables is the default LLVM target
35 # architecture, which itself defaults to the host architecture.
36 string(TOLOWER "${LLVM_TARGET_ARCH}" LLDB_DEFAULT_TEST_ARCH)
37 if( LLDB_DEFAULT_TEST_ARCH STREQUAL "host" )
38 string(REGEX MATCH "^[^-]*" LLDB_DEFAULT_TEST_ARCH ${LLVM_HOST_TRIPLE})
41 # Allow the user to override the default by setting LLDB_TEST_ARCH
43 ${LLDB_DEFAULT_TEST_ARCH}
44 CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64). Determines whether tests are compiled with -m32 or -m64")
46 # Scrub LLDB_TEST_COMPILER out of the CMake caches
47 # TODO: remove the replace lines and the FORCE parameter in a few days once the
48 # change has made its way through bots to clean up their CMake caches.
49 string(REPLACE "-C;${LLDB_TEST_COMPILER}" "" LLDB_TEST_USER_ARGS_New "${LLDB_TEST_USER_ARGS}")
52 set(LLDB_TEST_COMPILER $<TARGET_FILE:clang>)
55 # Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script
56 set(LLDB_TEST_USER_ARGS
57 "${LLDB_TEST_USER_ARGS_New}"
58 CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'" FORCE)
60 set(LLDB_TEST_COMMON_ARGS
61 --arch=${LLDB_TEST_ARCH}
62 --executable $<TARGET_FILE:lldb>
64 ${CMAKE_BINARY_DIR}/lldb-test-traces
68 -C ${LLDB_TEST_COMPILER}
71 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
72 # All tests are currently flaky on Windows, so rerun them all once when they fail.
73 set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --rerun-all-issues)
75 set(LLDB_TEST_DEBUG_TEST_CRASHES
77 CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes")
79 set(LLDB_TEST_HIDE_CONSOLE_WINDOWS
81 CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite")
83 if (LLDB_TEST_DEBUG_TEST_CRASHES)
84 set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --enable-crash-dialog)
87 if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS)
88 set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --show-inferior-console)
92 if(LLDB_CODESIGN_IDENTITY)
93 list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
96 if(LLDB_BUILD_FRAMEWORK)
97 list(APPEND LLDB_TEST_COMMON_ARGS --framework $<TARGET_FILE_DIR:liblldb>)
100 add_python_test_target(check-lldb-single
101 ${LLDB_SOURCE_DIR}/test/dotest.py
102 "--no-multiprocess;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
103 "Testing LLDB with args: ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}"
106 set(LLDB_DOTEST_ARGS -q;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
108 # If tests crash cause LLDB to crash, or things are otherwise unstable, or if machine-parsable
109 # output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target.
110 add_python_test_target(check-lldb
111 ${LLDB_SOURCE_DIR}/test/dotest.py
112 "${LLDB_DOTEST_ARGS}"
113 "Testing LLDB (parallel execution, with a separate subprocess per test)"