blob: 8b1eebc3f54537e7fe3f28b14631d23028673bf2 [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",
Ryan Prichard58cbfd92020-02-04 15:46:15 -080082 "__cxa_atexit_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030083 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070084 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070085 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070086 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070087 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070088 "buffer_tests.cpp",
89 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030090 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070091 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070092 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070093 "ctype_test.cpp",
94 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -070095 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080096 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -070097 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070098 "error_test.cpp",
99 "eventfd_test.cpp",
100 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700101 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800102 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700103 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800104 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700105 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700106 "ftw_test.cpp",
107 "getauxval_test.cpp",
108 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700109 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700110 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800111 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700112 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700113 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800114 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700115 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700116 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800117 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700118 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700119 "libgen_basename_test.cpp",
120 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700121 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700122 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700123 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700124 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700125 "malloc_test.cpp",
126 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700127 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100128 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700129 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800130 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700131 "netdb_test.cpp",
132 "net_if_test.cpp",
133 "netinet_ether_test.cpp",
134 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700135 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "netinet_udp_test.cpp",
137 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700138 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700139 "pthread_test.cpp",
140 "pty_test.cpp",
141 "regex_test.cpp",
142 "resolv_test.cpp",
143 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800144 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700145 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700146 "search_test.cpp",
147 "semaphore_test.cpp",
148 "setjmp_test.cpp",
149 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700150 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700151 "stack_protector_test.cpp",
152 "stack_protector_test_helper.cpp",
153 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700154 "stdalign_test.cpp",
155 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700156 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700157 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700158 "stdint_test.cpp",
159 "stdio_nofortify_test.cpp",
160 "stdio_test.cpp",
161 "stdio_ext_test.cpp",
162 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700163 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700164 "string_nofortify_test.cpp",
165 "string_test.cpp",
166 "string_posix_strerror_r_test.cpp",
167 "strings_nofortify_test.cpp",
168 "strings_test.cpp",
169 "sstream_test.cpp",
170 "sys_epoll_test.cpp",
171 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700172 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700173 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700174 "sys_personality_test.cpp",
175 "sys_prctl_test.cpp",
176 "sys_procfs_test.cpp",
177 "sys_ptrace_test.cpp",
178 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700179 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700180 "sys_resource_test.cpp",
181 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700182 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700183 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700184 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800185 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700186 "sys_socket_test.cpp",
187 "sys_stat_test.cpp",
188 "sys_statvfs_test.cpp",
189 "sys_syscall_test.cpp",
190 "sys_sysinfo_test.cpp",
191 "sys_sysmacros_test.cpp",
192 "sys_time_test.cpp",
193 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700194 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700195 "sys_types_test.cpp",
196 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700197 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700198 "sys_vfs_test.cpp",
199 "sys_xattr_test.cpp",
200 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000201 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800202 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700203 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700204 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700205 "time_test.cpp",
206 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700207 "unistd_nofortify_test.cpp",
208 "unistd_test.cpp",
209 "utmp_test.cpp",
210 "wchar_test.cpp",
211 "wctype_test.cpp",
212 ],
213
214 include_dirs: [
215 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700216 ],
217
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700218 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700219 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800220 whole_static_libs: [
221 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700222 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800223 "libsystemproperties",
224 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800225 srcs: [
226 "tagged_pointers_test.cpp",
227 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700228 },
229 },
230
Dan Willemsen41567702016-08-31 16:35:01 -0700231 static_libs: [
232 "libtinyxml2",
233 "liblog",
234 "libbase",
235 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700236 shared: {
237 enabled: false,
238 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000239
240 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700241}
242
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800243cc_test_library {
244 name: "libBionicElfTlsTests",
245 defaults: ["bionic_tests_defaults"],
246 srcs: [
247 "elftls_test.cpp",
248 ],
249 include_dirs: [
250 "bionic/libc",
251 ],
252 shared: {
253 enabled: false,
254 },
255 cflags: [
256 "-fno-emulated-tls",
257 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700258 // With fuzzer builds, compiler instrumentation generates a reference to the
259 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
260 // library as an emutls symbol. The -fno-emulated-tls flag above configures
261 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
262 // symbol instead, which isn't defined. Disable the fuzzer for this test
263 // until the platform is switched to ELF TLS.
264 sanitize: {
265 fuzzer: false,
266 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800267}
268
269cc_test_library {
270 name: "libBionicElfTlsLoaderTests",
271 defaults: ["bionic_tests_defaults"],
272 srcs: [
273 "elftls_dl_test.cpp",
274 ],
275 include_dirs: [
276 "bionic/libc",
277 ],
278 static_libs: [
279 "liblog",
280 "libbase",
281 ],
282 shared: {
283 enabled: false,
284 },
285 cflags: [
286 "-fno-emulated-tls",
287 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700288 // With fuzzer builds, compiler instrumentation generates a reference to the
289 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
290 // library as an emutls symbol. The -fno-emulated-tls flag above configures
291 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
292 // symbol instead, which isn't defined. Disable the fuzzer for this test
293 // until the platform is switched to ELF TLS.
294 sanitize: {
295 fuzzer: false,
296 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800297}
298
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800299cc_test_library {
300 name: "libBionicFramePointerTests",
301 defaults: ["bionic_tests_defaults"],
302 srcs: [
303 "android_unsafe_frame_pointer_chase_test.cpp",
304 ],
305 include_dirs: [
306 "bionic/libc",
307 ],
308 cflags: [
309 "-fno-omit-frame-pointer",
310 ],
311}
312
Colin Cross2722ebb2016-07-11 16:20:06 -0700313// -----------------------------------------------------------------------------
314// Fortify tests.
315// -----------------------------------------------------------------------------
316
317cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700318 name: "bionic_clang_fortify_tests_w_flags",
319 cflags: [
320 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700321 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700322 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700323 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700324 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700325 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700326 "-Wno-strncat-size",
327 ],
328}
329
330cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700331 name: "bionic_fortify_tests_defaults",
332 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700333 "-U_FORTIFY_SOURCE",
334 ],
335 srcs: ["fortify_test_main.cpp"],
336 target: {
337 host: {
338 clang_cflags: ["-D__clang__"],
339 },
340 },
341}
342
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700343// Ensures that FORTIFY checks aren't run when ASAN is on.
344cc_test {
345 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700346 defaults: [
347 "bionic_clang_fortify_tests_w_flags",
348 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700349 cflags: [
350 "-Werror",
351 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700352 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700353 sanitize: {
354 address: true,
355 },
356 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700357}
358
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700359// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
360// it can confuse these tools pretty easily. If this builds successfully, then
361// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
362// enabled. The library that results from building this is meant to be unused.
363cc_test_library {
364 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700365 defaults: [
366 "bionic_clang_fortify_tests_w_flags",
367 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700368 cflags: [
369 "-Werror",
370 "-D_FORTIFY_SOURCE=2",
371 "-D__clang_analyzer__",
372 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700373 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700374}
375
Colin Cross2722ebb2016-07-11 16:20:06 -0700376cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700377 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800378 defaults: [
379 "bionic_fortify_tests_defaults",
380 "bionic_tests_defaults",
381 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700382 cflags: [
383 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800384 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700385 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700386 shared: {
387 enabled: false,
388 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700389}
390
391cc_test_library {
392 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800393 defaults: [
394 "bionic_fortify_tests_defaults",
395 "bionic_tests_defaults",
396 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700397 cflags: [
398 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800399 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700400 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700401 shared: {
402 enabled: false,
403 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700404}
405
George Burgess IV9a274102019-06-04 15:39:52 -0700406cc_defaults {
407 name: "bionic_new_fortify_tests_defaults",
408 defaults: [
409 "bionic_clang_fortify_tests_w_flags",
410 ],
411 cflags: [
412 "-U_FORTIFY_SOURCE",
413 ],
414 srcs: ["clang_fortify_tests.cpp"],
415 target: {
416 host: {
417 clang_cflags: ["-D__clang__"],
418 },
419 },
420}
421
422cc_test_library {
423 name: "libfortify1-new-tests-clang",
424 defaults: [
425 "bionic_new_fortify_tests_defaults",
426 "bionic_tests_defaults",
427 ],
428 cflags: [
429 "-D_FORTIFY_SOURCE=1",
430 "-DTEST_NAME=Fortify1_clang_new",
431 ],
432 shared: {
433 enabled: false,
434 },
435}
436
437cc_test_library {
438 name: "libfortify2-new-tests-clang",
439 defaults: [
440 "bionic_new_fortify_tests_defaults",
441 "bionic_tests_defaults",
442 ],
443 cflags: [
444 "-D_FORTIFY_SOURCE=2",
445 "-DTEST_NAME=Fortify2_clang_new",
446 ],
447 shared: {
448 enabled: false,
449 },
450}
451
452
Colin Cross2722ebb2016-07-11 16:20:06 -0700453// -----------------------------------------------------------------------------
454// Library of all tests (excluding the dynamic linker tests).
455// -----------------------------------------------------------------------------
456cc_test_library {
457 name: "libBionicTests",
458 defaults: ["bionic_tests_defaults"],
459 whole_static_libs: [
460 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800461 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800462 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700463 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700464 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700465 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700466 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700467 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700468 shared: {
469 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700470 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700471}
472
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700473cc_test_library {
474 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800475 defaults: [
476 "bionic_tests_defaults",
477 "llvm-defaults",
478 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700479 srcs: [
480 "atexit_test.cpp",
481 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700482 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700483 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700484 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700485 "pthread_dlfcn_test.cpp",
486 ],
487 static_libs: [
488 "libbase",
489 ],
490 include_dirs: [
491 "bionic/libc",
492 ],
493 shared: {
494 enabled: false,
495 },
496 target: {
497 android: {
498 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700499 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700500 "dlext_test.cpp",
501 "libdl_test.cpp",
502 ],
503 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800504 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400505 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700506 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800507 "libLLVMObject",
508 "libLLVMBitReader",
509 "libLLVMMC",
510 "libLLVMMCParser",
511 "libLLVMCore",
512 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700513 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800514 },
Jiyong Park02586a22017-05-20 01:01:24 +0900515 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700516}
517
Colin Cross2722ebb2016-07-11 16:20:06 -0700518// -----------------------------------------------------------------------------
519// Library of bionic customized gtest main function, with normal gtest output format,
520// which is needed by bionic cts test.
521// -----------------------------------------------------------------------------
522cc_test_library {
523 name: "libBionicCtsGtestMain",
524 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700525 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700526 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700527 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700528 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700529 shared: {
530 enabled: false,
531 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700532 whole_static_libs: [
533 "libgtest_isolated",
534 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700535}
536
537// -----------------------------------------------------------------------------
538// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900539// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
540// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700541// -----------------------------------------------------------------------------
542cc_defaults {
543 name: "bionic_unit_tests_defaults",
544 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800545 gtest: false,
546
547 defaults: [
548 "bionic_tests_defaults",
549 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700550
551 whole_static_libs: [
552 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700553 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800554 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700555 ],
556
557 static_libs: [
558 "libtinyxml2",
559 "liblog",
560 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800561 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700562 ],
563
564 srcs: [
565 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700566 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700567 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800568 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700569 "thread_local_test.cpp",
570 ],
571
572 conlyflags: [
573 "-fexceptions",
574 "-fnon-call-exceptions",
575 ],
576
577 ldflags: ["-Wl,--export-dynamic"],
578
579 include_dirs: ["bionic/libc"],
580
Yabin Cui1f553ea2017-01-13 12:31:59 -0800581 stl: "libc++_static",
582
Colin Cross2722ebb2016-07-11 16:20:06 -0700583 target: {
584 android: {
585 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100586 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700587 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100588 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700589 "libdl_preempt_test_1",
590 "libdl_preempt_test_2",
591 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800592 "libtest_elftls_shared_var",
593 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700594 ],
595 static_libs: [
596 // The order of these libraries matters, do not shuffle them.
597 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800598 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700599 "libziparchive",
600 "libz",
601 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800602 "libLLVMObject",
603 "libLLVMBitReader",
604 "libLLVMMC",
605 "libLLVMMCParser",
606 "libLLVMCore",
607 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700608 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700609 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700610 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700611 "-Wl,--enable-new-dtags",
612 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700613 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800614 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700615
616 required: [
617 "cfi_test_helper",
618 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800619 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700620 "exec_linker_helper",
621 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700622 "libtest_dt_runpath_a",
623 "libtest_dt_runpath_b",
624 "libtest_dt_runpath_c",
625 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900626 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700627 "libatest_simple_zip",
628 "libcfi-test",
629 "libcfi-test-bad",
630 "libdlext_test_different_soname",
631 "libdlext_test_fd",
632 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400633 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700634 "libdlext_test_runpath_zip_zipaligned",
635 "libdlext_test",
636 "libdlext_test_zip",
637 "libdlext_test_zip_zipaligned",
638 "libdl_preempt_test_1",
639 "libdl_preempt_test_2",
640 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700641 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800642 "librelocations-ANDROID_RELR",
643 "librelocations-ANDROID_REL",
644 "librelocations-RELR",
645 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700646 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700647 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700648 "libtest_atexit",
649 "libtest_check_order_dlsym_1_left",
650 "libtest_check_order_dlsym_2_right",
651 "libtest_check_order_dlsym_3_c",
652 "libtest_check_order_dlsym_a",
653 "libtest_check_order_dlsym_b",
654 "libtest_check_order_dlsym_d",
655 "libtest_check_order_dlsym",
656 "libtest_check_order_reloc_root_1",
657 "libtest_check_order_reloc_root_2",
658 "libtest_check_order_reloc_root",
659 "libtest_check_order_reloc_siblings_1",
660 "libtest_check_order_reloc_siblings_2",
661 "libtest_check_order_reloc_siblings_3",
662 "libtest_check_order_reloc_siblings_a",
663 "libtest_check_order_reloc_siblings_b",
664 "libtest_check_order_reloc_siblings_c_1",
665 "libtest_check_order_reloc_siblings_c_2",
666 "libtest_check_order_reloc_siblings_c",
667 "libtest_check_order_reloc_siblings_d",
668 "libtest_check_order_reloc_siblings_e",
669 "libtest_check_order_reloc_siblings_f",
670 "libtest_check_order_reloc_siblings",
671 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700672 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700673 "libtest_dlopen_from_ctor_main",
674 "libtest_dlopen_from_ctor",
675 "libtest_dlopen_weak_undefined_func",
676 "libtest_dlsym_df_1_global",
677 "libtest_dlsym_from_this_child",
678 "libtest_dlsym_from_this_grandchild",
679 "libtest_dlsym_from_this",
680 "libtest_dlsym_weak_func",
681 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800682 "libtest_elftls_dynamic",
683 "libtest_elftls_dynamic_filler_1",
684 "libtest_elftls_dynamic_filler_2",
685 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800686 "libtest_elftls_shared_var",
687 "libtest_elftls_shared_var_ie",
688 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700689 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700690 "libtest_ifunc_variable_impl",
691 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700692 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700693 "libtest_init_fini_order_child",
694 "libtest_init_fini_order_grand_child",
695 "libtest_init_fini_order_root2",
696 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700697 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700698 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700699 "libtest_missing_symbol_root",
700 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700701 "libtest_nodelete_1",
702 "libtest_nodelete_2",
703 "libtest_nodelete_dt_flags_1",
704 "libtest_pthread_atfork",
705 "libtest_relo_check_dt_needed_order_1",
706 "libtest_relo_check_dt_needed_order_2",
707 "libtest_relo_check_dt_needed_order",
708 "libtest_simple",
709 "libtest_two_parents_child",
710 "libtest_two_parents_parent1",
711 "libtest_two_parents_parent2",
712 "libtest_versioned_lib",
713 "libtest_versioned_libv1",
714 "libtest_versioned_libv2",
715 "libtest_versioned_otherlib_empty",
716 "libtest_versioned_otherlib",
717 "libtest_versioned_uselibv1",
718 "libtest_versioned_uselibv2_other",
719 "libtest_versioned_uselibv2",
720 "libtest_versioned_uselibv3_other",
721 "libtest_with_dependency_loop_a",
722 "libtest_with_dependency_loop_b",
723 "libtest_with_dependency_loop_c",
724 "libtest_with_dependency_loop",
725 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200726 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700727 "libtest_invalid-empty_shdr_table.so",
728 "libtest_invalid-rw_load_segment.so",
729 "libtest_invalid-unaligned_shdr_offset.so",
730 "libtest_invalid-zero_shdr_table_content.so",
731 "libtest_invalid-zero_shdr_table_offset.so",
732 "libtest_invalid-zero_shentsize.so",
733 "libtest_invalid-zero_shstrndx.so",
734 "libtest_invalid-textrels.so",
735 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700736 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200737 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700738 "preinit_getauxval_test_helper",
739 "preinit_syscall_test_helper",
740 "libnstest_private_external",
741 "libnstest_dlopened",
742 "libnstest_private",
743 "libnstest_root_not_isolated",
744 "libnstest_root",
745 "libnstest_public",
746 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800747 "libnstest_ns_a_public1",
748 "libnstest_ns_a_public1_internal",
749 "libnstest_ns_b_public2",
750 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800751 "ns_hidden_child_helper",
752 "libns_hidden_child_global",
753 "libns_hidden_child_internal",
754 "libns_hidden_child_public",
755 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800756 "libsegment_gap_inner",
757 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900758 "ld_preload_test_helper",
759 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700760 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900761 "ld_config_test_helper",
762 "ld_config_test_helper_lib1",
763 "ld_config_test_helper_lib2",
764 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700765 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700766}
767
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800768cc_test {
769 name: "bionic-unit-tests",
770 defaults: [
771 "bionic_unit_tests_defaults",
772 ],
773}
774
775cc_test {
776 name: "bionic-unit-tests-scudo",
777 defaults: [
778 "bionic_unit_tests_defaults",
779 ],
780
781 shared_libs: [
782 "libc_scudo",
783 ],
784}
785
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700786cc_test {
787 name: "bionic-stress-tests",
788 defaults: [
789 "bionic_tests_defaults",
790 ],
791
792 // For now, these tests run forever, so do not use the isolation framework.
793 isolated: false,
794
795 srcs: [
796 "malloc_stress_test.cpp",
797 ],
798
799 shared_libs: [
800 "libbase",
801 ],
802
803 target: {
804 android: {
805 static_libs: [
806 "libmeminfo",
807 "libprocinfo",
808 ],
809 },
810 },
811}
812
Colin Cross2722ebb2016-07-11 16:20:06 -0700813// -----------------------------------------------------------------------------
814// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900815// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
816// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700817// -----------------------------------------------------------------------------
818cc_test {
819 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700820 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700821 defaults: ["bionic_tests_defaults"],
822 host_supported: false,
823
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800824 srcs: [
825 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700826 "gtest_globals.cpp",
827 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800828
829 // The Bionic allocator has its own C++ API. It isn't packaged into its
830 // own library, so it can only be tested when it's part of libc.a.
831 "bionic_allocator_test.cpp",
832 ],
833 include_dirs: [
834 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800835 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700836 whole_static_libs: [
837 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700838 ],
839
840 static_libs: [
841 "libm",
842 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700843 "libdl",
844 "libtinyxml2",
845 "liblog",
846 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700847 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700848 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800849 "libtest_elftls_shared_var",
850 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700851 ],
852
853 static_executable: true,
854 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700855}
856
857// -----------------------------------------------------------------------------
858// Tests to run on the host and linked against glibc. Run with:
859// cd bionic/tests; mm bionic-unit-tests-glibc-run
860// -----------------------------------------------------------------------------
861
862cc_test_host {
863 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700864 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700865 defaults: ["bionic_tests_defaults"],
866
867 srcs: [
868 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700869 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700870 "dlfcn_test.cpp",
871 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700872 "gtest_globals.cpp",
873 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700874 "pthread_dlfcn_test.cpp",
875 ],
876
877 shared_libs: [
878 "libdl_preempt_test_1",
879 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700880 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800881 "libtest_elftls_shared_var",
882 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700883 ],
884
885 whole_static_libs: [
886 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800887 "libBionicElfTlsTests",
888 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700889 "libfortify1-tests-clang",
890 "libfortify2-tests-clang",
891 ],
892
893 static_libs: [
894 "libbase",
895 "liblog",
896 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700897 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700898 ],
899
900 host_ldlibs: [
901 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700902 "-lutil",
903 ],
904
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700905 include_dirs: [
906 "bionic/libc",
907 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700908
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800909 ldflags: [
910 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
911 "-Wl,--export-dynamic",
912 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700913
914 sanitize: {
915 never: false,
916 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700917
918 target: {
919 linux_bionic: {
920 enabled: false,
921 },
922 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700923}
924
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700925subdirs = ["*"]