blob: cb275a266f5ca852b29892dc1b20ca88b901840d [file] [log] [blame]
Colin Cross2722ebb2016-07-11 16:20:06 -07001//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "bionic_tests_defaults",
19 host_supported: true,
Tom Cherry60ddedf2018-02-20 15:40:02 -080020 cpp_std: "experimental",
Colin Cross2722ebb2016-07-11 16:20:06 -070021 target: {
22 darwin: {
23 enabled: false,
24 },
25 },
26 cflags: [
27 "-fstack-protector-all",
28 "-g",
29 "-Wall",
30 "-Wextra",
31 "-Wunused",
32 "-Werror",
33 "-fno-builtin",
34
35 // We want to test deprecated API too.
36 "-Wno-deprecated-declarations",
37
38 // For glibc.
39 "-D__STDC_LIMIT_MACROS",
40 ],
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080041 header_libs: ["bionic_libc_platform_headers"],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080042 // Make the bionic tests implicitly test bionic's shadow call stack support.
43 arch: {
44 arm64: {
45 cflags: ["-fsanitize=shadow-call-stack"],
46 },
47 },
Colin Cross2722ebb2016-07-11 16:20:06 -070048 stl: "libc++",
49 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080050 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070051 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090052 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080053
54 product_variables: {
55 experimental_mte: {
56 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
57 },
58 },
Colin Cross2722ebb2016-07-11 16:20:06 -070059}
60
61// -----------------------------------------------------------------------------
62// All standard tests.
63// -----------------------------------------------------------------------------
64
George Burgess IVde45dcb2018-03-16 14:15:01 -070065// Test diagnostics emitted by clang. The library that results is useless; we
66// just want to run '-Xclang -verify', which will fail if the diagnostics don't
67// match up with what the source file says they should be.
68cc_test_library {
69 name: "clang_diagnostic_tests",
70 cflags: [
71 "-Xclang",
72 "-verify",
73 ],
74 srcs: ["sys_ioctl_diag_test.cpp"],
75}
76
Colin Cross2722ebb2016-07-11 16:20:06 -070077cc_test_library {
78 name: "libBionicStandardTests",
79 defaults: ["bionic_tests_defaults"],
80 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080081 "__aeabi_read_tp_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030082 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070083 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070084 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070085 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070086 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070087 "buffer_tests.cpp",
88 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030089 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070090 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070091 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070092 "ctype_test.cpp",
93 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -070094 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080095 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -070096 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070097 "error_test.cpp",
98 "eventfd_test.cpp",
99 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700100 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800101 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700102 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800103 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700104 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700105 "ftw_test.cpp",
106 "getauxval_test.cpp",
107 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700108 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700109 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800110 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700111 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700112 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800113 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700114 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700115 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800116 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700117 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700118 "libgen_basename_test.cpp",
119 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700120 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700121 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700122 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700123 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700124 "malloc_test.cpp",
125 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700126 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100127 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800129 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700130 "netdb_test.cpp",
131 "net_if_test.cpp",
132 "netinet_ether_test.cpp",
133 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700134 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700135 "netinet_udp_test.cpp",
136 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700137 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700138 "pthread_test.cpp",
139 "pty_test.cpp",
140 "regex_test.cpp",
141 "resolv_test.cpp",
142 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800143 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700144 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700145 "search_test.cpp",
146 "semaphore_test.cpp",
147 "setjmp_test.cpp",
148 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700149 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700150 "stack_protector_test.cpp",
151 "stack_protector_test_helper.cpp",
152 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700153 "stdalign_test.cpp",
154 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700156 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700157 "stdint_test.cpp",
158 "stdio_nofortify_test.cpp",
159 "stdio_test.cpp",
160 "stdio_ext_test.cpp",
161 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700162 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700163 "string_nofortify_test.cpp",
164 "string_test.cpp",
165 "string_posix_strerror_r_test.cpp",
166 "strings_nofortify_test.cpp",
167 "strings_test.cpp",
168 "sstream_test.cpp",
169 "sys_epoll_test.cpp",
170 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700171 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700172 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700173 "sys_personality_test.cpp",
174 "sys_prctl_test.cpp",
175 "sys_procfs_test.cpp",
176 "sys_ptrace_test.cpp",
177 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700178 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700179 "sys_resource_test.cpp",
180 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700181 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700182 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700183 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800184 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700185 "sys_socket_test.cpp",
186 "sys_stat_test.cpp",
187 "sys_statvfs_test.cpp",
188 "sys_syscall_test.cpp",
189 "sys_sysinfo_test.cpp",
190 "sys_sysmacros_test.cpp",
191 "sys_time_test.cpp",
192 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700193 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700194 "sys_types_test.cpp",
195 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700196 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700197 "sys_vfs_test.cpp",
198 "sys_xattr_test.cpp",
199 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000200 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800201 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700202 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700203 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700204 "time_test.cpp",
205 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700206 "unistd_nofortify_test.cpp",
207 "unistd_test.cpp",
208 "utmp_test.cpp",
209 "wchar_test.cpp",
210 "wctype_test.cpp",
211 ],
212
213 include_dirs: [
214 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700215 ],
216
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700217 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700218 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800219 whole_static_libs: [
220 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700221 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800222 "libsystemproperties",
223 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800224 srcs: [
225 "tagged_pointers_test.cpp",
226 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700227 },
228 },
229
Dan Willemsen41567702016-08-31 16:35:01 -0700230 static_libs: [
231 "libtinyxml2",
232 "liblog",
233 "libbase",
234 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700235 shared: {
236 enabled: false,
237 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000238
239 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700240}
241
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800242cc_test_library {
243 name: "libBionicElfTlsTests",
244 defaults: ["bionic_tests_defaults"],
245 srcs: [
246 "elftls_test.cpp",
247 ],
248 include_dirs: [
249 "bionic/libc",
250 ],
251 shared: {
252 enabled: false,
253 },
254 cflags: [
255 "-fno-emulated-tls",
256 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700257 // With fuzzer builds, compiler instrumentation generates a reference to the
258 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
259 // library as an emutls symbol. The -fno-emulated-tls flag above configures
260 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
261 // symbol instead, which isn't defined. Disable the fuzzer for this test
262 // until the platform is switched to ELF TLS.
263 sanitize: {
264 fuzzer: false,
265 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800266}
267
268cc_test_library {
269 name: "libBionicElfTlsLoaderTests",
270 defaults: ["bionic_tests_defaults"],
271 srcs: [
272 "elftls_dl_test.cpp",
273 ],
274 include_dirs: [
275 "bionic/libc",
276 ],
277 static_libs: [
278 "liblog",
279 "libbase",
280 ],
281 shared: {
282 enabled: false,
283 },
284 cflags: [
285 "-fno-emulated-tls",
286 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700287 // With fuzzer builds, compiler instrumentation generates a reference to the
288 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
289 // library as an emutls symbol. The -fno-emulated-tls flag above configures
290 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
291 // symbol instead, which isn't defined. Disable the fuzzer for this test
292 // until the platform is switched to ELF TLS.
293 sanitize: {
294 fuzzer: false,
295 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800296}
297
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800298cc_test_library {
299 name: "libBionicFramePointerTests",
300 defaults: ["bionic_tests_defaults"],
301 srcs: [
302 "android_unsafe_frame_pointer_chase_test.cpp",
303 ],
304 include_dirs: [
305 "bionic/libc",
306 ],
307 cflags: [
308 "-fno-omit-frame-pointer",
309 ],
310}
311
Colin Cross2722ebb2016-07-11 16:20:06 -0700312// -----------------------------------------------------------------------------
313// Fortify tests.
314// -----------------------------------------------------------------------------
315
316cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700317 name: "bionic_clang_fortify_tests_w_flags",
318 cflags: [
319 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700320 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700321 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700322 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700323 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700324 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700325 "-Wno-strncat-size",
326 ],
327}
328
329cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700330 name: "bionic_fortify_tests_defaults",
331 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700332 "-U_FORTIFY_SOURCE",
333 ],
334 srcs: ["fortify_test_main.cpp"],
335 target: {
336 host: {
337 clang_cflags: ["-D__clang__"],
338 },
339 },
340}
341
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700342// Ensures that FORTIFY checks aren't run when ASAN is on.
343cc_test {
344 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700345 defaults: [
346 "bionic_clang_fortify_tests_w_flags",
347 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700348 cflags: [
349 "-Werror",
350 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700351 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700352 sanitize: {
353 address: true,
354 },
355 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700356}
357
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700358// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
359// it can confuse these tools pretty easily. If this builds successfully, then
360// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
361// enabled. The library that results from building this is meant to be unused.
362cc_test_library {
363 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700364 defaults: [
365 "bionic_clang_fortify_tests_w_flags",
366 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700367 cflags: [
368 "-Werror",
369 "-D_FORTIFY_SOURCE=2",
370 "-D__clang_analyzer__",
371 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700372 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700373}
374
Colin Cross2722ebb2016-07-11 16:20:06 -0700375cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700376 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800377 defaults: [
378 "bionic_fortify_tests_defaults",
379 "bionic_tests_defaults",
380 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700381 cflags: [
382 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800383 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700384 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700385 shared: {
386 enabled: false,
387 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700388}
389
390cc_test_library {
391 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800392 defaults: [
393 "bionic_fortify_tests_defaults",
394 "bionic_tests_defaults",
395 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700396 cflags: [
397 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800398 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700399 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700400 shared: {
401 enabled: false,
402 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700403}
404
George Burgess IV9a274102019-06-04 15:39:52 -0700405cc_defaults {
406 name: "bionic_new_fortify_tests_defaults",
407 defaults: [
408 "bionic_clang_fortify_tests_w_flags",
409 ],
410 cflags: [
411 "-U_FORTIFY_SOURCE",
412 ],
413 srcs: ["clang_fortify_tests.cpp"],
414 target: {
415 host: {
416 clang_cflags: ["-D__clang__"],
417 },
418 },
419}
420
421cc_test_library {
422 name: "libfortify1-new-tests-clang",
423 defaults: [
424 "bionic_new_fortify_tests_defaults",
425 "bionic_tests_defaults",
426 ],
427 cflags: [
428 "-D_FORTIFY_SOURCE=1",
429 "-DTEST_NAME=Fortify1_clang_new",
430 ],
431 shared: {
432 enabled: false,
433 },
434}
435
436cc_test_library {
437 name: "libfortify2-new-tests-clang",
438 defaults: [
439 "bionic_new_fortify_tests_defaults",
440 "bionic_tests_defaults",
441 ],
442 cflags: [
443 "-D_FORTIFY_SOURCE=2",
444 "-DTEST_NAME=Fortify2_clang_new",
445 ],
446 shared: {
447 enabled: false,
448 },
449}
450
451
Colin Cross2722ebb2016-07-11 16:20:06 -0700452// -----------------------------------------------------------------------------
453// Library of all tests (excluding the dynamic linker tests).
454// -----------------------------------------------------------------------------
455cc_test_library {
456 name: "libBionicTests",
457 defaults: ["bionic_tests_defaults"],
458 whole_static_libs: [
459 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800460 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800461 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700462 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700463 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700464 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700465 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700466 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700467 shared: {
468 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700469 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700470}
471
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700472cc_test_library {
473 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800474 defaults: [
475 "bionic_tests_defaults",
476 "llvm-defaults",
477 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700478 srcs: [
479 "atexit_test.cpp",
480 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700481 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700482 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700483 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700484 "pthread_dlfcn_test.cpp",
485 ],
486 static_libs: [
487 "libbase",
488 ],
489 include_dirs: [
490 "bionic/libc",
491 ],
492 shared: {
493 enabled: false,
494 },
495 target: {
496 android: {
497 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700498 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700499 "dlext_test.cpp",
500 "libdl_test.cpp",
501 ],
502 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800503 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400504 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700505 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800506 "libLLVMObject",
507 "libLLVMBitReader",
508 "libLLVMMC",
509 "libLLVMMCParser",
510 "libLLVMCore",
511 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700512 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800513 },
Jiyong Park02586a22017-05-20 01:01:24 +0900514 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700515}
516
Colin Cross2722ebb2016-07-11 16:20:06 -0700517// -----------------------------------------------------------------------------
518// Library of bionic customized gtest main function, with normal gtest output format,
519// which is needed by bionic cts test.
520// -----------------------------------------------------------------------------
521cc_test_library {
522 name: "libBionicCtsGtestMain",
523 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700524 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700525 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700526 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700527 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700528 shared: {
529 enabled: false,
530 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700531 whole_static_libs: [
532 "libgtest_isolated",
533 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700534}
535
536// -----------------------------------------------------------------------------
537// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900538// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
539// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700540// -----------------------------------------------------------------------------
541cc_defaults {
542 name: "bionic_unit_tests_defaults",
543 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800544 gtest: false,
545
546 defaults: [
547 "bionic_tests_defaults",
548 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700549
550 whole_static_libs: [
551 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700552 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800553 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700554 ],
555
556 static_libs: [
557 "libtinyxml2",
558 "liblog",
559 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800560 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700561 ],
562
563 srcs: [
564 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700565 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700566 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800567 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700568 "thread_local_test.cpp",
569 ],
570
571 conlyflags: [
572 "-fexceptions",
573 "-fnon-call-exceptions",
574 ],
575
576 ldflags: ["-Wl,--export-dynamic"],
577
578 include_dirs: ["bionic/libc"],
579
Yabin Cui1f553ea2017-01-13 12:31:59 -0800580 stl: "libc++_static",
581
Colin Cross2722ebb2016-07-11 16:20:06 -0700582 target: {
583 android: {
584 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100585 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700586 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100587 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700588 "libdl_preempt_test_1",
589 "libdl_preempt_test_2",
590 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800591 "libtest_elftls_shared_var",
592 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700593 ],
594 static_libs: [
595 // The order of these libraries matters, do not shuffle them.
596 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800597 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700598 "libziparchive",
599 "libz",
600 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800601 "libLLVMObject",
602 "libLLVMBitReader",
603 "libLLVMMC",
604 "libLLVMMCParser",
605 "libLLVMCore",
606 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700607 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700608 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700609 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700610 "-Wl,--enable-new-dtags",
611 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700612 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800613 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700614
615 required: [
616 "cfi_test_helper",
617 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800618 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700619 "exec_linker_helper",
620 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700621 "libtest_dt_runpath_a",
622 "libtest_dt_runpath_b",
623 "libtest_dt_runpath_c",
624 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900625 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700626 "libatest_simple_zip",
627 "libcfi-test",
628 "libcfi-test-bad",
629 "libdlext_test_different_soname",
630 "libdlext_test_fd",
631 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400632 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700633 "libdlext_test_runpath_zip_zipaligned",
634 "libdlext_test",
635 "libdlext_test_zip",
636 "libdlext_test_zip_zipaligned",
637 "libdl_preempt_test_1",
638 "libdl_preempt_test_2",
639 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700640 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800641 "librelocations-ANDROID_RELR",
642 "librelocations-ANDROID_REL",
643 "librelocations-RELR",
644 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700645 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700646 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700647 "libtest_atexit",
648 "libtest_check_order_dlsym_1_left",
649 "libtest_check_order_dlsym_2_right",
650 "libtest_check_order_dlsym_3_c",
651 "libtest_check_order_dlsym_a",
652 "libtest_check_order_dlsym_b",
653 "libtest_check_order_dlsym_d",
654 "libtest_check_order_dlsym",
655 "libtest_check_order_reloc_root_1",
656 "libtest_check_order_reloc_root_2",
657 "libtest_check_order_reloc_root",
658 "libtest_check_order_reloc_siblings_1",
659 "libtest_check_order_reloc_siblings_2",
660 "libtest_check_order_reloc_siblings_3",
661 "libtest_check_order_reloc_siblings_a",
662 "libtest_check_order_reloc_siblings_b",
663 "libtest_check_order_reloc_siblings_c_1",
664 "libtest_check_order_reloc_siblings_c_2",
665 "libtest_check_order_reloc_siblings_c",
666 "libtest_check_order_reloc_siblings_d",
667 "libtest_check_order_reloc_siblings_e",
668 "libtest_check_order_reloc_siblings_f",
669 "libtest_check_order_reloc_siblings",
670 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700671 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700672 "libtest_dlopen_from_ctor_main",
673 "libtest_dlopen_from_ctor",
674 "libtest_dlopen_weak_undefined_func",
675 "libtest_dlsym_df_1_global",
676 "libtest_dlsym_from_this_child",
677 "libtest_dlsym_from_this_grandchild",
678 "libtest_dlsym_from_this",
679 "libtest_dlsym_weak_func",
680 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800681 "libtest_elftls_dynamic",
682 "libtest_elftls_dynamic_filler_1",
683 "libtest_elftls_dynamic_filler_2",
684 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800685 "libtest_elftls_shared_var",
686 "libtest_elftls_shared_var_ie",
687 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700688 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700689 "libtest_ifunc_variable_impl",
690 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700691 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700692 "libtest_init_fini_order_child",
693 "libtest_init_fini_order_grand_child",
694 "libtest_init_fini_order_root2",
695 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700696 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700697 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700698 "libtest_missing_symbol_root",
699 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700700 "libtest_nodelete_1",
701 "libtest_nodelete_2",
702 "libtest_nodelete_dt_flags_1",
703 "libtest_pthread_atfork",
704 "libtest_relo_check_dt_needed_order_1",
705 "libtest_relo_check_dt_needed_order_2",
706 "libtest_relo_check_dt_needed_order",
707 "libtest_simple",
708 "libtest_two_parents_child",
709 "libtest_two_parents_parent1",
710 "libtest_two_parents_parent2",
711 "libtest_versioned_lib",
712 "libtest_versioned_libv1",
713 "libtest_versioned_libv2",
714 "libtest_versioned_otherlib_empty",
715 "libtest_versioned_otherlib",
716 "libtest_versioned_uselibv1",
717 "libtest_versioned_uselibv2_other",
718 "libtest_versioned_uselibv2",
719 "libtest_versioned_uselibv3_other",
720 "libtest_with_dependency_loop_a",
721 "libtest_with_dependency_loop_b",
722 "libtest_with_dependency_loop_c",
723 "libtest_with_dependency_loop",
724 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200725 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700726 "libtest_invalid-empty_shdr_table.so",
727 "libtest_invalid-rw_load_segment.so",
728 "libtest_invalid-unaligned_shdr_offset.so",
729 "libtest_invalid-zero_shdr_table_content.so",
730 "libtest_invalid-zero_shdr_table_offset.so",
731 "libtest_invalid-zero_shentsize.so",
732 "libtest_invalid-zero_shstrndx.so",
733 "libtest_invalid-textrels.so",
734 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700735 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200736 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700737 "preinit_getauxval_test_helper",
738 "preinit_syscall_test_helper",
739 "libnstest_private_external",
740 "libnstest_dlopened",
741 "libnstest_private",
742 "libnstest_root_not_isolated",
743 "libnstest_root",
744 "libnstest_public",
745 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800746 "libnstest_ns_a_public1",
747 "libnstest_ns_a_public1_internal",
748 "libnstest_ns_b_public2",
749 "libnstest_ns_b_public3",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800750 "libsegment_gap_inner",
751 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900752 "ld_preload_test_helper",
753 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700754 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900755 "ld_config_test_helper",
756 "ld_config_test_helper_lib1",
757 "ld_config_test_helper_lib2",
758 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700759 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700760}
761
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800762cc_test {
763 name: "bionic-unit-tests",
764 defaults: [
765 "bionic_unit_tests_defaults",
766 ],
767}
768
769cc_test {
770 name: "bionic-unit-tests-scudo",
771 defaults: [
772 "bionic_unit_tests_defaults",
773 ],
774
775 shared_libs: [
776 "libc_scudo",
777 ],
778}
779
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700780cc_test {
781 name: "bionic-stress-tests",
782 defaults: [
783 "bionic_tests_defaults",
784 ],
785
786 // For now, these tests run forever, so do not use the isolation framework.
787 isolated: false,
788
789 srcs: [
790 "malloc_stress_test.cpp",
791 ],
792
793 shared_libs: [
794 "libbase",
795 ],
796
797 target: {
798 android: {
799 static_libs: [
800 "libmeminfo",
801 "libprocinfo",
802 ],
803 },
804 },
805}
806
Colin Cross2722ebb2016-07-11 16:20:06 -0700807// -----------------------------------------------------------------------------
808// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900809// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
810// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700811// -----------------------------------------------------------------------------
812cc_test {
813 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700814 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700815 defaults: ["bionic_tests_defaults"],
816 host_supported: false,
817
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800818 srcs: [
819 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700820 "gtest_globals.cpp",
821 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800822
823 // The Bionic allocator has its own C++ API. It isn't packaged into its
824 // own library, so it can only be tested when it's part of libc.a.
825 "bionic_allocator_test.cpp",
826 ],
827 include_dirs: [
828 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800829 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700830 whole_static_libs: [
831 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700832 ],
833
834 static_libs: [
835 "libm",
836 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700837 "libdl",
838 "libtinyxml2",
839 "liblog",
840 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700841 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700842 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800843 "libtest_elftls_shared_var",
844 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700845 ],
846
847 static_executable: true,
848 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700849}
850
851// -----------------------------------------------------------------------------
852// Tests to run on the host and linked against glibc. Run with:
853// cd bionic/tests; mm bionic-unit-tests-glibc-run
854// -----------------------------------------------------------------------------
855
856cc_test_host {
857 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700858 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700859 defaults: ["bionic_tests_defaults"],
860
861 srcs: [
862 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700863 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700864 "dlfcn_test.cpp",
865 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700866 "gtest_globals.cpp",
867 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700868 "pthread_dlfcn_test.cpp",
869 ],
870
871 shared_libs: [
872 "libdl_preempt_test_1",
873 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700874 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800875 "libtest_elftls_shared_var",
876 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700877 ],
878
879 whole_static_libs: [
880 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800881 "libBionicElfTlsTests",
882 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700883 "libfortify1-tests-clang",
884 "libfortify2-tests-clang",
885 ],
886
887 static_libs: [
888 "libbase",
889 "liblog",
890 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700891 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700892 ],
893
894 host_ldlibs: [
895 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700896 "-lutil",
897 ],
898
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700899 include_dirs: [
900 "bionic/libc",
901 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700902
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800903 ldflags: [
904 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
905 "-Wl,--export-dynamic",
906 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700907
908 sanitize: {
909 never: false,
910 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700911
912 target: {
913 linux_bionic: {
914 enabled: false,
915 },
916 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700917}
918
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700919subdirs = ["*"]