1 | # Test runner infrastructure for Clang. This configures the Clang test trees |
2 | # for use by Lit, and delegates to LLVM's lit test handlers. |
3 | |
4 | if (CMAKE_CFG_INTDIR STREQUAL ".") |
5 | set(LLVM_BUILD_MODE ".") |
6 | else () |
7 | set(LLVM_BUILD_MODE "%(build_mode)s") |
8 | endif () |
9 | |
10 | string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) |
11 | |
12 | if(CLANG_BUILT_STANDALONE) |
13 | # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This |
14 | # value is forced to 0 if zlib was not found, so it is fine to use it |
15 | # instead of HAVE_LIBZ (not recorded). |
16 | if(LLVM_ENABLE_ZLIB) |
17 | set(HAVE_LIBZ 1) |
18 | endif() |
19 | endif() |
20 | |
21 | llvm_canonicalize_cmake_booleans( |
22 | CLANG_BUILD_EXAMPLES |
23 | CLANG_ENABLE_ARCMT |
24 | CLANG_ENABLE_STATIC_ANALYZER |
25 | ENABLE_BACKTRACES |
26 | HAVE_LIBZ |
27 | LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) |
28 | |
29 | configure_lit_site_cfg( |
30 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in |
31 | ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py |
32 | MAIN_CONFIG |
33 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py |
34 | ) |
35 | |
36 | configure_lit_site_cfg( |
37 | ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in |
38 | ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py |
39 | MAIN_CONFIG |
40 | ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py |
41 | ) |
42 | |
43 | option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) |
44 | if(CLANG_TEST_USE_VG) |
45 | set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") |
46 | endif () |
47 | |
48 | list(APPEND CLANG_TEST_DEPS |
49 | clang clang-resource-headers |
50 | clang-format |
51 | c-index-test diagtool |
52 | clang-tblgen |
53 | clang-offload-bundler |
54 | clang-import-test |
55 | clang-rename |
56 | clang-refactor |
57 | clang-diff |
58 | hmaptool |
59 | ) |
60 | |
61 | if(CLANG_ENABLE_STATIC_ANALYZER) |
62 | list(APPEND CLANG_TEST_DEPS |
63 | clang-check |
64 | clang-extdef-mapping |
65 | ) |
66 | endif() |
67 | |
68 | if (CLANG_ENABLE_ARCMT) |
69 | list(APPEND CLANG_TEST_DEPS |
70 | arcmt-test |
71 | c-arcmt-test |
72 | ) |
73 | endif () |
74 | |
75 | if (CLANG_BUILD_EXAMPLES) |
76 | list(APPEND CLANG_TEST_DEPS |
77 | AnnotateFunctions |
78 | clang-interpreter |
79 | PrintFunctionNames |
80 | ) |
81 | endif () |
82 | |
83 | if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES) |
84 | list(APPEND CLANG_TEST_DEPS |
85 | SampleAnalyzerPlugin |
86 | ) |
87 | endif () |
88 | |
89 | set(CLANG_TEST_PARAMS |
90 | clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg |
91 | USE_Z3_SOLVER=0 |
92 | ) |
93 | |
94 | set(ANALYZER_TEST_PARAMS |
95 | USE_Z3_SOLVER=0) |
96 | |
97 | set(ANALYZER_TEST_PARAMS_Z3 |
98 | USE_Z3_SOLVER=1) |
99 | |
100 | if( NOT CLANG_BUILT_STANDALONE ) |
101 | list(APPEND CLANG_TEST_DEPS |
102 | llvm-config |
103 | FileCheck count not |
104 | llc |
105 | llvm-as |
106 | llvm-bcanalyzer |
107 | llvm-cat |
108 | llvm-dis |
109 | llvm-lto2 |
110 | llvm-modextract |
111 | llvm-nm |
112 | llvm-objdump |
113 | llvm-profdata |
114 | llvm-readobj |
115 | llvm-symbolizer |
116 | opt |
117 | ) |
118 | |
119 | if(TARGET llvm-lto) |
120 | list(APPEND CLANG_TEST_DEPS llvm-lto) |
121 | endif() |
122 | endif() |
123 | |
124 | add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS}) |
125 | set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests") |
126 | |
127 | add_lit_testsuite(check-clang "Running the Clang regression tests" |
128 | ${CMAKE_CURRENT_BINARY_DIR} |
129 | #LIT ${LLVM_LIT} |
130 | PARAMS ${CLANG_TEST_PARAMS} |
131 | DEPENDS ${CLANG_TEST_DEPS} |
132 | ARGS ${CLANG_TEST_EXTRA_ARGS} |
133 | ) |
134 | set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") |
135 | |
136 | if (CLANG_ENABLE_STATIC_ANALYZER) |
137 | # check-all would launch those tests via check-clang. |
138 | set(EXCLUDE_FROM_ALL ON) |
139 | |
140 | add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests" |
141 | ${CMAKE_CURRENT_BINARY_DIR}/Analysis |
142 | PARAMS ${ANALYZER_TEST_PARAMS} |
143 | DEPENDS ${CLANG_TEST_DEPS}) |
144 | set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests") |
145 | |
146 | |
147 | if (LLVM_WITH_Z3) |
148 | add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer tests, using Z3 as a solver" |
149 | ${CMAKE_CURRENT_BINARY_DIR}/Analysis |
150 | PARAMS ${ANALYZER_TEST_PARAMS_Z3} |
151 | DEPENDS ${CLANG_TEST_DEPS}) |
152 | set_target_properties(check-clang-analyzer-z3 PROPERTIES FOLDER "Clang tests") |
153 | endif() |
154 | |
155 | set(EXCLUDE_FROM_ALL OFF) |
156 | endif() |
157 | |
158 | add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR} |
159 | PARAMS ${CLANG_TEST_PARAMS} |
160 | DEPENDS ${CLANG_TEST_DEPS} |
161 | ) |
162 | |
163 | # Add a legacy target spelling: clang-test |
164 | add_custom_target(clang-test) |
165 | add_dependencies(clang-test check-clang) |
166 | set_target_properties(clang-test PROPERTIES FOLDER "Clang tests") |
167 | |
168 | # FIXME: This logic can be removed once all buildbots have moved |
169 | # debuginfo-test from clang/test to llvm/projects or monorepo. |
170 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests) |
171 | message(WARNING "Including debuginfo-tests in clang/test is deprecated. Move to llvm/projects or use monorepo.") |
172 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt) |
173 | add_subdirectory(debuginfo-tests) |
174 | endif() |
175 | endif() |
176 | |