blob: f1182a72f75a7eeeec8374568ec541348b457098 [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"],
Tamas Petzd901ec62020-02-25 11:25:48 +010042 // Ensure that the tests exercise shadow call stack support and
43 // the hint space PAC/BTI instructions.
Peter Collingbourne7b70e272018-11-12 20:09:14 -080044 arch: {
45 arm64: {
Tamas Petzd901ec62020-02-25 11:25:48 +010046 cflags: [
47 "-fsanitize=shadow-call-stack",
Christopher Ferris140220b2020-03-12 17:09:38 -070048 // Disable this option for now: see b/151372823
49 //"-mbranch-protection=standard",
Tamas Petzd901ec62020-02-25 11:25:48 +010050 ],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080051 },
52 },
Colin Cross2722ebb2016-07-11 16:20:06 -070053 stl: "libc++",
54 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080055 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070056 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090057 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080058
59 product_variables: {
60 experimental_mte: {
61 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
62 },
63 },
Colin Cross2722ebb2016-07-11 16:20:06 -070064}
65
66// -----------------------------------------------------------------------------
67// All standard tests.
68// -----------------------------------------------------------------------------
69
George Burgess IVde45dcb2018-03-16 14:15:01 -070070// Test diagnostics emitted by clang. The library that results is useless; we
71// just want to run '-Xclang -verify', which will fail if the diagnostics don't
72// match up with what the source file says they should be.
73cc_test_library {
74 name: "clang_diagnostic_tests",
75 cflags: [
76 "-Xclang",
77 "-verify",
78 ],
79 srcs: ["sys_ioctl_diag_test.cpp"],
80}
81
Colin Cross2722ebb2016-07-11 16:20:06 -070082cc_test_library {
83 name: "libBionicStandardTests",
84 defaults: ["bionic_tests_defaults"],
85 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080086 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -080087 "__cxa_atexit_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030088 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070089 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070090 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070091 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070092 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070093 "buffer_tests.cpp",
94 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030095 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070096 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070097 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070098 "ctype_test.cpp",
99 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -0700100 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800101 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700102 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700103 "error_test.cpp",
104 "eventfd_test.cpp",
105 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700106 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800107 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700108 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800109 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700110 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700111 "ftw_test.cpp",
112 "getauxval_test.cpp",
113 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700114 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700115 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800116 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700117 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700118 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800119 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700120 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700121 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800122 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700123 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700124 "libgen_basename_test.cpp",
125 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700126 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700127 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700129 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700130 "malloc_test.cpp",
131 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700132 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100133 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700134 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800135 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "netdb_test.cpp",
137 "net_if_test.cpp",
138 "netinet_ether_test.cpp",
139 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700140 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700141 "netinet_udp_test.cpp",
142 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700143 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700144 "pthread_test.cpp",
145 "pty_test.cpp",
146 "regex_test.cpp",
147 "resolv_test.cpp",
148 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800149 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700150 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700151 "search_test.cpp",
152 "semaphore_test.cpp",
153 "setjmp_test.cpp",
154 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700155 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700156 "stack_protector_test.cpp",
157 "stack_protector_test_helper.cpp",
158 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700159 "stdalign_test.cpp",
160 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700161 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700162 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700163 "stdint_test.cpp",
164 "stdio_nofortify_test.cpp",
165 "stdio_test.cpp",
166 "stdio_ext_test.cpp",
167 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700168 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700169 "string_nofortify_test.cpp",
170 "string_test.cpp",
171 "string_posix_strerror_r_test.cpp",
172 "strings_nofortify_test.cpp",
173 "strings_test.cpp",
174 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800175 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700176 "sys_epoll_test.cpp",
177 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700178 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700179 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700180 "sys_personality_test.cpp",
181 "sys_prctl_test.cpp",
182 "sys_procfs_test.cpp",
183 "sys_ptrace_test.cpp",
184 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700185 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700186 "sys_resource_test.cpp",
187 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700188 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700189 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700190 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800191 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700192 "sys_socket_test.cpp",
193 "sys_stat_test.cpp",
194 "sys_statvfs_test.cpp",
195 "sys_syscall_test.cpp",
196 "sys_sysinfo_test.cpp",
197 "sys_sysmacros_test.cpp",
198 "sys_time_test.cpp",
199 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700200 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700201 "sys_types_test.cpp",
202 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700203 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700204 "sys_vfs_test.cpp",
205 "sys_xattr_test.cpp",
206 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000207 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800208 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700209 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700210 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700211 "time_test.cpp",
212 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700213 "unistd_nofortify_test.cpp",
214 "unistd_test.cpp",
215 "utmp_test.cpp",
216 "wchar_test.cpp",
217 "wctype_test.cpp",
218 ],
219
220 include_dirs: [
221 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700222 ],
223
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700224 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700225 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800226 whole_static_libs: [
227 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700228 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800229 "libsystemproperties",
230 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800231 srcs: [
232 "tagged_pointers_test.cpp",
233 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700234 },
235 },
236
Dan Willemsen41567702016-08-31 16:35:01 -0700237 static_libs: [
238 "libtinyxml2",
239 "liblog",
240 "libbase",
241 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700242 shared: {
243 enabled: false,
244 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000245
246 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700247}
248
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800249cc_test_library {
250 name: "libBionicElfTlsTests",
251 defaults: ["bionic_tests_defaults"],
252 srcs: [
253 "elftls_test.cpp",
254 ],
255 include_dirs: [
256 "bionic/libc",
257 ],
258 shared: {
259 enabled: false,
260 },
261 cflags: [
262 "-fno-emulated-tls",
263 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700264 // With fuzzer builds, compiler instrumentation generates a reference to the
265 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
266 // library as an emutls symbol. The -fno-emulated-tls flag above configures
267 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
268 // symbol instead, which isn't defined. Disable the fuzzer for this test
269 // until the platform is switched to ELF TLS.
270 sanitize: {
271 fuzzer: false,
272 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800273}
274
275cc_test_library {
276 name: "libBionicElfTlsLoaderTests",
277 defaults: ["bionic_tests_defaults"],
278 srcs: [
279 "elftls_dl_test.cpp",
280 ],
281 include_dirs: [
282 "bionic/libc",
283 ],
284 static_libs: [
285 "liblog",
286 "libbase",
287 ],
288 shared: {
289 enabled: false,
290 },
291 cflags: [
292 "-fno-emulated-tls",
293 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700294 // With fuzzer builds, compiler instrumentation generates a reference to the
295 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
296 // library as an emutls symbol. The -fno-emulated-tls flag above configures
297 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
298 // symbol instead, which isn't defined. Disable the fuzzer for this test
299 // until the platform is switched to ELF TLS.
300 sanitize: {
301 fuzzer: false,
302 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800303}
304
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800305cc_test_library {
306 name: "libBionicFramePointerTests",
307 defaults: ["bionic_tests_defaults"],
308 srcs: [
309 "android_unsafe_frame_pointer_chase_test.cpp",
310 ],
311 include_dirs: [
312 "bionic/libc",
313 ],
314 cflags: [
315 "-fno-omit-frame-pointer",
316 ],
317}
318
Colin Cross2722ebb2016-07-11 16:20:06 -0700319// -----------------------------------------------------------------------------
320// Fortify tests.
321// -----------------------------------------------------------------------------
322
323cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700324 name: "bionic_clang_fortify_tests_w_flags",
325 cflags: [
326 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700327 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700328 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700329 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700330 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700331 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700332 "-Wno-strncat-size",
333 ],
334}
335
336cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700337 name: "bionic_fortify_tests_defaults",
338 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700339 "-U_FORTIFY_SOURCE",
340 ],
341 srcs: ["fortify_test_main.cpp"],
342 target: {
343 host: {
344 clang_cflags: ["-D__clang__"],
345 },
346 },
347}
348
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700349// Ensures that FORTIFY checks aren't run when ASAN is on.
350cc_test {
351 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700352 defaults: [
353 "bionic_clang_fortify_tests_w_flags",
354 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700355 cflags: [
356 "-Werror",
357 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700358 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700359 sanitize: {
360 address: true,
361 },
362 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700363}
364
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700365// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
366// it can confuse these tools pretty easily. If this builds successfully, then
367// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
368// enabled. The library that results from building this is meant to be unused.
369cc_test_library {
370 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700371 defaults: [
372 "bionic_clang_fortify_tests_w_flags",
373 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700374 cflags: [
375 "-Werror",
376 "-D_FORTIFY_SOURCE=2",
377 "-D__clang_analyzer__",
378 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700379 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700380}
381
Colin Cross2722ebb2016-07-11 16:20:06 -0700382cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700383 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800384 defaults: [
385 "bionic_fortify_tests_defaults",
386 "bionic_tests_defaults",
387 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700388 cflags: [
389 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800390 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700391 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700392 shared: {
393 enabled: false,
394 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700395}
396
397cc_test_library {
398 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800399 defaults: [
400 "bionic_fortify_tests_defaults",
401 "bionic_tests_defaults",
402 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700403 cflags: [
404 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800405 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700406 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700407 shared: {
408 enabled: false,
409 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700410}
411
George Burgess IV9a274102019-06-04 15:39:52 -0700412cc_defaults {
413 name: "bionic_new_fortify_tests_defaults",
414 defaults: [
415 "bionic_clang_fortify_tests_w_flags",
416 ],
417 cflags: [
418 "-U_FORTIFY_SOURCE",
419 ],
420 srcs: ["clang_fortify_tests.cpp"],
421 target: {
422 host: {
423 clang_cflags: ["-D__clang__"],
424 },
425 },
426}
427
428cc_test_library {
429 name: "libfortify1-new-tests-clang",
430 defaults: [
431 "bionic_new_fortify_tests_defaults",
432 "bionic_tests_defaults",
433 ],
434 cflags: [
435 "-D_FORTIFY_SOURCE=1",
436 "-DTEST_NAME=Fortify1_clang_new",
437 ],
438 shared: {
439 enabled: false,
440 },
441}
442
443cc_test_library {
444 name: "libfortify2-new-tests-clang",
445 defaults: [
446 "bionic_new_fortify_tests_defaults",
447 "bionic_tests_defaults",
448 ],
449 cflags: [
450 "-D_FORTIFY_SOURCE=2",
451 "-DTEST_NAME=Fortify2_clang_new",
452 ],
453 shared: {
454 enabled: false,
455 },
456}
457
458
Colin Cross2722ebb2016-07-11 16:20:06 -0700459// -----------------------------------------------------------------------------
460// Library of all tests (excluding the dynamic linker tests).
461// -----------------------------------------------------------------------------
462cc_test_library {
463 name: "libBionicTests",
464 defaults: ["bionic_tests_defaults"],
465 whole_static_libs: [
466 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800467 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800468 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700469 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700470 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700471 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700472 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700473 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700474 shared: {
475 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700476 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700477}
478
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700479cc_test_library {
480 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800481 defaults: [
482 "bionic_tests_defaults",
483 "llvm-defaults",
484 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700485 srcs: [
486 "atexit_test.cpp",
487 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700488 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700489 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700490 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700491 "pthread_dlfcn_test.cpp",
492 ],
493 static_libs: [
494 "libbase",
495 ],
496 include_dirs: [
497 "bionic/libc",
498 ],
499 shared: {
500 enabled: false,
501 },
502 target: {
503 android: {
504 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700505 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700506 "dlext_test.cpp",
507 "libdl_test.cpp",
508 ],
509 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800510 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400511 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700512 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800513 "libLLVMObject",
514 "libLLVMBitReader",
515 "libLLVMMC",
516 "libLLVMMCParser",
517 "libLLVMCore",
518 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700519 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800520 },
Jiyong Park02586a22017-05-20 01:01:24 +0900521 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700522}
523
Colin Cross2722ebb2016-07-11 16:20:06 -0700524// -----------------------------------------------------------------------------
525// Library of bionic customized gtest main function, with normal gtest output format,
526// which is needed by bionic cts test.
527// -----------------------------------------------------------------------------
528cc_test_library {
529 name: "libBionicCtsGtestMain",
530 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700531 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700532 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700533 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700534 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700535 shared: {
536 enabled: false,
537 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700538 whole_static_libs: [
539 "libgtest_isolated",
540 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700541}
542
543// -----------------------------------------------------------------------------
544// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900545// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
546// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700547// -----------------------------------------------------------------------------
548cc_defaults {
549 name: "bionic_unit_tests_defaults",
550 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800551 gtest: false,
552
553 defaults: [
554 "bionic_tests_defaults",
555 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700556
557 whole_static_libs: [
558 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700559 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800560 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700561 ],
562
563 static_libs: [
564 "libtinyxml2",
565 "liblog",
566 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800567 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700568 ],
569
570 srcs: [
571 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700572 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700573 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800574 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700575 "thread_local_test.cpp",
576 ],
577
578 conlyflags: [
579 "-fexceptions",
580 "-fnon-call-exceptions",
581 ],
582
583 ldflags: ["-Wl,--export-dynamic"],
584
585 include_dirs: ["bionic/libc"],
586
Yabin Cui1f553ea2017-01-13 12:31:59 -0800587 stl: "libc++_static",
588
Colin Cross2722ebb2016-07-11 16:20:06 -0700589 target: {
590 android: {
591 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100592 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700593 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100594 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700595 "libdl_preempt_test_1",
596 "libdl_preempt_test_2",
597 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800598 "libtest_elftls_shared_var",
599 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700600 ],
601 static_libs: [
602 // The order of these libraries matters, do not shuffle them.
603 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800604 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700605 "libziparchive",
606 "libz",
607 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800608 "libLLVMObject",
609 "libLLVMBitReader",
610 "libLLVMMC",
611 "libLLVMMCParser",
612 "libLLVMCore",
613 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700614 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700615 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700616 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700617 "-Wl,--enable-new-dtags",
618 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700619 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800620 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700621
622 required: [
623 "cfi_test_helper",
624 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800625 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700626 "exec_linker_helper",
627 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700628 "libtest_dt_runpath_a",
629 "libtest_dt_runpath_b",
630 "libtest_dt_runpath_c",
631 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900632 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700633 "libatest_simple_zip",
634 "libcfi-test",
635 "libcfi-test-bad",
636 "libdlext_test_different_soname",
637 "libdlext_test_fd",
638 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400639 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700640 "libdlext_test_runpath_zip_zipaligned",
641 "libdlext_test",
642 "libdlext_test_zip",
643 "libdlext_test_zip_zipaligned",
644 "libdl_preempt_test_1",
645 "libdl_preempt_test_2",
646 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700647 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800648 "librelocations-ANDROID_RELR",
649 "librelocations-ANDROID_REL",
650 "librelocations-RELR",
651 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700652 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700653 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700654 "libtest_atexit",
655 "libtest_check_order_dlsym_1_left",
656 "libtest_check_order_dlsym_2_right",
657 "libtest_check_order_dlsym_3_c",
658 "libtest_check_order_dlsym_a",
659 "libtest_check_order_dlsym_b",
660 "libtest_check_order_dlsym_d",
661 "libtest_check_order_dlsym",
662 "libtest_check_order_reloc_root_1",
663 "libtest_check_order_reloc_root_2",
664 "libtest_check_order_reloc_root",
665 "libtest_check_order_reloc_siblings_1",
666 "libtest_check_order_reloc_siblings_2",
667 "libtest_check_order_reloc_siblings_3",
668 "libtest_check_order_reloc_siblings_a",
669 "libtest_check_order_reloc_siblings_b",
670 "libtest_check_order_reloc_siblings_c_1",
671 "libtest_check_order_reloc_siblings_c_2",
672 "libtest_check_order_reloc_siblings_c",
673 "libtest_check_order_reloc_siblings_d",
674 "libtest_check_order_reloc_siblings_e",
675 "libtest_check_order_reloc_siblings_f",
676 "libtest_check_order_reloc_siblings",
677 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700678 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700679 "libtest_dlopen_from_ctor_main",
680 "libtest_dlopen_from_ctor",
681 "libtest_dlopen_weak_undefined_func",
682 "libtest_dlsym_df_1_global",
683 "libtest_dlsym_from_this_child",
684 "libtest_dlsym_from_this_grandchild",
685 "libtest_dlsym_from_this",
686 "libtest_dlsym_weak_func",
687 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800688 "libtest_elftls_dynamic",
689 "libtest_elftls_dynamic_filler_1",
690 "libtest_elftls_dynamic_filler_2",
691 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800692 "libtest_elftls_shared_var",
693 "libtest_elftls_shared_var_ie",
694 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700695 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700696 "libtest_ifunc_variable_impl",
697 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700698 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700699 "libtest_init_fini_order_child",
700 "libtest_init_fini_order_grand_child",
701 "libtest_init_fini_order_root2",
702 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700703 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700704 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700705 "libtest_missing_symbol_root",
706 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700707 "libtest_nodelete_1",
708 "libtest_nodelete_2",
709 "libtest_nodelete_dt_flags_1",
710 "libtest_pthread_atfork",
711 "libtest_relo_check_dt_needed_order_1",
712 "libtest_relo_check_dt_needed_order_2",
713 "libtest_relo_check_dt_needed_order",
714 "libtest_simple",
715 "libtest_two_parents_child",
716 "libtest_two_parents_parent1",
717 "libtest_two_parents_parent2",
718 "libtest_versioned_lib",
719 "libtest_versioned_libv1",
720 "libtest_versioned_libv2",
721 "libtest_versioned_otherlib_empty",
722 "libtest_versioned_otherlib",
723 "libtest_versioned_uselibv1",
724 "libtest_versioned_uselibv2_other",
725 "libtest_versioned_uselibv2",
726 "libtest_versioned_uselibv3_other",
727 "libtest_with_dependency_loop_a",
728 "libtest_with_dependency_loop_b",
729 "libtest_with_dependency_loop_c",
730 "libtest_with_dependency_loop",
731 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200732 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700733 "libtest_invalid-empty_shdr_table.so",
734 "libtest_invalid-rw_load_segment.so",
735 "libtest_invalid-unaligned_shdr_offset.so",
736 "libtest_invalid-zero_shdr_table_content.so",
737 "libtest_invalid-zero_shdr_table_offset.so",
738 "libtest_invalid-zero_shentsize.so",
739 "libtest_invalid-zero_shstrndx.so",
740 "libtest_invalid-textrels.so",
741 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700742 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200743 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700744 "preinit_getauxval_test_helper",
745 "preinit_syscall_test_helper",
746 "libnstest_private_external",
747 "libnstest_dlopened",
748 "libnstest_private",
749 "libnstest_root_not_isolated",
750 "libnstest_root",
751 "libnstest_public",
752 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800753 "libnstest_ns_a_public1",
754 "libnstest_ns_a_public1_internal",
755 "libnstest_ns_b_public2",
756 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800757 "ns_hidden_child_helper",
758 "libns_hidden_child_global",
759 "libns_hidden_child_internal",
760 "libns_hidden_child_public",
761 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800762 "libsegment_gap_inner",
763 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900764 "ld_preload_test_helper",
765 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700766 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900767 "ld_config_test_helper",
768 "ld_config_test_helper_lib1",
769 "ld_config_test_helper_lib2",
770 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700771 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700772}
773
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800774cc_test {
775 name: "bionic-unit-tests",
776 defaults: [
777 "bionic_unit_tests_defaults",
778 ],
779}
780
781cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700782 name: "bionic-stress-tests",
783 defaults: [
784 "bionic_tests_defaults",
785 ],
786
787 // For now, these tests run forever, so do not use the isolation framework.
788 isolated: false,
789
790 srcs: [
791 "malloc_stress_test.cpp",
792 ],
793
794 shared_libs: [
795 "libbase",
796 ],
797
798 target: {
799 android: {
800 static_libs: [
801 "libmeminfo",
802 "libprocinfo",
803 ],
804 },
805 },
806}
807
Colin Cross2722ebb2016-07-11 16:20:06 -0700808// -----------------------------------------------------------------------------
809// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900810// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
811// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700812// -----------------------------------------------------------------------------
813cc_test {
814 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700815 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700816 defaults: ["bionic_tests_defaults"],
817 host_supported: false,
818
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800819 srcs: [
820 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700821 "gtest_globals.cpp",
822 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800823
824 // The Bionic allocator has its own C++ API. It isn't packaged into its
825 // own library, so it can only be tested when it's part of libc.a.
826 "bionic_allocator_test.cpp",
827 ],
828 include_dirs: [
829 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800830 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700831 whole_static_libs: [
832 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700833 ],
834
835 static_libs: [
836 "libm",
837 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700838 "libdl",
839 "libtinyxml2",
840 "liblog",
841 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700842 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700843 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800844 "libtest_elftls_shared_var",
845 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700846 ],
847
848 static_executable: true,
849 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700850}
851
852// -----------------------------------------------------------------------------
853// Tests to run on the host and linked against glibc. Run with:
854// cd bionic/tests; mm bionic-unit-tests-glibc-run
855// -----------------------------------------------------------------------------
856
857cc_test_host {
858 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700859 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700860 defaults: ["bionic_tests_defaults"],
861
862 srcs: [
863 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700864 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700865 "dlfcn_test.cpp",
866 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700867 "gtest_globals.cpp",
868 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700869 "pthread_dlfcn_test.cpp",
870 ],
871
872 shared_libs: [
873 "libdl_preempt_test_1",
874 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700875 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800876 "libtest_elftls_shared_var",
877 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700878 ],
879
880 whole_static_libs: [
881 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800882 "libBionicElfTlsTests",
883 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700884 "libfortify1-tests-clang",
885 "libfortify2-tests-clang",
886 ],
887
888 static_libs: [
889 "libbase",
890 "liblog",
891 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700892 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700893 ],
894
895 host_ldlibs: [
896 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700897 "-lutil",
898 ],
899
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700900 include_dirs: [
901 "bionic/libc",
902 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700903
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800904 ldflags: [
905 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
906 "-Wl,--export-dynamic",
907 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700908
909 sanitize: {
910 never: false,
911 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700912
913 target: {
914 linux_bionic: {
915 enabled: false,
916 },
917 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700918}
919
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700920subdirs = ["*"]