blob: 75fdd906f9594dea9a5da1e0d199f7fe8230d6fc [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 },
Martin Stjernholma2763432020-04-23 16:47:19 +010025 android: {
26 header_libs: ["bionic_libc_platform_headers"],
27 },
28 linux_bionic: {
29 header_libs: ["bionic_libc_platform_headers"],
30 },
Colin Cross2722ebb2016-07-11 16:20:06 -070031 },
32 cflags: [
33 "-fstack-protector-all",
34 "-g",
35 "-Wall",
36 "-Wextra",
37 "-Wunused",
38 "-Werror",
39 "-fno-builtin",
40
41 // We want to test deprecated API too.
42 "-Wno-deprecated-declarations",
43
44 // For glibc.
45 "-D__STDC_LIMIT_MACROS",
46 ],
Tamas Petzd901ec62020-02-25 11:25:48 +010047 // Ensure that the tests exercise shadow call stack support and
48 // the hint space PAC/BTI instructions.
Peter Collingbourne7b70e272018-11-12 20:09:14 -080049 arch: {
50 arm64: {
Tamas Petzd901ec62020-02-25 11:25:48 +010051 cflags: [
52 "-fsanitize=shadow-call-stack",
Christopher Ferris140220b2020-03-12 17:09:38 -070053 // Disable this option for now: see b/151372823
54 //"-mbranch-protection=standard",
Tamas Petzd901ec62020-02-25 11:25:48 +010055 ],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080056 },
57 },
Colin Cross2722ebb2016-07-11 16:20:06 -070058 stl: "libc++",
59 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080060 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070061 },
Ryan Prichard3c5dff42020-03-31 17:34:03 -070062
63 // Use the bootstrap version of bionic because some tests call private APIs
64 // that aren't exposed by the APEX bionic stubs.
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090065 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080066
67 product_variables: {
68 experimental_mte: {
69 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
70 },
71 },
Colin Cross2722ebb2016-07-11 16:20:06 -070072}
73
74// -----------------------------------------------------------------------------
75// All standard tests.
76// -----------------------------------------------------------------------------
77
George Burgess IVde45dcb2018-03-16 14:15:01 -070078// Test diagnostics emitted by clang. The library that results is useless; we
79// just want to run '-Xclang -verify', which will fail if the diagnostics don't
80// match up with what the source file says they should be.
81cc_test_library {
82 name: "clang_diagnostic_tests",
83 cflags: [
84 "-Xclang",
85 "-verify",
86 ],
87 srcs: ["sys_ioctl_diag_test.cpp"],
88}
89
Colin Cross2722ebb2016-07-11 16:20:06 -070090cc_test_library {
91 name: "libBionicStandardTests",
92 defaults: ["bionic_tests_defaults"],
93 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080094 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -080095 "__cxa_atexit_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030096 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070097 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070098 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070099 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -0700100 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700101 "buffer_tests.cpp",
102 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300103 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700104 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700105 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700106 "ctype_test.cpp",
107 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -0700108 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800109 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700110 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700111 "error_test.cpp",
112 "eventfd_test.cpp",
113 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700114 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800115 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700116 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800117 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700118 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700119 "ftw_test.cpp",
120 "getauxval_test.cpp",
121 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700122 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700123 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800124 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700125 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700126 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800127 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700129 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800130 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700131 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700132 "libgen_basename_test.cpp",
133 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700134 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700135 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700137 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700138 "malloc_test.cpp",
139 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700140 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100141 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700142 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800143 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700144 "netdb_test.cpp",
145 "net_if_test.cpp",
146 "netinet_ether_test.cpp",
147 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700148 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700149 "netinet_udp_test.cpp",
150 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700151 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700152 "pthread_test.cpp",
153 "pty_test.cpp",
154 "regex_test.cpp",
155 "resolv_test.cpp",
156 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800157 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700158 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700159 "search_test.cpp",
160 "semaphore_test.cpp",
161 "setjmp_test.cpp",
162 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700163 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700164 "stack_protector_test.cpp",
165 "stack_protector_test_helper.cpp",
166 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700167 "stdalign_test.cpp",
168 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700169 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700170 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700171 "stdint_test.cpp",
172 "stdio_nofortify_test.cpp",
173 "stdio_test.cpp",
174 "stdio_ext_test.cpp",
175 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700176 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700177 "string_nofortify_test.cpp",
178 "string_test.cpp",
179 "string_posix_strerror_r_test.cpp",
180 "strings_nofortify_test.cpp",
181 "strings_test.cpp",
182 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800183 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700184 "sys_epoll_test.cpp",
185 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700186 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700187 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700188 "sys_personality_test.cpp",
189 "sys_prctl_test.cpp",
190 "sys_procfs_test.cpp",
191 "sys_ptrace_test.cpp",
192 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700193 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700194 "sys_resource_test.cpp",
195 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700196 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700197 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700198 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800199 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700200 "sys_socket_test.cpp",
201 "sys_stat_test.cpp",
202 "sys_statvfs_test.cpp",
203 "sys_syscall_test.cpp",
204 "sys_sysinfo_test.cpp",
205 "sys_sysmacros_test.cpp",
206 "sys_time_test.cpp",
207 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700208 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700209 "sys_types_test.cpp",
210 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700211 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700212 "sys_vfs_test.cpp",
213 "sys_xattr_test.cpp",
214 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000215 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800216 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700217 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700218 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700219 "time_test.cpp",
220 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700221 "unistd_nofortify_test.cpp",
222 "unistd_test.cpp",
223 "utmp_test.cpp",
224 "wchar_test.cpp",
225 "wctype_test.cpp",
226 ],
227
228 include_dirs: [
229 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700230 ],
231
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700232 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700233 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800234 whole_static_libs: [
235 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700236 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800237 "libsystemproperties",
238 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800239 srcs: [
240 "tagged_pointers_test.cpp",
241 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700242 },
243 },
244
Dan Willemsen41567702016-08-31 16:35:01 -0700245 static_libs: [
246 "libtinyxml2",
247 "liblog",
248 "libbase",
249 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700250 shared: {
251 enabled: false,
252 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000253
254 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700255}
256
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800257cc_test_library {
258 name: "libBionicElfTlsTests",
259 defaults: ["bionic_tests_defaults"],
260 srcs: [
261 "elftls_test.cpp",
262 ],
263 include_dirs: [
264 "bionic/libc",
265 ],
266 shared: {
267 enabled: false,
268 },
269 cflags: [
270 "-fno-emulated-tls",
271 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700272 // With fuzzer builds, compiler instrumentation generates a reference to the
273 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
274 // library as an emutls symbol. The -fno-emulated-tls flag above configures
275 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
276 // symbol instead, which isn't defined. Disable the fuzzer for this test
277 // until the platform is switched to ELF TLS.
278 sanitize: {
279 fuzzer: false,
280 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800281}
282
283cc_test_library {
284 name: "libBionicElfTlsLoaderTests",
285 defaults: ["bionic_tests_defaults"],
286 srcs: [
287 "elftls_dl_test.cpp",
288 ],
289 include_dirs: [
290 "bionic/libc",
291 ],
292 static_libs: [
293 "liblog",
294 "libbase",
295 ],
296 shared: {
297 enabled: false,
298 },
299 cflags: [
300 "-fno-emulated-tls",
301 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700302 // With fuzzer builds, compiler instrumentation generates a reference to the
303 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
304 // library as an emutls symbol. The -fno-emulated-tls flag above configures
305 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
306 // symbol instead, which isn't defined. Disable the fuzzer for this test
307 // until the platform is switched to ELF TLS.
308 sanitize: {
309 fuzzer: false,
310 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800311}
312
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800313cc_test_library {
314 name: "libBionicFramePointerTests",
315 defaults: ["bionic_tests_defaults"],
316 srcs: [
317 "android_unsafe_frame_pointer_chase_test.cpp",
318 ],
319 include_dirs: [
320 "bionic/libc",
321 ],
322 cflags: [
323 "-fno-omit-frame-pointer",
324 ],
325}
326
Colin Cross2722ebb2016-07-11 16:20:06 -0700327// -----------------------------------------------------------------------------
328// Fortify tests.
329// -----------------------------------------------------------------------------
330
331cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700332 name: "bionic_clang_fortify_tests_w_flags",
333 cflags: [
334 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700335 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700336 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700337 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700338 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700339 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700340 "-Wno-strncat-size",
341 ],
342}
343
344cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700345 name: "bionic_fortify_tests_defaults",
346 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700347 "-U_FORTIFY_SOURCE",
348 ],
349 srcs: ["fortify_test_main.cpp"],
350 target: {
351 host: {
352 clang_cflags: ["-D__clang__"],
353 },
354 },
355}
356
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700357// Ensures that FORTIFY checks aren't run when ASAN is on.
358cc_test {
359 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700360 defaults: [
361 "bionic_clang_fortify_tests_w_flags",
362 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700363 cflags: [
364 "-Werror",
365 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700366 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700367 sanitize: {
368 address: true,
369 },
370 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700371}
372
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700373// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
374// it can confuse these tools pretty easily. If this builds successfully, then
375// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
376// enabled. The library that results from building this is meant to be unused.
377cc_test_library {
378 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700379 defaults: [
380 "bionic_clang_fortify_tests_w_flags",
381 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700382 cflags: [
383 "-Werror",
384 "-D_FORTIFY_SOURCE=2",
385 "-D__clang_analyzer__",
386 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700387 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700388}
389
Colin Cross2722ebb2016-07-11 16:20:06 -0700390cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700391 name: "libfortify1-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=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800398 "-DTEST_NAME=Fortify1_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
405cc_test_library {
406 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800407 defaults: [
408 "bionic_fortify_tests_defaults",
409 "bionic_tests_defaults",
410 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700411 cflags: [
412 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800413 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700414 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700415 shared: {
416 enabled: false,
417 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700418}
419
George Burgess IV9a274102019-06-04 15:39:52 -0700420cc_defaults {
421 name: "bionic_new_fortify_tests_defaults",
422 defaults: [
423 "bionic_clang_fortify_tests_w_flags",
424 ],
425 cflags: [
426 "-U_FORTIFY_SOURCE",
427 ],
428 srcs: ["clang_fortify_tests.cpp"],
429 target: {
430 host: {
431 clang_cflags: ["-D__clang__"],
432 },
433 },
434}
435
436cc_test_library {
437 name: "libfortify1-new-tests-clang",
438 defaults: [
439 "bionic_new_fortify_tests_defaults",
440 "bionic_tests_defaults",
441 ],
442 cflags: [
443 "-D_FORTIFY_SOURCE=1",
444 "-DTEST_NAME=Fortify1_clang_new",
445 ],
446 shared: {
447 enabled: false,
448 },
449}
450
451cc_test_library {
452 name: "libfortify2-new-tests-clang",
453 defaults: [
454 "bionic_new_fortify_tests_defaults",
455 "bionic_tests_defaults",
456 ],
457 cflags: [
458 "-D_FORTIFY_SOURCE=2",
459 "-DTEST_NAME=Fortify2_clang_new",
460 ],
461 shared: {
462 enabled: false,
463 },
464}
465
466
Colin Cross2722ebb2016-07-11 16:20:06 -0700467// -----------------------------------------------------------------------------
468// Library of all tests (excluding the dynamic linker tests).
469// -----------------------------------------------------------------------------
470cc_test_library {
471 name: "libBionicTests",
472 defaults: ["bionic_tests_defaults"],
473 whole_static_libs: [
474 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800475 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800476 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700477 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700478 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700479 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700480 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700481 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700482 shared: {
483 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700484 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700485}
486
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700487cc_test_library {
488 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800489 defaults: [
490 "bionic_tests_defaults",
491 "llvm-defaults",
492 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700493 srcs: [
494 "atexit_test.cpp",
495 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700496 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700497 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700498 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700499 "pthread_dlfcn_test.cpp",
500 ],
501 static_libs: [
502 "libbase",
503 ],
504 include_dirs: [
505 "bionic/libc",
506 ],
507 shared: {
508 enabled: false,
509 },
510 target: {
511 android: {
512 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700513 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700514 "dlext_test.cpp",
515 "libdl_test.cpp",
516 ],
517 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800518 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400519 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700520 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800521 "libLLVMObject",
522 "libLLVMBitReader",
523 "libLLVMMC",
524 "libLLVMMCParser",
525 "libLLVMCore",
526 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700527 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800528 },
Jiyong Park02586a22017-05-20 01:01:24 +0900529 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700530}
531
Colin Cross2722ebb2016-07-11 16:20:06 -0700532// -----------------------------------------------------------------------------
533// Library of bionic customized gtest main function, with normal gtest output format,
534// which is needed by bionic cts test.
535// -----------------------------------------------------------------------------
536cc_test_library {
537 name: "libBionicCtsGtestMain",
538 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700539 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700540 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700541 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700542 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700543 shared: {
544 enabled: false,
545 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700546 whole_static_libs: [
547 "libgtest_isolated",
548 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700549}
550
551// -----------------------------------------------------------------------------
552// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900553// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
554// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700555// -----------------------------------------------------------------------------
556cc_defaults {
557 name: "bionic_unit_tests_defaults",
558 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800559 gtest: false,
560
561 defaults: [
562 "bionic_tests_defaults",
563 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700564
565 whole_static_libs: [
566 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700567 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800568 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700569 ],
570
571 static_libs: [
572 "libtinyxml2",
573 "liblog",
574 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800575 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700576 ],
577
578 srcs: [
579 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700580 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700581 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800582 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700583 "thread_local_test.cpp",
584 ],
585
586 conlyflags: [
587 "-fexceptions",
588 "-fnon-call-exceptions",
589 ],
590
591 ldflags: ["-Wl,--export-dynamic"],
592
593 include_dirs: ["bionic/libc"],
594
Yabin Cui1f553ea2017-01-13 12:31:59 -0800595 stl: "libc++_static",
596
Colin Cross2722ebb2016-07-11 16:20:06 -0700597 target: {
598 android: {
599 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100600 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700601 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100602 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700603 "libdl_preempt_test_1",
604 "libdl_preempt_test_2",
605 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800606 "libtest_elftls_shared_var",
607 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700608 ],
609 static_libs: [
610 // The order of these libraries matters, do not shuffle them.
611 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800612 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700613 "libziparchive",
614 "libz",
615 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800616 "libLLVMObject",
617 "libLLVMBitReader",
618 "libLLVMMC",
619 "libLLVMMCParser",
620 "libLLVMCore",
621 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700622 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700623 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700624 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700625 "-Wl,--enable-new-dtags",
626 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700627 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800628 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700629
630 required: [
631 "cfi_test_helper",
632 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800633 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700634 "exec_linker_helper",
635 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700636 "libtest_dt_runpath_a",
637 "libtest_dt_runpath_b",
638 "libtest_dt_runpath_c",
639 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900640 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700641 "libatest_simple_zip",
642 "libcfi-test",
643 "libcfi-test-bad",
644 "libdlext_test_different_soname",
645 "libdlext_test_fd",
646 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400647 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700648 "libdlext_test_runpath_zip_zipaligned",
649 "libdlext_test",
650 "libdlext_test_zip",
651 "libdlext_test_zip_zipaligned",
652 "libdl_preempt_test_1",
653 "libdl_preempt_test_2",
654 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700655 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800656 "librelocations-ANDROID_RELR",
657 "librelocations-ANDROID_REL",
658 "librelocations-RELR",
659 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700660 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700661 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700662 "libtest_atexit",
663 "libtest_check_order_dlsym_1_left",
664 "libtest_check_order_dlsym_2_right",
665 "libtest_check_order_dlsym_3_c",
666 "libtest_check_order_dlsym_a",
667 "libtest_check_order_dlsym_b",
668 "libtest_check_order_dlsym_d",
669 "libtest_check_order_dlsym",
670 "libtest_check_order_reloc_root_1",
671 "libtest_check_order_reloc_root_2",
672 "libtest_check_order_reloc_root",
673 "libtest_check_order_reloc_siblings_1",
674 "libtest_check_order_reloc_siblings_2",
675 "libtest_check_order_reloc_siblings_3",
676 "libtest_check_order_reloc_siblings_a",
677 "libtest_check_order_reloc_siblings_b",
678 "libtest_check_order_reloc_siblings_c_1",
679 "libtest_check_order_reloc_siblings_c_2",
680 "libtest_check_order_reloc_siblings_c",
681 "libtest_check_order_reloc_siblings_d",
682 "libtest_check_order_reloc_siblings_e",
683 "libtest_check_order_reloc_siblings_f",
684 "libtest_check_order_reloc_siblings",
685 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700686 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700687 "libtest_dlopen_from_ctor_main",
688 "libtest_dlopen_from_ctor",
689 "libtest_dlopen_weak_undefined_func",
690 "libtest_dlsym_df_1_global",
691 "libtest_dlsym_from_this_child",
692 "libtest_dlsym_from_this_grandchild",
693 "libtest_dlsym_from_this",
694 "libtest_dlsym_weak_func",
695 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800696 "libtest_elftls_dynamic",
697 "libtest_elftls_dynamic_filler_1",
698 "libtest_elftls_dynamic_filler_2",
699 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800700 "libtest_elftls_shared_var",
701 "libtest_elftls_shared_var_ie",
702 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700703 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700704 "libtest_ifunc_variable_impl",
705 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700706 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700707 "libtest_init_fini_order_child",
708 "libtest_init_fini_order_grand_child",
709 "libtest_init_fini_order_root2",
710 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700711 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700712 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700713 "libtest_missing_symbol_root",
714 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700715 "libtest_nodelete_1",
716 "libtest_nodelete_2",
717 "libtest_nodelete_dt_flags_1",
718 "libtest_pthread_atfork",
719 "libtest_relo_check_dt_needed_order_1",
720 "libtest_relo_check_dt_needed_order_2",
721 "libtest_relo_check_dt_needed_order",
722 "libtest_simple",
723 "libtest_two_parents_child",
724 "libtest_two_parents_parent1",
725 "libtest_two_parents_parent2",
726 "libtest_versioned_lib",
727 "libtest_versioned_libv1",
728 "libtest_versioned_libv2",
729 "libtest_versioned_otherlib_empty",
730 "libtest_versioned_otherlib",
731 "libtest_versioned_uselibv1",
732 "libtest_versioned_uselibv2_other",
733 "libtest_versioned_uselibv2",
734 "libtest_versioned_uselibv3_other",
735 "libtest_with_dependency_loop_a",
736 "libtest_with_dependency_loop_b",
737 "libtest_with_dependency_loop_c",
738 "libtest_with_dependency_loop",
739 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200740 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700741 "libtest_invalid-empty_shdr_table.so",
742 "libtest_invalid-rw_load_segment.so",
743 "libtest_invalid-unaligned_shdr_offset.so",
744 "libtest_invalid-zero_shdr_table_content.so",
745 "libtest_invalid-zero_shdr_table_offset.so",
746 "libtest_invalid-zero_shentsize.so",
747 "libtest_invalid-zero_shstrndx.so",
748 "libtest_invalid-textrels.so",
749 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700750 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200751 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700752 "preinit_getauxval_test_helper",
753 "preinit_syscall_test_helper",
754 "libnstest_private_external",
755 "libnstest_dlopened",
756 "libnstest_private",
757 "libnstest_root_not_isolated",
758 "libnstest_root",
759 "libnstest_public",
760 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800761 "libnstest_ns_a_public1",
762 "libnstest_ns_a_public1_internal",
763 "libnstest_ns_b_public2",
764 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800765 "ns_hidden_child_helper",
766 "libns_hidden_child_global",
767 "libns_hidden_child_internal",
768 "libns_hidden_child_public",
769 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800770 "libsegment_gap_inner",
771 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900772 "ld_preload_test_helper",
773 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700774 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900775 "ld_config_test_helper",
776 "ld_config_test_helper_lib1",
777 "ld_config_test_helper_lib2",
778 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700779 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700780}
781
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800782cc_test {
783 name: "bionic-unit-tests",
784 defaults: [
785 "bionic_unit_tests_defaults",
786 ],
787}
788
789cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700790 name: "bionic-stress-tests",
791 defaults: [
792 "bionic_tests_defaults",
793 ],
794
795 // For now, these tests run forever, so do not use the isolation framework.
796 isolated: false,
797
798 srcs: [
799 "malloc_stress_test.cpp",
800 ],
801
802 shared_libs: [
803 "libbase",
804 ],
805
806 target: {
807 android: {
808 static_libs: [
809 "libmeminfo",
810 "libprocinfo",
811 ],
812 },
813 },
814}
815
Colin Cross2722ebb2016-07-11 16:20:06 -0700816// -----------------------------------------------------------------------------
817// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900818// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
819// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700820// -----------------------------------------------------------------------------
821cc_test {
822 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700823 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700824 defaults: ["bionic_tests_defaults"],
825 host_supported: false,
826
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800827 srcs: [
828 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700829 "gtest_globals.cpp",
830 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800831
832 // The Bionic allocator has its own C++ API. It isn't packaged into its
833 // own library, so it can only be tested when it's part of libc.a.
834 "bionic_allocator_test.cpp",
835 ],
836 include_dirs: [
837 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800838 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700839 whole_static_libs: [
840 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700841 ],
842
843 static_libs: [
844 "libm",
845 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700846 "libdl",
847 "libtinyxml2",
848 "liblog",
849 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700850 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700851 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800852 "libtest_elftls_shared_var",
853 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700854 ],
855
856 static_executable: true,
857 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700858}
859
860// -----------------------------------------------------------------------------
861// Tests to run on the host and linked against glibc. Run with:
862// cd bionic/tests; mm bionic-unit-tests-glibc-run
863// -----------------------------------------------------------------------------
864
865cc_test_host {
866 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700867 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700868 defaults: ["bionic_tests_defaults"],
869
870 srcs: [
871 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700872 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700873 "dlfcn_test.cpp",
874 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700875 "gtest_globals.cpp",
876 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700877 "pthread_dlfcn_test.cpp",
878 ],
879
880 shared_libs: [
881 "libdl_preempt_test_1",
882 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700883 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800884 "libtest_elftls_shared_var",
885 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700886 ],
887
888 whole_static_libs: [
889 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800890 "libBionicElfTlsTests",
891 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700892 "libfortify1-tests-clang",
893 "libfortify2-tests-clang",
894 ],
895
896 static_libs: [
897 "libbase",
898 "liblog",
899 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700900 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700901 ],
902
903 host_ldlibs: [
904 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700905 "-lutil",
906 ],
907
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700908 include_dirs: [
909 "bionic/libc",
910 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700911
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800912 ldflags: [
913 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
914 "-Wl,--export-dynamic",
915 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700916
917 sanitize: {
918 never: false,
919 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700920
921 target: {
922 linux_bionic: {
923 enabled: false,
924 },
925 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700926}
927
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700928subdirs = ["*"]