]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | # Testing rules for AddressSanitizer. |
2 | # | |
3 | # These are broken into two buckets. One set of tests directly interacts with | |
4 | # the runtime library and checks its functionality. These are the | |
5 | # no-instrumentation tests. | |
6 | # | |
7 | # Another group of tests relies upon the ability to compile the test with | |
8 | # address sanitizer instrumentation pass. These tests form "integration" tests | |
9 | # and have some elements of version skew -- they test the *host* compiler's | |
10 | # instrumentation against the just-built runtime library. | |
11 | ||
12 | include(CheckCXXCompilerFlag) | |
13 | include(CompilerRTCompile) | |
14 | ||
15 | include_directories(..) | |
16 | include_directories(../..) | |
17 | ||
18 | set(ASAN_UNITTEST_HEADERS | |
19 | asan_mac_test.h | |
20 | asan_test_config.h | |
21 | asan_test_utils.h) | |
22 | ||
23 | set(ASAN_UNITTEST_COMMON_CFLAGS | |
5bcae85e | 24 | ${COMPILER_RT_UNITTEST_CFLAGS} |
1a4d82fc JJ |
25 | ${COMPILER_RT_GTEST_CFLAGS} |
26 | -I${COMPILER_RT_SOURCE_DIR}/include | |
27 | -I${COMPILER_RT_SOURCE_DIR}/lib | |
28 | -I${COMPILER_RT_SOURCE_DIR}/lib/asan | |
29 | -I${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/tests | |
92a42be0 SL |
30 | -fno-rtti |
31 | -O2 | |
1a4d82fc JJ |
32 | -Wno-format |
33 | -Werror=sign-compare | |
92a42be0 SL |
34 | -Wno-non-virtual-dtor) |
35 | append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros ASAN_UNITTEST_COMMON_CFLAGS) | |
36 | ||
5bcae85e SL |
37 | # This will ensure the target linker is used |
38 | # during cross compilation | |
7cac9316 XL |
39 | set(ASAN_UNITTEST_COMMON_LINK_FLAGS |
40 | ${COMPILER_RT_UNITTEST_LINK_FLAGS}) | |
5bcae85e | 41 | |
92a42be0 SL |
42 | # -gline-tables-only must be enough for ASan, so use it if possible. |
43 | if(COMPILER_RT_TEST_COMPILER_ID MATCHES "Clang") | |
44 | list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -gline-tables-only) | |
45 | else() | |
46 | list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -g) | |
47 | endif() | |
5bcae85e SL |
48 | if(MSVC) |
49 | list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -gcodeview) | |
50 | endif() | |
7cac9316 | 51 | list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS -g) |
1a4d82fc JJ |
52 | |
53 | # Use -D instead of definitions to please custom compile command. | |
54 | list(APPEND ASAN_UNITTEST_COMMON_CFLAGS | |
55 | -DASAN_HAS_BLACKLIST=1 | |
56 | -DASAN_HAS_EXCEPTIONS=1 | |
1a4d82fc JJ |
57 | -DASAN_UAR=0) |
58 | ||
92a42be0 SL |
59 | if(APPLE) |
60 | list(APPEND ASAN_UNITTEST_COMMON_CFLAGS ${DARWIN_osx_CFLAGS}) | |
7cac9316 XL |
61 | list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS ${DARWIN_osx_LINK_FLAGS}) |
62 | ||
63 | add_weak_symbols("asan" WEAK_SYMBOL_LINK_FLAGS) | |
64 | add_weak_symbols("ubsan" WEAK_SYMBOL_LINK_FLAGS) | |
65 | add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS) | |
66 | list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}) | |
92a42be0 SL |
67 | endif() |
68 | ||
69 | if(MSVC) | |
70 | # Disable exceptions on Windows until they work reliably. | |
71 | list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -fno-exceptions -DGTEST_HAS_SEH=0) | |
72 | endif() | |
73 | ||
1a4d82fc JJ |
74 | set(ASAN_BLACKLIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/asan_test.ignore") |
75 | set(ASAN_UNITTEST_INSTRUMENTED_CFLAGS | |
76 | ${ASAN_UNITTEST_COMMON_CFLAGS} | |
77 | -fsanitize=address | |
78 | "-fsanitize-blacklist=${ASAN_BLACKLIST_FILE}" | |
1a4d82fc | 79 | ) |
92a42be0 SL |
80 | if(CAN_TARGET_x86_64 OR CAN_TARGET_i386) |
81 | list(APPEND ASAN_UNITTEST_INSTRUMENTED_CFLAGS -mllvm -asan-instrument-assembly) | |
82 | endif() | |
83 | ||
84 | if(NOT MSVC) | |
7cac9316 | 85 | list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS --driver-mode=g++) |
92a42be0 | 86 | endif() |
1a4d82fc | 87 | |
1a4d82fc JJ |
88 | # x86_64 FreeBSD 9.2 additionally requires libc++ to build the tests. |
89 | if(CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE") | |
7cac9316 | 90 | list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS "-lc++") |
1a4d82fc JJ |
91 | endif() |
92 | ||
93 | # Unit tests on Mac depend on Foundation. | |
94 | if(APPLE) | |
7cac9316 | 95 | list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS -framework Foundation) |
1a4d82fc JJ |
96 | endif() |
97 | if(ANDROID) | |
7cac9316 | 98 | list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS -pie) |
1a4d82fc JJ |
99 | endif() |
100 | ||
7cac9316 XL |
101 | set(ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS |
102 | ${ASAN_UNITTEST_COMMON_LINK_FLAGS}) | |
103 | list(APPEND ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS -fsanitize=address) | |
1a4d82fc | 104 | |
7cac9316 XL |
105 | set(ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS |
106 | ${ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS} | |
1a4d82fc JJ |
107 | -shared-libasan) |
108 | ||
92a42be0 SL |
109 | set(ASAN_UNITTEST_INSTRUMENTED_LIBS) |
110 | # NDK r10 requires -latomic almost always. | |
111 | append_list_if(ANDROID atomic ASAN_UNITTEST_INSTRUMENTED_LIBS) | |
112 | ||
7cac9316 XL |
113 | set(ASAN_UNITTEST_NOINST_LINK_FLAGS ${ASAN_UNITTEST_COMMON_LINK_FLAGS}) |
114 | if(NOT APPLE) | |
115 | append_list_if(COMPILER_RT_HAS_LIBM -lm ASAN_UNITTEST_NOINST_LINK_FLAGS) | |
116 | append_list_if(COMPILER_RT_HAS_LIBDL -ldl ASAN_UNITTEST_NOINST_LINK_FLAGS) | |
117 | append_list_if(COMPILER_RT_HAS_LIBRT -lrt ASAN_UNITTEST_NOINST_LINK_FLAGS) | |
118 | append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread ASAN_UNITTEST_NOINST_LINK_FLAGS) | |
119 | append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS) | |
120 | endif() | |
1a4d82fc | 121 | |
92a42be0 SL |
122 | # TODO(eugenis): move all -l flags above to _LIBS? |
123 | set(ASAN_UNITTEST_NOINST_LIBS) | |
124 | append_list_if(COMPILER_RT_HAS_LIBLOG log ASAN_UNITTEST_NOINST_LIBS) | |
125 | # NDK r10 requires -latomic almost always. | |
126 | append_list_if(ANDROID atomic ASAN_UNITTEST_NOINST_LIBS) | |
127 | ||
1a4d82fc JJ |
128 | # Compile source for the given architecture, using compiler |
129 | # options in ${ARGN}, and add it to the object list. | |
130 | macro(asan_compile obj_list source arch kind) | |
131 | get_filename_component(basename ${source} NAME) | |
5bcae85e SL |
132 | if(CMAKE_CONFIGURATION_TYPES) |
133 | set(output_obj "${CMAKE_CFG_INTDIR}/${obj_list}.${basename}.${arch}${kind}.o") | |
134 | else() | |
135 | set(output_obj "${obj_list}.${basename}.${arch}${kind}.o") | |
136 | endif() | |
1a4d82fc JJ |
137 | get_target_flags_for_arch(${arch} TARGET_CFLAGS) |
138 | set(COMPILE_DEPS ${ASAN_UNITTEST_HEADERS} ${ASAN_BLACKLIST_FILE}) | |
139 | if(NOT COMPILER_RT_STANDALONE_BUILD) | |
140 | list(APPEND COMPILE_DEPS gtest asan) | |
141 | endif() | |
142 | clang_compile(${output_obj} ${source} | |
143 | CFLAGS ${ARGN} ${TARGET_CFLAGS} | |
144 | DEPS ${COMPILE_DEPS}) | |
145 | list(APPEND ${obj_list} ${output_obj}) | |
146 | endmacro() | |
147 | ||
148 | # Link ASan unit test for a given architecture from a set | |
149 | # of objects in with given linker flags. | |
150 | macro(add_asan_test test_suite test_name arch kind) | |
7cac9316 | 151 | cmake_parse_arguments(TEST "WITH_TEST_RUNTIME" "" "OBJECTS;LINK_FLAGS;SUBDIR" ${ARGN}) |
1a4d82fc JJ |
152 | get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS) |
153 | set(TEST_DEPS ${TEST_OBJECTS}) | |
154 | if(NOT COMPILER_RT_STANDALONE_BUILD) | |
155 | list(APPEND TEST_DEPS asan) | |
156 | endif() | |
157 | if(TEST_WITH_TEST_RUNTIME) | |
158 | list(APPEND TEST_DEPS ${ASAN_TEST_RUNTIME}) | |
5bcae85e SL |
159 | if(CMAKE_CONFIGURATION_TYPES) |
160 | set(configuration_path "${CMAKE_CFG_INTDIR}/") | |
161 | else() | |
162 | set(configuration_path "") | |
163 | endif() | |
92a42be0 | 164 | if(NOT MSVC) |
5bcae85e | 165 | set(asan_test_runtime_path ${configuration_path}lib${ASAN_TEST_RUNTIME}.a) |
92a42be0 | 166 | else() |
5bcae85e | 167 | set(asan_test_runtime_path ${configuration_path}${ASAN_TEST_RUNTIME}.lib) |
92a42be0 | 168 | endif() |
5bcae85e | 169 | list(APPEND TEST_OBJECTS ${asan_test_runtime_path}) |
1a4d82fc JJ |
170 | endif() |
171 | add_compiler_rt_test(${test_suite} ${test_name} | |
92a42be0 | 172 | SUBDIR ${TEST_SUBDIR} |
1a4d82fc JJ |
173 | OBJECTS ${TEST_OBJECTS} |
174 | DEPS ${TEST_DEPS} | |
7cac9316 | 175 | LINK_FLAGS ${TEST_LINK_FLAGS} |
1a4d82fc JJ |
176 | ${TARGET_LINK_FLAGS}) |
177 | endmacro() | |
178 | ||
179 | # Main AddressSanitizer unit tests. | |
180 | add_custom_target(AsanUnitTests) | |
5bcae85e SL |
181 | set_target_properties(AsanUnitTests PROPERTIES FOLDER "Compiler-RT Tests") |
182 | ||
92a42be0 SL |
183 | # AddressSanitizer unit tests with dynamic runtime (on platforms where it's |
184 | # not the default). | |
185 | add_custom_target(AsanDynamicUnitTests) | |
5bcae85e | 186 | set_target_properties(AsanDynamicUnitTests PROPERTIES FOLDER "Compiler-RT Tests") |
1a4d82fc JJ |
187 | # ASan benchmarks (not actively used now). |
188 | add_custom_target(AsanBenchmarks) | |
5bcae85e | 189 | set_target_properties(AsanBenchmarks PROPERTIES FOLDER "Compiler-RT Tests") |
1a4d82fc JJ |
190 | |
191 | set(ASAN_NOINST_TEST_SOURCES | |
192 | ${COMPILER_RT_GTEST_SOURCE} | |
193 | asan_fake_stack_test.cc | |
194 | asan_noinst_test.cc | |
195 | asan_test_main.cc) | |
196 | ||
197 | set(ASAN_INST_TEST_SOURCES | |
198 | ${COMPILER_RT_GTEST_SOURCE} | |
199 | asan_asm_test.cc | |
200 | asan_globals_test.cc | |
201 | asan_interface_test.cc | |
7cac9316 | 202 | asan_internal_interface_test.cc |
1a4d82fc JJ |
203 | asan_test.cc |
204 | asan_oob_test.cc | |
205 | asan_mem_test.cc | |
206 | asan_str_test.cc | |
207 | asan_test_main.cc) | |
208 | if(APPLE) | |
209 | list(APPEND ASAN_INST_TEST_SOURCES asan_mac_test.cc) | |
210 | endif() | |
211 | ||
212 | set(ASAN_BENCHMARKS_SOURCES | |
213 | ${COMPILER_RT_GTEST_SOURCE} | |
214 | asan_benchmarks_test.cc) | |
215 | ||
216 | # Adds ASan unit tests and benchmarks for architecture. | |
217 | macro(add_asan_tests_for_arch_and_kind arch kind) | |
218 | # Instrumented tests. | |
219 | set(ASAN_INST_TEST_OBJECTS) | |
220 | foreach(src ${ASAN_INST_TEST_SOURCES}) | |
221 | asan_compile(ASAN_INST_TEST_OBJECTS ${src} ${arch} ${kind} | |
222 | ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN}) | |
223 | endforeach() | |
224 | if (APPLE) | |
225 | # Add Mac-specific helper. | |
226 | asan_compile(ASAN_INST_TEST_OBJECTS asan_mac_test_helpers.mm ${arch} ${kind} | |
227 | ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -ObjC ${ARGN}) | |
228 | endif() | |
5bcae85e | 229 | |
7cac9316 XL |
230 | if (MSVC) |
231 | # With the MSVC CRT, the choice between static and dynamic CRT is made at | |
232 | # compile time with a macro. Simulate the effect of passing /MD to clang-cl. | |
233 | set(ASAN_INST_DYNAMIC_TEST_OBJECTS) | |
234 | foreach(src ${ASAN_INST_TEST_SOURCES}) | |
235 | asan_compile(ASAN_INST_DYNAMIC_TEST_OBJECTS ${src} ${arch} ${kind} | |
236 | ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -D_MT -D_DLL ${ARGN}) | |
237 | endforeach() | |
238 | # Clang links the static CRT by default. Override that to use the dynamic | |
239 | # CRT. | |
240 | set(ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS | |
241 | ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS} | |
242 | -Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames) | |
243 | else() | |
244 | set(ASAN_INST_DYNAMIC_TEST_OBJECTS ${ASAN_INST_TEST_OBJECTS}) | |
245 | endif() | |
246 | ||
5bcae85e SL |
247 | # Create the 'default' folder where ASAN tests are produced. |
248 | if(CMAKE_CONFIGURATION_TYPES) | |
249 | foreach(build_mode ${CMAKE_CONFIGURATION_TYPES}) | |
250 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/default/${build_mode}") | |
251 | endforeach() | |
252 | else() | |
253 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/default") | |
254 | endif() | |
255 | ||
92a42be0 SL |
256 | add_asan_test(AsanUnitTests "Asan-${arch}${kind}-Test" |
257 | ${arch} ${kind} SUBDIR "default" | |
1a4d82fc | 258 | OBJECTS ${ASAN_INST_TEST_OBJECTS} |
7cac9316 | 259 | LINK_FLAGS ${ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS}) |
92a42be0 | 260 | if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME) |
5bcae85e SL |
261 | # Create the 'dynamic' folder where ASAN tests are produced. |
262 | if(CMAKE_CONFIGURATION_TYPES) | |
263 | foreach(build_mode ${CMAKE_CONFIGURATION_TYPES}) | |
264 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynamic/${build_mode}") | |
265 | endforeach() | |
266 | else() | |
267 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynamic") | |
268 | endif() | |
269 | ||
92a42be0 SL |
270 | add_asan_test(AsanDynamicUnitTests "Asan-${arch}${kind}-Dynamic-Test" |
271 | ${arch} ${kind} SUBDIR "dynamic" | |
7cac9316 XL |
272 | OBJECTS ${ASAN_INST_DYNAMIC_TEST_OBJECTS} |
273 | LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}) | |
1a4d82fc JJ |
274 | endif() |
275 | ||
276 | # Add static ASan runtime that will be linked with uninstrumented tests. | |
277 | set(ASAN_TEST_RUNTIME RTAsanTest.${arch}${kind}) | |
278 | if(APPLE) | |
279 | set(ASAN_TEST_RUNTIME_OBJECTS | |
92a42be0 | 280 | $<TARGET_OBJECTS:RTAsan_dynamic.osx> |
1a4d82fc JJ |
281 | $<TARGET_OBJECTS:RTInterception.osx> |
282 | $<TARGET_OBJECTS:RTSanitizerCommon.osx> | |
92a42be0 SL |
283 | $<TARGET_OBJECTS:RTSanitizerCommonLibc.osx> |
284 | $<TARGET_OBJECTS:RTLSanCommon.osx> | |
285 | $<TARGET_OBJECTS:RTUbsan.osx>) | |
1a4d82fc JJ |
286 | else() |
287 | set(ASAN_TEST_RUNTIME_OBJECTS | |
288 | $<TARGET_OBJECTS:RTAsan.${arch}> | |
92a42be0 | 289 | $<TARGET_OBJECTS:RTAsan_cxx.${arch}> |
1a4d82fc | 290 | $<TARGET_OBJECTS:RTInterception.${arch}> |
1a4d82fc | 291 | $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> |
92a42be0 SL |
292 | $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> |
293 | $<TARGET_OBJECTS:RTLSanCommon.${arch}> | |
294 | $<TARGET_OBJECTS:RTUbsan.${arch}> | |
295 | $<TARGET_OBJECTS:RTUbsan_cxx.${arch}>) | |
1a4d82fc JJ |
296 | endif() |
297 | add_library(${ASAN_TEST_RUNTIME} STATIC ${ASAN_TEST_RUNTIME_OBJECTS}) | |
298 | set_target_properties(${ASAN_TEST_RUNTIME} PROPERTIES | |
5bcae85e SL |
299 | ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
300 | FOLDER "Compiler-RT Runtime tests") | |
1a4d82fc JJ |
301 | # Uninstrumented tests. |
302 | set(ASAN_NOINST_TEST_OBJECTS) | |
303 | foreach(src ${ASAN_NOINST_TEST_SOURCES}) | |
304 | asan_compile(ASAN_NOINST_TEST_OBJECTS ${src} ${arch} ${kind} | |
305 | ${ASAN_UNITTEST_COMMON_CFLAGS} ${ARGN}) | |
306 | endforeach() | |
92a42be0 SL |
307 | add_asan_test(AsanUnitTests "Asan-${arch}${kind}-Noinst-Test" |
308 | ${arch} ${kind} SUBDIR "default" | |
1a4d82fc | 309 | OBJECTS ${ASAN_NOINST_TEST_OBJECTS} |
7cac9316 | 310 | LINK_FLAGS ${ASAN_UNITTEST_NOINST_LINK_FLAGS} |
1a4d82fc JJ |
311 | WITH_TEST_RUNTIME) |
312 | ||
313 | # Benchmarks. | |
314 | set(ASAN_BENCHMARKS_OBJECTS) | |
315 | foreach(src ${ASAN_BENCHMARKS_SOURCES}) | |
316 | asan_compile(ASAN_BENCHMARKS_OBJECTS ${src} ${arch} ${kind} | |
317 | ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN}) | |
318 | endforeach() | |
92a42be0 SL |
319 | add_asan_test(AsanBenchmarks "Asan-${arch}${kind}-Benchmark" |
320 | ${arch} ${kind} SUBDIR "default" | |
1a4d82fc | 321 | OBJECTS ${ASAN_BENCHMARKS_OBJECTS} |
7cac9316 | 322 | LINK_FLAGS ${ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS}) |
1a4d82fc JJ |
323 | endmacro() |
324 | ||
92a42be0 SL |
325 | if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT ANDROID) |
326 | set(ASAN_TEST_ARCH ${ASAN_SUPPORTED_ARCH}) | |
327 | if(APPLE) | |
328 | darwin_filter_host_archs(ASAN_SUPPORTED_ARCH ASAN_TEST_ARCH) | |
329 | endif() | |
330 | foreach(arch ${ASAN_TEST_ARCH}) | |
1a4d82fc JJ |
331 | add_asan_tests_for_arch_and_kind(${arch} "-inline") |
332 | add_asan_tests_for_arch_and_kind(${arch} "-with-calls" | |
333 | -mllvm -asan-instrumentation-with-call-threshold=0) | |
334 | endforeach() | |
335 | endif() | |
336 | ||
337 | if(ANDROID) | |
92a42be0 SL |
338 | foreach(arch ${ASAN_SUPPORTED_ARCH}) |
339 | # Test w/o ASan instrumentation. Link it with ASan statically. | |
340 | add_executable(AsanNoinstTest # FIXME: .arch? | |
341 | $<TARGET_OBJECTS:RTAsan.${arch}> | |
342 | $<TARGET_OBJECTS:RTInterception.${arch}> | |
343 | $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> | |
344 | $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> | |
345 | $<TARGET_OBJECTS:RTUbsan.${arch}> | |
346 | $<TARGET_OBJECTS:RTUbsan_cxx.${arch}> | |
347 | ${COMPILER_RT_GTEST_SOURCE} | |
348 | ${ASAN_NOINST_TEST_SOURCES}) | |
349 | set_target_compile_flags(AsanNoinstTest ${ASAN_UNITTEST_COMMON_CFLAGS}) | |
7cac9316 | 350 | set_target_link_flags(AsanNoinstTest ${ASAN_UNITTEST_NOINST_LINK_FLAGS}) |
92a42be0 | 351 | target_link_libraries(AsanNoinstTest ${ASAN_UNITTEST_NOINST_LIBS}) |
1a4d82fc | 352 | |
92a42be0 SL |
353 | # Test with ASan instrumentation. Link with ASan dynamic runtime. |
354 | add_executable(AsanTest | |
355 | ${COMPILER_RT_GTEST_SOURCE} | |
356 | ${ASAN_INST_TEST_SOURCES}) | |
357 | set_target_compile_flags(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS}) | |
7cac9316 | 358 | set_target_link_flags(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS}) |
92a42be0 | 359 | target_link_libraries(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_LIBS}) |
1a4d82fc | 360 | |
92a42be0 SL |
361 | # Setup correct output directory and link flags. |
362 | set_target_properties(AsanNoinstTest AsanTest PROPERTIES | |
363 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | |
364 | # Add unit tests to the test suite. | |
365 | add_dependencies(AsanUnitTests AsanNoinstTest AsanTest) | |
366 | endforeach() | |
1a4d82fc | 367 | endif() |