blob: 7219fc56725aec699d1a5f5c2565173e809eb54b [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 Collingbourne7b70e272018-11-12 20:09:14 -080041 // Make the bionic tests implicitly test bionic's shadow call stack support.
42 arch: {
43 arm64: {
44 cflags: ["-fsanitize=shadow-call-stack"],
45 },
46 },
Colin Cross2722ebb2016-07-11 16:20:06 -070047 stl: "libc++",
48 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080049 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070050 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090051 bootstrap: true,
Colin Cross2722ebb2016-07-11 16:20:06 -070052}
53
54// -----------------------------------------------------------------------------
55// All standard tests.
56// -----------------------------------------------------------------------------
57
George Burgess IVde45dcb2018-03-16 14:15:01 -070058// Test diagnostics emitted by clang. The library that results is useless; we
59// just want to run '-Xclang -verify', which will fail if the diagnostics don't
60// match up with what the source file says they should be.
61cc_test_library {
62 name: "clang_diagnostic_tests",
63 cflags: [
64 "-Xclang",
65 "-verify",
66 ],
67 srcs: ["sys_ioctl_diag_test.cpp"],
68}
69
Colin Cross2722ebb2016-07-11 16:20:06 -070070cc_test_library {
71 name: "libBionicStandardTests",
72 defaults: ["bionic_tests_defaults"],
73 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080074 "__aeabi_read_tp_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030075 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070076 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070077 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070078 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070079 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070080 "buffer_tests.cpp",
81 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030082 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070083 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070084 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070085 "ctype_test.cpp",
86 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -070087 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080088 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -070089 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070090 "error_test.cpp",
91 "eventfd_test.cpp",
92 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -070093 "fdsan_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070094 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -080095 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -070096 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070097 "ftw_test.cpp",
98 "getauxval_test.cpp",
99 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700100 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700101 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800102 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700103 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700104 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800105 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700106 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700107 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800108 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700109 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700110 "libgen_basename_test.cpp",
111 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700112 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700113 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700114 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700115 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700116 "malloc_test.cpp",
117 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700118 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100119 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700120 "mntent_test.cpp",
121 "netdb_test.cpp",
122 "net_if_test.cpp",
123 "netinet_ether_test.cpp",
124 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700125 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700126 "netinet_udp_test.cpp",
127 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700128 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700129 "pthread_test.cpp",
130 "pty_test.cpp",
131 "regex_test.cpp",
132 "resolv_test.cpp",
133 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800134 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700135 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "search_test.cpp",
137 "semaphore_test.cpp",
138 "setjmp_test.cpp",
139 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700140 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700141 "stack_protector_test.cpp",
142 "stack_protector_test_helper.cpp",
143 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700144 "stdalign_test.cpp",
145 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700146 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700147 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700148 "stdint_test.cpp",
149 "stdio_nofortify_test.cpp",
150 "stdio_test.cpp",
151 "stdio_ext_test.cpp",
152 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700153 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700154 "string_nofortify_test.cpp",
155 "string_test.cpp",
156 "string_posix_strerror_r_test.cpp",
157 "strings_nofortify_test.cpp",
158 "strings_test.cpp",
159 "sstream_test.cpp",
160 "sys_epoll_test.cpp",
161 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700162 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700163 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700164 "sys_personality_test.cpp",
165 "sys_prctl_test.cpp",
166 "sys_procfs_test.cpp",
167 "sys_ptrace_test.cpp",
168 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700169 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700170 "sys_resource_test.cpp",
171 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700172 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700173 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700174 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800175 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700176 "sys_socket_test.cpp",
177 "sys_stat_test.cpp",
178 "sys_statvfs_test.cpp",
179 "sys_syscall_test.cpp",
180 "sys_sysinfo_test.cpp",
181 "sys_sysmacros_test.cpp",
182 "sys_time_test.cpp",
183 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700184 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700185 "sys_types_test.cpp",
186 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700187 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700188 "sys_vfs_test.cpp",
189 "sys_xattr_test.cpp",
190 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000191 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800192 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700193 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700194 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700195 "time_test.cpp",
196 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700197 "unistd_nofortify_test.cpp",
198 "unistd_test.cpp",
199 "utmp_test.cpp",
200 "wchar_test.cpp",
201 "wctype_test.cpp",
202 ],
203
204 include_dirs: [
205 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700206 ],
207
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700208 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700209 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800210 whole_static_libs: [
211 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700212 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800213 "libsystemproperties",
214 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800215 srcs: [
216 "tagged_pointers_test.cpp",
217 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700218 },
219 },
220
Dan Willemsen41567702016-08-31 16:35:01 -0700221 static_libs: [
222 "libtinyxml2",
223 "liblog",
224 "libbase",
225 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700226 shared: {
227 enabled: false,
228 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000229
230 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700231}
232
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800233cc_test_library {
234 name: "libBionicElfTlsTests",
235 defaults: ["bionic_tests_defaults"],
236 srcs: [
237 "elftls_test.cpp",
238 ],
239 include_dirs: [
240 "bionic/libc",
241 ],
242 shared: {
243 enabled: false,
244 },
245 cflags: [
246 "-fno-emulated-tls",
247 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700248 // With fuzzer builds, compiler instrumentation generates a reference to the
249 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
250 // library as an emutls symbol. The -fno-emulated-tls flag above configures
251 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
252 // symbol instead, which isn't defined. Disable the fuzzer for this test
253 // until the platform is switched to ELF TLS.
254 sanitize: {
255 fuzzer: false,
256 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800257}
258
259cc_test_library {
260 name: "libBionicElfTlsLoaderTests",
261 defaults: ["bionic_tests_defaults"],
262 srcs: [
263 "elftls_dl_test.cpp",
264 ],
265 include_dirs: [
266 "bionic/libc",
267 ],
268 static_libs: [
269 "liblog",
270 "libbase",
271 ],
272 shared: {
273 enabled: false,
274 },
275 cflags: [
276 "-fno-emulated-tls",
277 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700278 // With fuzzer builds, compiler instrumentation generates a reference to the
279 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
280 // library as an emutls symbol. The -fno-emulated-tls flag above configures
281 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
282 // symbol instead, which isn't defined. Disable the fuzzer for this test
283 // until the platform is switched to ELF TLS.
284 sanitize: {
285 fuzzer: false,
286 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800287}
288
Colin Cross2722ebb2016-07-11 16:20:06 -0700289// -----------------------------------------------------------------------------
290// Fortify tests.
291// -----------------------------------------------------------------------------
292
293cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700294 name: "bionic_clang_fortify_tests_w_flags",
295 cflags: [
296 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700297 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700298 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700299 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700300 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700301 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700302 "-Wno-strncat-size",
303 ],
304}
305
306cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700307 name: "bionic_fortify_tests_defaults",
308 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700309 "-U_FORTIFY_SOURCE",
310 ],
311 srcs: ["fortify_test_main.cpp"],
312 target: {
313 host: {
314 clang_cflags: ["-D__clang__"],
315 },
316 },
317}
318
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700319// Ensures that FORTIFY checks aren't run when ASAN is on.
320cc_test {
321 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700322 defaults: [
323 "bionic_clang_fortify_tests_w_flags",
324 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700325 cflags: [
326 "-Werror",
327 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700328 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700329 sanitize: {
330 address: true,
331 },
332 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700333}
334
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700335// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
336// it can confuse these tools pretty easily. If this builds successfully, then
337// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
338// enabled. The library that results from building this is meant to be unused.
339cc_test_library {
340 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700341 defaults: [
342 "bionic_clang_fortify_tests_w_flags",
343 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700344 cflags: [
345 "-Werror",
346 "-D_FORTIFY_SOURCE=2",
347 "-D__clang_analyzer__",
348 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700349 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700350}
351
Colin Cross2722ebb2016-07-11 16:20:06 -0700352cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700353 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800354 defaults: [
355 "bionic_fortify_tests_defaults",
356 "bionic_tests_defaults",
357 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700358 cflags: [
359 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800360 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700361 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700362 shared: {
363 enabled: false,
364 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700365}
366
367cc_test_library {
368 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800369 defaults: [
370 "bionic_fortify_tests_defaults",
371 "bionic_tests_defaults",
372 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700373 cflags: [
374 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800375 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700376 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700377 shared: {
378 enabled: false,
379 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700380}
381
George Burgess IV9a274102019-06-04 15:39:52 -0700382cc_defaults {
383 name: "bionic_new_fortify_tests_defaults",
384 defaults: [
385 "bionic_clang_fortify_tests_w_flags",
386 ],
387 cflags: [
388 "-U_FORTIFY_SOURCE",
389 ],
390 srcs: ["clang_fortify_tests.cpp"],
391 target: {
392 host: {
393 clang_cflags: ["-D__clang__"],
394 },
395 },
396}
397
398cc_test_library {
399 name: "libfortify1-new-tests-clang",
400 defaults: [
401 "bionic_new_fortify_tests_defaults",
402 "bionic_tests_defaults",
403 ],
404 cflags: [
405 "-D_FORTIFY_SOURCE=1",
406 "-DTEST_NAME=Fortify1_clang_new",
407 ],
408 shared: {
409 enabled: false,
410 },
411}
412
413cc_test_library {
414 name: "libfortify2-new-tests-clang",
415 defaults: [
416 "bionic_new_fortify_tests_defaults",
417 "bionic_tests_defaults",
418 ],
419 cflags: [
420 "-D_FORTIFY_SOURCE=2",
421 "-DTEST_NAME=Fortify2_clang_new",
422 ],
423 shared: {
424 enabled: false,
425 },
426}
427
428
Colin Cross2722ebb2016-07-11 16:20:06 -0700429// -----------------------------------------------------------------------------
430// Library of all tests (excluding the dynamic linker tests).
431// -----------------------------------------------------------------------------
432cc_test_library {
433 name: "libBionicTests",
434 defaults: ["bionic_tests_defaults"],
435 whole_static_libs: [
436 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800437 "libBionicElfTlsTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700438 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700439 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700440 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700441 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700442 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700443 shared: {
444 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700445 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700446}
447
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700448cc_test_library {
449 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800450 defaults: [
451 "bionic_tests_defaults",
452 "llvm-defaults",
453 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700454 srcs: [
455 "atexit_test.cpp",
456 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700457 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700458 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700459 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700460 "pthread_dlfcn_test.cpp",
461 ],
462 static_libs: [
463 "libbase",
464 ],
465 include_dirs: [
466 "bionic/libc",
467 ],
468 shared: {
469 enabled: false,
470 },
471 target: {
472 android: {
473 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700474 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700475 "dlext_test.cpp",
476 "libdl_test.cpp",
477 ],
478 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800479 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400480 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700481 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800482 "libLLVMObject",
483 "libLLVMBitReader",
484 "libLLVMMC",
485 "libLLVMMCParser",
486 "libLLVMCore",
487 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700488 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800489 },
Jiyong Park02586a22017-05-20 01:01:24 +0900490 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700491}
492
Colin Cross2722ebb2016-07-11 16:20:06 -0700493// -----------------------------------------------------------------------------
494// Library of bionic customized gtest main function, with normal gtest output format,
495// which is needed by bionic cts test.
496// -----------------------------------------------------------------------------
497cc_test_library {
498 name: "libBionicCtsGtestMain",
499 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700500 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700501 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700502 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700503 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700504 shared: {
505 enabled: false,
506 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700507 whole_static_libs: [
508 "libgtest_isolated",
509 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700510}
511
512// -----------------------------------------------------------------------------
513// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900514// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
515// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700516// -----------------------------------------------------------------------------
517cc_defaults {
518 name: "bionic_unit_tests_defaults",
519 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800520 gtest: false,
521
522 defaults: [
523 "bionic_tests_defaults",
524 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700525
526 whole_static_libs: [
527 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700528 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800529 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700530 ],
531
532 static_libs: [
533 "libtinyxml2",
534 "liblog",
535 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800536 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700537 ],
538
539 srcs: [
540 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700541 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700542 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800543 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700544 "thread_local_test.cpp",
545 ],
546
547 conlyflags: [
548 "-fexceptions",
549 "-fnon-call-exceptions",
550 ],
551
552 ldflags: ["-Wl,--export-dynamic"],
553
554 include_dirs: ["bionic/libc"],
555
Yabin Cui1f553ea2017-01-13 12:31:59 -0800556 stl: "libc++_static",
557
Colin Cross2722ebb2016-07-11 16:20:06 -0700558 target: {
559 android: {
560 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100561 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700562 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100563 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700564 "libdl_preempt_test_1",
565 "libdl_preempt_test_2",
566 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800567 "libtest_elftls_shared_var",
568 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700569 ],
570 static_libs: [
571 // The order of these libraries matters, do not shuffle them.
572 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800573 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700574 "libziparchive",
575 "libz",
576 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800577 "libLLVMObject",
578 "libLLVMBitReader",
579 "libLLVMMC",
580 "libLLVMMCParser",
581 "libLLVMCore",
582 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700583 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700584 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700585 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700586 "-Wl,--enable-new-dtags",
587 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700588 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800589 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700590
591 required: [
592 "cfi_test_helper",
593 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800594 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700595 "exec_linker_helper",
596 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700597 "libtest_dt_runpath_a",
598 "libtest_dt_runpath_b",
599 "libtest_dt_runpath_c",
600 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900601 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700602 "libatest_simple_zip",
603 "libcfi-test",
604 "libcfi-test-bad",
605 "libdlext_test_different_soname",
606 "libdlext_test_fd",
607 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400608 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700609 "libdlext_test_runpath_zip_zipaligned",
610 "libdlext_test",
611 "libdlext_test_zip",
612 "libdlext_test_zip_zipaligned",
613 "libdl_preempt_test_1",
614 "libdl_preempt_test_2",
615 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700616 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800617 "librelocations-ANDROID_RELR",
618 "librelocations-ANDROID_REL",
619 "librelocations-RELR",
620 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700621 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700622 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700623 "libtest_atexit",
624 "libtest_check_order_dlsym_1_left",
625 "libtest_check_order_dlsym_2_right",
626 "libtest_check_order_dlsym_3_c",
627 "libtest_check_order_dlsym_a",
628 "libtest_check_order_dlsym_b",
629 "libtest_check_order_dlsym_d",
630 "libtest_check_order_dlsym",
631 "libtest_check_order_reloc_root_1",
632 "libtest_check_order_reloc_root_2",
633 "libtest_check_order_reloc_root",
634 "libtest_check_order_reloc_siblings_1",
635 "libtest_check_order_reloc_siblings_2",
636 "libtest_check_order_reloc_siblings_3",
637 "libtest_check_order_reloc_siblings_a",
638 "libtest_check_order_reloc_siblings_b",
639 "libtest_check_order_reloc_siblings_c_1",
640 "libtest_check_order_reloc_siblings_c_2",
641 "libtest_check_order_reloc_siblings_c",
642 "libtest_check_order_reloc_siblings_d",
643 "libtest_check_order_reloc_siblings_e",
644 "libtest_check_order_reloc_siblings_f",
645 "libtest_check_order_reloc_siblings",
646 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700647 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700648 "libtest_dlopen_from_ctor_main",
649 "libtest_dlopen_from_ctor",
650 "libtest_dlopen_weak_undefined_func",
651 "libtest_dlsym_df_1_global",
652 "libtest_dlsym_from_this_child",
653 "libtest_dlsym_from_this_grandchild",
654 "libtest_dlsym_from_this",
655 "libtest_dlsym_weak_func",
656 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800657 "libtest_elftls_dynamic",
658 "libtest_elftls_dynamic_filler_1",
659 "libtest_elftls_dynamic_filler_2",
660 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800661 "libtest_elftls_shared_var",
662 "libtest_elftls_shared_var_ie",
663 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700664 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700665 "libtest_ifunc_variable_impl",
666 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700667 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700668 "libtest_init_fini_order_child",
669 "libtest_init_fini_order_grand_child",
670 "libtest_init_fini_order_root2",
671 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700672 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700673 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700674 "libtest_missing_symbol_root",
675 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700676 "libtest_nodelete_1",
677 "libtest_nodelete_2",
678 "libtest_nodelete_dt_flags_1",
679 "libtest_pthread_atfork",
680 "libtest_relo_check_dt_needed_order_1",
681 "libtest_relo_check_dt_needed_order_2",
682 "libtest_relo_check_dt_needed_order",
683 "libtest_simple",
684 "libtest_two_parents_child",
685 "libtest_two_parents_parent1",
686 "libtest_two_parents_parent2",
687 "libtest_versioned_lib",
688 "libtest_versioned_libv1",
689 "libtest_versioned_libv2",
690 "libtest_versioned_otherlib_empty",
691 "libtest_versioned_otherlib",
692 "libtest_versioned_uselibv1",
693 "libtest_versioned_uselibv2_other",
694 "libtest_versioned_uselibv2",
695 "libtest_versioned_uselibv3_other",
696 "libtest_with_dependency_loop_a",
697 "libtest_with_dependency_loop_b",
698 "libtest_with_dependency_loop_c",
699 "libtest_with_dependency_loop",
700 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200701 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700702 "libtest_invalid-empty_shdr_table.so",
703 "libtest_invalid-rw_load_segment.so",
704 "libtest_invalid-unaligned_shdr_offset.so",
705 "libtest_invalid-zero_shdr_table_content.so",
706 "libtest_invalid-zero_shdr_table_offset.so",
707 "libtest_invalid-zero_shentsize.so",
708 "libtest_invalid-zero_shstrndx.so",
709 "libtest_invalid-textrels.so",
710 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700711 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200712 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700713 "preinit_getauxval_test_helper",
714 "preinit_syscall_test_helper",
715 "libnstest_private_external",
716 "libnstest_dlopened",
717 "libnstest_private",
718 "libnstest_root_not_isolated",
719 "libnstest_root",
720 "libnstest_public",
721 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800722 "libnstest_ns_a_public1",
723 "libnstest_ns_a_public1_internal",
724 "libnstest_ns_b_public2",
725 "libnstest_ns_b_public3",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800726 "libsegment_gap_inner",
727 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900728 "ld_preload_test_helper",
729 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700730 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900731 "ld_config_test_helper",
732 "ld_config_test_helper_lib1",
733 "ld_config_test_helper_lib2",
734 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700735 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700736}
737
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800738cc_test {
739 name: "bionic-unit-tests",
740 defaults: [
741 "bionic_unit_tests_defaults",
742 ],
743}
744
745cc_test {
746 name: "bionic-unit-tests-scudo",
747 defaults: [
748 "bionic_unit_tests_defaults",
749 ],
750
751 shared_libs: [
752 "libc_scudo",
753 ],
754}
755
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700756cc_test {
757 name: "bionic-stress-tests",
758 defaults: [
759 "bionic_tests_defaults",
760 ],
761
762 // For now, these tests run forever, so do not use the isolation framework.
763 isolated: false,
764
765 srcs: [
766 "malloc_stress_test.cpp",
767 ],
768
769 shared_libs: [
770 "libbase",
771 ],
772
773 target: {
774 android: {
775 static_libs: [
776 "libmeminfo",
777 "libprocinfo",
778 ],
779 },
780 },
781}
782
Colin Cross2722ebb2016-07-11 16:20:06 -0700783// -----------------------------------------------------------------------------
784// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900785// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
786// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700787// -----------------------------------------------------------------------------
788cc_test {
789 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700790 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700791 defaults: ["bionic_tests_defaults"],
792 host_supported: false,
793
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800794 srcs: [
795 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700796 "gtest_globals.cpp",
797 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800798
799 // The Bionic allocator has its own C++ API. It isn't packaged into its
800 // own library, so it can only be tested when it's part of libc.a.
801 "bionic_allocator_test.cpp",
802 ],
803 include_dirs: [
804 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800805 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700806 whole_static_libs: [
807 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700808 ],
809
810 static_libs: [
811 "libm",
812 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700813 "libdl",
814 "libtinyxml2",
815 "liblog",
816 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700817 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700818 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800819 "libtest_elftls_shared_var",
820 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700821 ],
822
823 static_executable: true,
824 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700825}
826
827// -----------------------------------------------------------------------------
828// Tests to run on the host and linked against glibc. Run with:
829// cd bionic/tests; mm bionic-unit-tests-glibc-run
830// -----------------------------------------------------------------------------
831
832cc_test_host {
833 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700834 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700835 defaults: ["bionic_tests_defaults"],
836
837 srcs: [
838 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700839 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700840 "dlfcn_test.cpp",
841 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700842 "gtest_globals.cpp",
843 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700844 "pthread_dlfcn_test.cpp",
845 ],
846
847 shared_libs: [
848 "libdl_preempt_test_1",
849 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700850 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800851 "libtest_elftls_shared_var",
852 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700853 ],
854
855 whole_static_libs: [
856 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800857 "libBionicElfTlsTests",
858 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700859 "libfortify1-tests-clang",
860 "libfortify2-tests-clang",
861 ],
862
863 static_libs: [
864 "libbase",
865 "liblog",
866 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700867 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700868 ],
869
870 host_ldlibs: [
871 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700872 "-lutil",
873 ],
874
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700875 include_dirs: [
876 "bionic/libc",
877 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700878
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800879 ldflags: [
880 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
881 "-Wl,--export-dynamic",
882 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700883
884 sanitize: {
885 never: false,
886 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700887
888 target: {
889 linux_bionic: {
890 enabled: false,
891 },
892 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700893}
894
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700895subdirs = ["*"]