blob: f39aff0edc03210801b00c38a0fa0e31985f4f55 [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",
48 "-mbranch-protection=standard",
49 ],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080050 },
51 },
Colin Cross2722ebb2016-07-11 16:20:06 -070052 stl: "libc++",
53 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080054 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070055 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090056 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080057
58 product_variables: {
59 experimental_mte: {
60 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
61 },
62 },
Colin Cross2722ebb2016-07-11 16:20:06 -070063}
64
65// -----------------------------------------------------------------------------
66// All standard tests.
67// -----------------------------------------------------------------------------
68
George Burgess IVde45dcb2018-03-16 14:15:01 -070069// Test diagnostics emitted by clang. The library that results is useless; we
70// just want to run '-Xclang -verify', which will fail if the diagnostics don't
71// match up with what the source file says they should be.
72cc_test_library {
73 name: "clang_diagnostic_tests",
74 cflags: [
75 "-Xclang",
76 "-verify",
77 ],
78 srcs: ["sys_ioctl_diag_test.cpp"],
79}
80
Colin Cross2722ebb2016-07-11 16:20:06 -070081cc_test_library {
82 name: "libBionicStandardTests",
83 defaults: ["bionic_tests_defaults"],
84 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080085 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -080086 "__cxa_atexit_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030087 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070088 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070089 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070090 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070091 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070092 "buffer_tests.cpp",
93 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030094 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070095 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070096 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070097 "ctype_test.cpp",
98 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -070099 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800100 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700101 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700102 "error_test.cpp",
103 "eventfd_test.cpp",
104 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700105 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800106 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700107 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800108 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700109 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700110 "ftw_test.cpp",
111 "getauxval_test.cpp",
112 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700113 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700114 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800115 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700116 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700117 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800118 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700119 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700120 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800121 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700122 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700123 "libgen_basename_test.cpp",
124 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700125 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700126 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700127 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700128 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700129 "malloc_test.cpp",
130 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700131 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100132 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700133 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800134 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700135 "netdb_test.cpp",
136 "net_if_test.cpp",
137 "netinet_ether_test.cpp",
138 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700139 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700140 "netinet_udp_test.cpp",
141 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700142 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700143 "pthread_test.cpp",
144 "pty_test.cpp",
145 "regex_test.cpp",
146 "resolv_test.cpp",
147 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800148 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700149 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700150 "search_test.cpp",
151 "semaphore_test.cpp",
152 "setjmp_test.cpp",
153 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700154 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 "stack_protector_test.cpp",
156 "stack_protector_test_helper.cpp",
157 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700158 "stdalign_test.cpp",
159 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700160 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700161 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700162 "stdint_test.cpp",
163 "stdio_nofortify_test.cpp",
164 "stdio_test.cpp",
165 "stdio_ext_test.cpp",
166 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700167 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700168 "string_nofortify_test.cpp",
169 "string_test.cpp",
170 "string_posix_strerror_r_test.cpp",
171 "strings_nofortify_test.cpp",
172 "strings_test.cpp",
173 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800174 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700175 "sys_epoll_test.cpp",
176 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700177 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700178 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700179 "sys_personality_test.cpp",
180 "sys_prctl_test.cpp",
181 "sys_procfs_test.cpp",
182 "sys_ptrace_test.cpp",
183 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700184 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700185 "sys_resource_test.cpp",
186 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700187 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700188 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700189 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800190 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700191 "sys_socket_test.cpp",
192 "sys_stat_test.cpp",
193 "sys_statvfs_test.cpp",
194 "sys_syscall_test.cpp",
195 "sys_sysinfo_test.cpp",
196 "sys_sysmacros_test.cpp",
197 "sys_time_test.cpp",
198 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700199 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700200 "sys_types_test.cpp",
201 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700202 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700203 "sys_vfs_test.cpp",
204 "sys_xattr_test.cpp",
205 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000206 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800207 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700208 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700209 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700210 "time_test.cpp",
211 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700212 "unistd_nofortify_test.cpp",
213 "unistd_test.cpp",
214 "utmp_test.cpp",
215 "wchar_test.cpp",
216 "wctype_test.cpp",
217 ],
218
219 include_dirs: [
220 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700221 ],
222
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700223 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700224 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800225 whole_static_libs: [
226 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700227 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800228 "libsystemproperties",
229 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800230 srcs: [
231 "tagged_pointers_test.cpp",
232 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700233 },
234 },
235
Dan Willemsen41567702016-08-31 16:35:01 -0700236 static_libs: [
237 "libtinyxml2",
238 "liblog",
239 "libbase",
240 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700241 shared: {
242 enabled: false,
243 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000244
245 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700246}
247
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800248cc_test_library {
249 name: "libBionicElfTlsTests",
250 defaults: ["bionic_tests_defaults"],
251 srcs: [
252 "elftls_test.cpp",
253 ],
254 include_dirs: [
255 "bionic/libc",
256 ],
257 shared: {
258 enabled: false,
259 },
260 cflags: [
261 "-fno-emulated-tls",
262 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700263 // With fuzzer builds, compiler instrumentation generates a reference to the
264 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
265 // library as an emutls symbol. The -fno-emulated-tls flag above configures
266 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
267 // symbol instead, which isn't defined. Disable the fuzzer for this test
268 // until the platform is switched to ELF TLS.
269 sanitize: {
270 fuzzer: false,
271 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800272}
273
274cc_test_library {
275 name: "libBionicElfTlsLoaderTests",
276 defaults: ["bionic_tests_defaults"],
277 srcs: [
278 "elftls_dl_test.cpp",
279 ],
280 include_dirs: [
281 "bionic/libc",
282 ],
283 static_libs: [
284 "liblog",
285 "libbase",
286 ],
287 shared: {
288 enabled: false,
289 },
290 cflags: [
291 "-fno-emulated-tls",
292 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700293 // With fuzzer builds, compiler instrumentation generates a reference to the
294 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
295 // library as an emutls symbol. The -fno-emulated-tls flag above configures
296 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
297 // symbol instead, which isn't defined. Disable the fuzzer for this test
298 // until the platform is switched to ELF TLS.
299 sanitize: {
300 fuzzer: false,
301 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800302}
303
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800304cc_test_library {
305 name: "libBionicFramePointerTests",
306 defaults: ["bionic_tests_defaults"],
307 srcs: [
308 "android_unsafe_frame_pointer_chase_test.cpp",
309 ],
310 include_dirs: [
311 "bionic/libc",
312 ],
313 cflags: [
314 "-fno-omit-frame-pointer",
315 ],
316}
317
Colin Cross2722ebb2016-07-11 16:20:06 -0700318// -----------------------------------------------------------------------------
319// Fortify tests.
320// -----------------------------------------------------------------------------
321
322cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700323 name: "bionic_clang_fortify_tests_w_flags",
324 cflags: [
325 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700326 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700327 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700328 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700329 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700330 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700331 "-Wno-strncat-size",
332 ],
333}
334
335cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700336 name: "bionic_fortify_tests_defaults",
337 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700338 "-U_FORTIFY_SOURCE",
339 ],
340 srcs: ["fortify_test_main.cpp"],
341 target: {
342 host: {
343 clang_cflags: ["-D__clang__"],
344 },
345 },
346}
347
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700348// Ensures that FORTIFY checks aren't run when ASAN is on.
349cc_test {
350 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700351 defaults: [
352 "bionic_clang_fortify_tests_w_flags",
353 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700354 cflags: [
355 "-Werror",
356 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700357 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700358 sanitize: {
359 address: true,
360 },
361 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700362}
363
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700364// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
365// it can confuse these tools pretty easily. If this builds successfully, then
366// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
367// enabled. The library that results from building this is meant to be unused.
368cc_test_library {
369 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700370 defaults: [
371 "bionic_clang_fortify_tests_w_flags",
372 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700373 cflags: [
374 "-Werror",
375 "-D_FORTIFY_SOURCE=2",
376 "-D__clang_analyzer__",
377 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700378 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700379}
380
Colin Cross2722ebb2016-07-11 16:20:06 -0700381cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700382 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800383 defaults: [
384 "bionic_fortify_tests_defaults",
385 "bionic_tests_defaults",
386 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700387 cflags: [
388 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800389 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700390 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700391 shared: {
392 enabled: false,
393 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700394}
395
396cc_test_library {
397 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800398 defaults: [
399 "bionic_fortify_tests_defaults",
400 "bionic_tests_defaults",
401 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700402 cflags: [
403 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800404 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700405 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700406 shared: {
407 enabled: false,
408 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700409}
410
George Burgess IV9a274102019-06-04 15:39:52 -0700411cc_defaults {
412 name: "bionic_new_fortify_tests_defaults",
413 defaults: [
414 "bionic_clang_fortify_tests_w_flags",
415 ],
416 cflags: [
417 "-U_FORTIFY_SOURCE",
418 ],
419 srcs: ["clang_fortify_tests.cpp"],
420 target: {
421 host: {
422 clang_cflags: ["-D__clang__"],
423 },
424 },
425}
426
427cc_test_library {
428 name: "libfortify1-new-tests-clang",
429 defaults: [
430 "bionic_new_fortify_tests_defaults",
431 "bionic_tests_defaults",
432 ],
433 cflags: [
434 "-D_FORTIFY_SOURCE=1",
435 "-DTEST_NAME=Fortify1_clang_new",
436 ],
437 shared: {
438 enabled: false,
439 },
440}
441
442cc_test_library {
443 name: "libfortify2-new-tests-clang",
444 defaults: [
445 "bionic_new_fortify_tests_defaults",
446 "bionic_tests_defaults",
447 ],
448 cflags: [
449 "-D_FORTIFY_SOURCE=2",
450 "-DTEST_NAME=Fortify2_clang_new",
451 ],
452 shared: {
453 enabled: false,
454 },
455}
456
457
Colin Cross2722ebb2016-07-11 16:20:06 -0700458// -----------------------------------------------------------------------------
459// Library of all tests (excluding the dynamic linker tests).
460// -----------------------------------------------------------------------------
461cc_test_library {
462 name: "libBionicTests",
463 defaults: ["bionic_tests_defaults"],
464 whole_static_libs: [
465 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800466 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800467 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700468 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700469 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700470 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700471 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700472 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700473 shared: {
474 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700475 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700476}
477
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700478cc_test_library {
479 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800480 defaults: [
481 "bionic_tests_defaults",
482 "llvm-defaults",
483 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700484 srcs: [
485 "atexit_test.cpp",
486 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700487 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700488 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700489 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700490 "pthread_dlfcn_test.cpp",
491 ],
492 static_libs: [
493 "libbase",
494 ],
495 include_dirs: [
496 "bionic/libc",
497 ],
498 shared: {
499 enabled: false,
500 },
501 target: {
502 android: {
503 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700504 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700505 "dlext_test.cpp",
506 "libdl_test.cpp",
507 ],
508 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800509 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400510 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700511 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800512 "libLLVMObject",
513 "libLLVMBitReader",
514 "libLLVMMC",
515 "libLLVMMCParser",
516 "libLLVMCore",
517 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700518 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800519 },
Jiyong Park02586a22017-05-20 01:01:24 +0900520 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700521}
522
Colin Cross2722ebb2016-07-11 16:20:06 -0700523// -----------------------------------------------------------------------------
524// Library of bionic customized gtest main function, with normal gtest output format,
525// which is needed by bionic cts test.
526// -----------------------------------------------------------------------------
527cc_test_library {
528 name: "libBionicCtsGtestMain",
529 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700530 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700531 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700532 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700533 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700534 shared: {
535 enabled: false,
536 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700537 whole_static_libs: [
538 "libgtest_isolated",
539 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700540}
541
542// -----------------------------------------------------------------------------
543// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900544// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
545// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700546// -----------------------------------------------------------------------------
547cc_defaults {
548 name: "bionic_unit_tests_defaults",
549 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800550 gtest: false,
551
552 defaults: [
553 "bionic_tests_defaults",
554 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700555
556 whole_static_libs: [
557 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700558 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800559 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700560 ],
561
562 static_libs: [
563 "libtinyxml2",
564 "liblog",
565 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800566 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700567 ],
568
569 srcs: [
570 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700571 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700572 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800573 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700574 "thread_local_test.cpp",
575 ],
576
577 conlyflags: [
578 "-fexceptions",
579 "-fnon-call-exceptions",
580 ],
581
582 ldflags: ["-Wl,--export-dynamic"],
583
584 include_dirs: ["bionic/libc"],
585
Yabin Cui1f553ea2017-01-13 12:31:59 -0800586 stl: "libc++_static",
587
Colin Cross2722ebb2016-07-11 16:20:06 -0700588 target: {
589 android: {
590 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100591 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700592 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100593 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700594 "libdl_preempt_test_1",
595 "libdl_preempt_test_2",
596 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800597 "libtest_elftls_shared_var",
598 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700599 ],
600 static_libs: [
601 // The order of these libraries matters, do not shuffle them.
602 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800603 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700604 "libziparchive",
605 "libz",
606 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800607 "libLLVMObject",
608 "libLLVMBitReader",
609 "libLLVMMC",
610 "libLLVMMCParser",
611 "libLLVMCore",
612 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700613 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700614 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700615 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700616 "-Wl,--enable-new-dtags",
617 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700618 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800619 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700620
621 required: [
622 "cfi_test_helper",
623 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800624 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700625 "exec_linker_helper",
626 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700627 "libtest_dt_runpath_a",
628 "libtest_dt_runpath_b",
629 "libtest_dt_runpath_c",
630 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900631 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700632 "libatest_simple_zip",
633 "libcfi-test",
634 "libcfi-test-bad",
635 "libdlext_test_different_soname",
636 "libdlext_test_fd",
637 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400638 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700639 "libdlext_test_runpath_zip_zipaligned",
640 "libdlext_test",
641 "libdlext_test_zip",
642 "libdlext_test_zip_zipaligned",
643 "libdl_preempt_test_1",
644 "libdl_preempt_test_2",
645 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700646 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800647 "librelocations-ANDROID_RELR",
648 "librelocations-ANDROID_REL",
649 "librelocations-RELR",
650 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700651 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700652 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700653 "libtest_atexit",
654 "libtest_check_order_dlsym_1_left",
655 "libtest_check_order_dlsym_2_right",
656 "libtest_check_order_dlsym_3_c",
657 "libtest_check_order_dlsym_a",
658 "libtest_check_order_dlsym_b",
659 "libtest_check_order_dlsym_d",
660 "libtest_check_order_dlsym",
661 "libtest_check_order_reloc_root_1",
662 "libtest_check_order_reloc_root_2",
663 "libtest_check_order_reloc_root",
664 "libtest_check_order_reloc_siblings_1",
665 "libtest_check_order_reloc_siblings_2",
666 "libtest_check_order_reloc_siblings_3",
667 "libtest_check_order_reloc_siblings_a",
668 "libtest_check_order_reloc_siblings_b",
669 "libtest_check_order_reloc_siblings_c_1",
670 "libtest_check_order_reloc_siblings_c_2",
671 "libtest_check_order_reloc_siblings_c",
672 "libtest_check_order_reloc_siblings_d",
673 "libtest_check_order_reloc_siblings_e",
674 "libtest_check_order_reloc_siblings_f",
675 "libtest_check_order_reloc_siblings",
676 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700677 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700678 "libtest_dlopen_from_ctor_main",
679 "libtest_dlopen_from_ctor",
680 "libtest_dlopen_weak_undefined_func",
681 "libtest_dlsym_df_1_global",
682 "libtest_dlsym_from_this_child",
683 "libtest_dlsym_from_this_grandchild",
684 "libtest_dlsym_from_this",
685 "libtest_dlsym_weak_func",
686 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800687 "libtest_elftls_dynamic",
688 "libtest_elftls_dynamic_filler_1",
689 "libtest_elftls_dynamic_filler_2",
690 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800691 "libtest_elftls_shared_var",
692 "libtest_elftls_shared_var_ie",
693 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700694 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700695 "libtest_ifunc_variable_impl",
696 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700697 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700698 "libtest_init_fini_order_child",
699 "libtest_init_fini_order_grand_child",
700 "libtest_init_fini_order_root2",
701 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700702 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700703 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700704 "libtest_missing_symbol_root",
705 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700706 "libtest_nodelete_1",
707 "libtest_nodelete_2",
708 "libtest_nodelete_dt_flags_1",
709 "libtest_pthread_atfork",
710 "libtest_relo_check_dt_needed_order_1",
711 "libtest_relo_check_dt_needed_order_2",
712 "libtest_relo_check_dt_needed_order",
713 "libtest_simple",
714 "libtest_two_parents_child",
715 "libtest_two_parents_parent1",
716 "libtest_two_parents_parent2",
717 "libtest_versioned_lib",
718 "libtest_versioned_libv1",
719 "libtest_versioned_libv2",
720 "libtest_versioned_otherlib_empty",
721 "libtest_versioned_otherlib",
722 "libtest_versioned_uselibv1",
723 "libtest_versioned_uselibv2_other",
724 "libtest_versioned_uselibv2",
725 "libtest_versioned_uselibv3_other",
726 "libtest_with_dependency_loop_a",
727 "libtest_with_dependency_loop_b",
728 "libtest_with_dependency_loop_c",
729 "libtest_with_dependency_loop",
730 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200731 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700732 "libtest_invalid-empty_shdr_table.so",
733 "libtest_invalid-rw_load_segment.so",
734 "libtest_invalid-unaligned_shdr_offset.so",
735 "libtest_invalid-zero_shdr_table_content.so",
736 "libtest_invalid-zero_shdr_table_offset.so",
737 "libtest_invalid-zero_shentsize.so",
738 "libtest_invalid-zero_shstrndx.so",
739 "libtest_invalid-textrels.so",
740 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700741 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200742 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700743 "preinit_getauxval_test_helper",
744 "preinit_syscall_test_helper",
745 "libnstest_private_external",
746 "libnstest_dlopened",
747 "libnstest_private",
748 "libnstest_root_not_isolated",
749 "libnstest_root",
750 "libnstest_public",
751 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800752 "libnstest_ns_a_public1",
753 "libnstest_ns_a_public1_internal",
754 "libnstest_ns_b_public2",
755 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800756 "ns_hidden_child_helper",
757 "libns_hidden_child_global",
758 "libns_hidden_child_internal",
759 "libns_hidden_child_public",
760 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800761 "libsegment_gap_inner",
762 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900763 "ld_preload_test_helper",
764 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700765 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900766 "ld_config_test_helper",
767 "ld_config_test_helper_lib1",
768 "ld_config_test_helper_lib2",
769 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700770 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700771}
772
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800773cc_test {
774 name: "bionic-unit-tests",
775 defaults: [
776 "bionic_unit_tests_defaults",
777 ],
778}
779
780cc_test {
781 name: "bionic-unit-tests-scudo",
782 defaults: [
783 "bionic_unit_tests_defaults",
784 ],
785
786 shared_libs: [
787 "libc_scudo",
788 ],
789}
790
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700791cc_test {
792 name: "bionic-stress-tests",
793 defaults: [
794 "bionic_tests_defaults",
795 ],
796
797 // For now, these tests run forever, so do not use the isolation framework.
798 isolated: false,
799
800 srcs: [
801 "malloc_stress_test.cpp",
802 ],
803
804 shared_libs: [
805 "libbase",
806 ],
807
808 target: {
809 android: {
810 static_libs: [
811 "libmeminfo",
812 "libprocinfo",
813 ],
814 },
815 },
816}
817
Colin Cross2722ebb2016-07-11 16:20:06 -0700818// -----------------------------------------------------------------------------
819// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900820// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
821// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700822// -----------------------------------------------------------------------------
823cc_test {
824 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700825 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700826 defaults: ["bionic_tests_defaults"],
827 host_supported: false,
828
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800829 srcs: [
830 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700831 "gtest_globals.cpp",
832 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800833
834 // The Bionic allocator has its own C++ API. It isn't packaged into its
835 // own library, so it can only be tested when it's part of libc.a.
836 "bionic_allocator_test.cpp",
837 ],
838 include_dirs: [
839 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800840 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700841 whole_static_libs: [
842 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700843 ],
844
845 static_libs: [
846 "libm",
847 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700848 "libdl",
849 "libtinyxml2",
850 "liblog",
851 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700852 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700853 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800854 "libtest_elftls_shared_var",
855 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700856 ],
857
858 static_executable: true,
859 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700860}
861
862// -----------------------------------------------------------------------------
863// Tests to run on the host and linked against glibc. Run with:
864// cd bionic/tests; mm bionic-unit-tests-glibc-run
865// -----------------------------------------------------------------------------
866
867cc_test_host {
868 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700869 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700870 defaults: ["bionic_tests_defaults"],
871
872 srcs: [
873 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700874 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700875 "dlfcn_test.cpp",
876 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700877 "gtest_globals.cpp",
878 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700879 "pthread_dlfcn_test.cpp",
880 ],
881
882 shared_libs: [
883 "libdl_preempt_test_1",
884 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700885 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800886 "libtest_elftls_shared_var",
887 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700888 ],
889
890 whole_static_libs: [
891 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800892 "libBionicElfTlsTests",
893 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700894 "libfortify1-tests-clang",
895 "libfortify2-tests-clang",
896 ],
897
898 static_libs: [
899 "libbase",
900 "liblog",
901 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700902 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700903 ],
904
905 host_ldlibs: [
906 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700907 "-lutil",
908 ],
909
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700910 include_dirs: [
911 "bionic/libc",
912 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700913
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800914 ldflags: [
915 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
916 "-Wl,--export-dynamic",
917 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700918
919 sanitize: {
920 never: false,
921 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700922
923 target: {
924 linux_bionic: {
925 enabled: false,
926 },
927 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700928}
929
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700930subdirs = ["*"]