]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CMakeLists.txt
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / test / CMakeLists.txt
1 function(add_python_test_target name test_script args comment)
2   set(PYTHON_TEST_COMMAND
3     ${PYTHON_EXECUTABLE}
4     ${test_script}
5     ${args}
6     )
7
8   add_custom_target(${name}
9     COMMAND ${PYTHON_TEST_COMMAND} ${ARG_DEFAULT_ARGS}
10     COMMENT "${comment}"
11     DEPENDS ${LLDB_TEST_DEPS}
12     USES_TERMINAL
13     )
14 endfunction()
15
16 set(LLDB_TEST_DEPS lldb)
17
18 if(TARGET lldb-server)
19   list(APPEND LLDB_TEST_DEPS lldb-server)
20 endif()
21   
22 if(TARGET debugserver)
23   list(APPEND LLDB_TEST_DEPS debugserver)
24 endif()
25
26 if(TARGET lldb-mi)
27   list(APPEND LLDB_TEST_DEPS lldb-mi)
28 endif()
29
30 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
31     string(REGEX REPLACE ".*ccache\ +" "" LLDB_TEST_COMPILER ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
32 endif()
33
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})
39 endif ()
40
41 # Allow the user to override the default by setting LLDB_TEST_ARCH
42 set(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")
45
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}")
50
51 if(LLDB_TEST_CLANG)
52   set(LLDB_TEST_COMPILER $<TARGET_FILE:clang>)
53 endif()
54
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)
59
60 set(LLDB_TEST_COMMON_ARGS
61   --arch=${LLDB_TEST_ARCH}
62   --executable $<TARGET_FILE:lldb>
63   -s
64   ${CMAKE_BINARY_DIR}/lldb-test-traces
65   -S nm
66   -u CXXFLAGS
67   -u CFLAGS
68   -C ${LLDB_TEST_COMPILER}
69   )
70
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)
74   
75   set(LLDB_TEST_DEBUG_TEST_CRASHES
76     0
77     CACHE BOOL "(Windows only) Enables debugging of tests in the test suite by showing the crash dialog when lldb crashes")
78
79   set(LLDB_TEST_HIDE_CONSOLE_WINDOWS
80     1
81     CACHE BOOL "(Windows only) Hides the console window for an inferior when it is launched through the test suite")
82
83   if (LLDB_TEST_DEBUG_TEST_CRASHES)
84     set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --enable-crash-dialog)
85   endif()
86
87   if (NOT LLDB_TEST_HIDE_CONSOLE_WINDOWS)
88     set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --show-inferior-console)
89   endif()
90 endif()
91
92 if(LLDB_CODESIGN_IDENTITY)
93   list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
94 endif()
95
96 if(LLDB_BUILD_FRAMEWORK)
97   list(APPEND LLDB_TEST_COMMON_ARGS --framework $<TARGET_FILE_DIR:liblldb>)
98 endif()
99
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}"
104   )
105
106 set(LLDB_DOTEST_ARGS -q;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
107
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)"
114   )