blob: 1ef7b0e1284d659ba345dba56668f85ab6362af9 [file] [log] [blame]
Colin Cross2722ebb2016-07-11 16:20:06 -07001//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "bionic_tests_defaults",
19 host_supported: true,
Tom Cherry60ddedf2018-02-20 15:40:02 -080020 cpp_std: "experimental",
Colin Cross2722ebb2016-07-11 16:20:06 -070021 target: {
22 darwin: {
23 enabled: false,
24 },
25 },
26 cflags: [
27 "-fstack-protector-all",
28 "-g",
29 "-Wall",
30 "-Wextra",
31 "-Wunused",
32 "-Werror",
33 "-fno-builtin",
34
35 // We want to test deprecated API too.
36 "-Wno-deprecated-declarations",
37
38 // For glibc.
39 "-D__STDC_LIMIT_MACROS",
40 ],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080041 // Make the bionic tests implicitly test bionic's shadow call stack support.
42 arch: {
43 arm64: {
44 cflags: ["-fsanitize=shadow-call-stack"],
45 },
46 },
Colin Cross2722ebb2016-07-11 16:20:06 -070047 stl: "libc++",
48 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080049 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070050 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090051 bootstrap: true,
Colin Cross2722ebb2016-07-11 16:20:06 -070052}
53
54// -----------------------------------------------------------------------------
55// All standard tests.
56// -----------------------------------------------------------------------------
57
George Burgess IVde45dcb2018-03-16 14:15:01 -070058// Test diagnostics emitted by clang. The library that results is useless; we
59// just want to run '-Xclang -verify', which will fail if the diagnostics don't
60// match up with what the source file says they should be.
61cc_test_library {
62 name: "clang_diagnostic_tests",
63 cflags: [
64 "-Xclang",
65 "-verify",
66 ],
67 srcs: ["sys_ioctl_diag_test.cpp"],
68}
69
Colin Cross2722ebb2016-07-11 16:20:06 -070070cc_test_library {
71 name: "libBionicStandardTests",
72 defaults: ["bionic_tests_defaults"],
73 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080074 "__aeabi_read_tp_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030075 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070076 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070077 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070078 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070079 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070080 "buffer_tests.cpp",
81 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030082 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070083 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070084 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070085 "ctype_test.cpp",
86 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -070087 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080088 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -070089 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070090 "error_test.cpp",
91 "eventfd_test.cpp",
92 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -070093 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -080094 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070095 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -080096 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -070097 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070098 "ftw_test.cpp",
99 "getauxval_test.cpp",
100 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700101 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700102 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800103 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700104 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700105 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800106 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700107 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700108 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800109 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700110 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700111 "libgen_basename_test.cpp",
112 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700113 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700114 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700115 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700116 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700117 "malloc_test.cpp",
118 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700119 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100120 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700121 "mntent_test.cpp",
122 "netdb_test.cpp",
123 "net_if_test.cpp",
124 "netinet_ether_test.cpp",
125 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700126 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700127 "netinet_udp_test.cpp",
128 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700129 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700130 "pthread_test.cpp",
131 "pty_test.cpp",
132 "regex_test.cpp",
133 "resolv_test.cpp",
134 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800135 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700136 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700137 "search_test.cpp",
138 "semaphore_test.cpp",
139 "setjmp_test.cpp",
140 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700141 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700142 "stack_protector_test.cpp",
143 "stack_protector_test_helper.cpp",
144 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700145 "stdalign_test.cpp",
146 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700147 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700148 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700149 "stdint_test.cpp",
150 "stdio_nofortify_test.cpp",
151 "stdio_test.cpp",
152 "stdio_ext_test.cpp",
153 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700154 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 "string_nofortify_test.cpp",
156 "string_test.cpp",
157 "string_posix_strerror_r_test.cpp",
158 "strings_nofortify_test.cpp",
159 "strings_test.cpp",
160 "sstream_test.cpp",
161 "sys_epoll_test.cpp",
162 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700163 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700164 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700165 "sys_personality_test.cpp",
166 "sys_prctl_test.cpp",
167 "sys_procfs_test.cpp",
168 "sys_ptrace_test.cpp",
169 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700170 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700171 "sys_resource_test.cpp",
172 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700173 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700174 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700175 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800176 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700177 "sys_socket_test.cpp",
178 "sys_stat_test.cpp",
179 "sys_statvfs_test.cpp",
180 "sys_syscall_test.cpp",
181 "sys_sysinfo_test.cpp",
182 "sys_sysmacros_test.cpp",
183 "sys_time_test.cpp",
184 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700185 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700186 "sys_types_test.cpp",
187 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700188 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700189 "sys_vfs_test.cpp",
190 "sys_xattr_test.cpp",
191 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000192 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800193 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700194 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700195 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700196 "time_test.cpp",
197 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700198 "unistd_nofortify_test.cpp",
199 "unistd_test.cpp",
200 "utmp_test.cpp",
201 "wchar_test.cpp",
202 "wctype_test.cpp",
203 ],
204
205 include_dirs: [
206 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700207 ],
208
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700209 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700210 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800211 whole_static_libs: [
212 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700213 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800214 "libsystemproperties",
215 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800216 srcs: [
217 "tagged_pointers_test.cpp",
218 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700219 },
220 },
221
Dan Willemsen41567702016-08-31 16:35:01 -0700222 static_libs: [
223 "libtinyxml2",
224 "liblog",
225 "libbase",
226 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700227 shared: {
228 enabled: false,
229 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000230
231 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700232}
233
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800234cc_test_library {
235 name: "libBionicElfTlsTests",
236 defaults: ["bionic_tests_defaults"],
237 srcs: [
238 "elftls_test.cpp",
239 ],
240 include_dirs: [
241 "bionic/libc",
242 ],
243 shared: {
244 enabled: false,
245 },
246 cflags: [
247 "-fno-emulated-tls",
248 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700249 // With fuzzer builds, compiler instrumentation generates a reference to the
250 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
251 // library as an emutls symbol. The -fno-emulated-tls flag above configures
252 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
253 // symbol instead, which isn't defined. Disable the fuzzer for this test
254 // until the platform is switched to ELF TLS.
255 sanitize: {
256 fuzzer: false,
257 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800258}
259
260cc_test_library {
261 name: "libBionicElfTlsLoaderTests",
262 defaults: ["bionic_tests_defaults"],
263 srcs: [
264 "elftls_dl_test.cpp",
265 ],
266 include_dirs: [
267 "bionic/libc",
268 ],
269 static_libs: [
270 "liblog",
271 "libbase",
272 ],
273 shared: {
274 enabled: false,
275 },
276 cflags: [
277 "-fno-emulated-tls",
278 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700279 // With fuzzer builds, compiler instrumentation generates a reference to the
280 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
281 // library as an emutls symbol. The -fno-emulated-tls flag above configures
282 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
283 // symbol instead, which isn't defined. Disable the fuzzer for this test
284 // until the platform is switched to ELF TLS.
285 sanitize: {
286 fuzzer: false,
287 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800288}
289
Colin Cross2722ebb2016-07-11 16:20:06 -0700290// -----------------------------------------------------------------------------
291// Fortify tests.
292// -----------------------------------------------------------------------------
293
294cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700295 name: "bionic_clang_fortify_tests_w_flags",
296 cflags: [
297 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700298 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700299 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700300 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700301 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700302 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700303 "-Wno-strncat-size",
304 ],
305}
306
307cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700308 name: "bionic_fortify_tests_defaults",
309 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700310 "-U_FORTIFY_SOURCE",
311 ],
312 srcs: ["fortify_test_main.cpp"],
313 target: {
314 host: {
315 clang_cflags: ["-D__clang__"],
316 },
317 },
318}
319
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700320// Ensures that FORTIFY checks aren't run when ASAN is on.
321cc_test {
322 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700323 defaults: [
324 "bionic_clang_fortify_tests_w_flags",
325 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700326 cflags: [
327 "-Werror",
328 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700329 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700330 sanitize: {
331 address: true,
332 },
333 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700334}
335
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700336// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
337// it can confuse these tools pretty easily. If this builds successfully, then
338// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
339// enabled. The library that results from building this is meant to be unused.
340cc_test_library {
341 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700342 defaults: [
343 "bionic_clang_fortify_tests_w_flags",
344 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700345 cflags: [
346 "-Werror",
347 "-D_FORTIFY_SOURCE=2",
348 "-D__clang_analyzer__",
349 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700350 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700351}
352
Colin Cross2722ebb2016-07-11 16:20:06 -0700353cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700354 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800355 defaults: [
356 "bionic_fortify_tests_defaults",
357 "bionic_tests_defaults",
358 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700359 cflags: [
360 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800361 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700362 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700363 shared: {
364 enabled: false,
365 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700366}
367
368cc_test_library {
369 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800370 defaults: [
371 "bionic_fortify_tests_defaults",
372 "bionic_tests_defaults",
373 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700374 cflags: [
375 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800376 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700377 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700378 shared: {
379 enabled: false,
380 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700381}
382
George Burgess IV9a274102019-06-04 15:39:52 -0700383cc_defaults {
384 name: "bionic_new_fortify_tests_defaults",
385 defaults: [
386 "bionic_clang_fortify_tests_w_flags",
387 ],
388 cflags: [
389 "-U_FORTIFY_SOURCE",
390 ],
391 srcs: ["clang_fortify_tests.cpp"],
392 target: {
393 host: {
394 clang_cflags: ["-D__clang__"],
395 },
396 },
397}
398
399cc_test_library {
400 name: "libfortify1-new-tests-clang",
401 defaults: [
402 "bionic_new_fortify_tests_defaults",
403 "bionic_tests_defaults",
404 ],
405 cflags: [
406 "-D_FORTIFY_SOURCE=1",
407 "-DTEST_NAME=Fortify1_clang_new",
408 ],
409 shared: {
410 enabled: false,
411 },
412}
413
414cc_test_library {
415 name: "libfortify2-new-tests-clang",
416 defaults: [
417 "bionic_new_fortify_tests_defaults",
418 "bionic_tests_defaults",
419 ],
420 cflags: [
421 "-D_FORTIFY_SOURCE=2",
422 "-DTEST_NAME=Fortify2_clang_new",
423 ],
424 shared: {
425 enabled: false,
426 },
427}
428
429
Colin Cross2722ebb2016-07-11 16:20:06 -0700430// -----------------------------------------------------------------------------
431// Library of all tests (excluding the dynamic linker tests).
432// -----------------------------------------------------------------------------
433cc_test_library {
434 name: "libBionicTests",
435 defaults: ["bionic_tests_defaults"],
436 whole_static_libs: [
437 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800438 "libBionicElfTlsTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700439 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700440 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700441 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700442 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700443 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700444 shared: {
445 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700446 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700447}
448
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700449cc_test_library {
450 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800451 defaults: [
452 "bionic_tests_defaults",
453 "llvm-defaults",
454 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700455 srcs: [
456 "atexit_test.cpp",
457 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700458 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700459 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700460 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700461 "pthread_dlfcn_test.cpp",
462 ],
463 static_libs: [
464 "libbase",
465 ],
466 include_dirs: [
467 "bionic/libc",
468 ],
469 shared: {
470 enabled: false,
471 },
472 target: {
473 android: {
474 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700475 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700476 "dlext_test.cpp",
477 "libdl_test.cpp",
478 ],
479 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800480 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400481 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700482 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800483 "libLLVMObject",
484 "libLLVMBitReader",
485 "libLLVMMC",
486 "libLLVMMCParser",
487 "libLLVMCore",
488 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700489 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800490 },
Jiyong Park02586a22017-05-20 01:01:24 +0900491 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700492}
493
Colin Cross2722ebb2016-07-11 16:20:06 -0700494// -----------------------------------------------------------------------------
495// Library of bionic customized gtest main function, with normal gtest output format,
496// which is needed by bionic cts test.
497// -----------------------------------------------------------------------------
498cc_test_library {
499 name: "libBionicCtsGtestMain",
500 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700501 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700502 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700503 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700504 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700505 shared: {
506 enabled: false,
507 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700508 whole_static_libs: [
509 "libgtest_isolated",
510 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700511}
512
513// -----------------------------------------------------------------------------
514// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900515// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
516// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700517// -----------------------------------------------------------------------------
518cc_defaults {
519 name: "bionic_unit_tests_defaults",
520 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800521 gtest: false,
522
523 defaults: [
524 "bionic_tests_defaults",
525 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700526
527 whole_static_libs: [
528 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700529 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800530 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700531 ],
532
533 static_libs: [
534 "libtinyxml2",
535 "liblog",
536 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800537 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700538 ],
539
540 srcs: [
541 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700542 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700543 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800544 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700545 "thread_local_test.cpp",
546 ],
547
548 conlyflags: [
549 "-fexceptions",
550 "-fnon-call-exceptions",
551 ],
552
553 ldflags: ["-Wl,--export-dynamic"],
554
555 include_dirs: ["bionic/libc"],
556
Yabin Cui1f553ea2017-01-13 12:31:59 -0800557 stl: "libc++_static",
558
Colin Cross2722ebb2016-07-11 16:20:06 -0700559 target: {
560 android: {
561 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100562 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700563 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100564 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700565 "libdl_preempt_test_1",
566 "libdl_preempt_test_2",
567 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800568 "libtest_elftls_shared_var",
569 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700570 ],
571 static_libs: [
572 // The order of these libraries matters, do not shuffle them.
573 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800574 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700575 "libziparchive",
576 "libz",
577 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800578 "libLLVMObject",
579 "libLLVMBitReader",
580 "libLLVMMC",
581 "libLLVMMCParser",
582 "libLLVMCore",
583 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700584 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700585 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700586 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700587 "-Wl,--enable-new-dtags",
588 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700589 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800590 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700591
592 required: [
593 "cfi_test_helper",
594 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800595 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700596 "exec_linker_helper",
597 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700598 "libtest_dt_runpath_a",
599 "libtest_dt_runpath_b",
600 "libtest_dt_runpath_c",
601 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900602 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700603 "libatest_simple_zip",
604 "libcfi-test",
605 "libcfi-test-bad",
606 "libdlext_test_different_soname",
607 "libdlext_test_fd",
608 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400609 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700610 "libdlext_test_runpath_zip_zipaligned",
611 "libdlext_test",
612 "libdlext_test_zip",
613 "libdlext_test_zip_zipaligned",
614 "libdl_preempt_test_1",
615 "libdl_preempt_test_2",
616 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700617 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800618 "librelocations-ANDROID_RELR",
619 "librelocations-ANDROID_REL",
620 "librelocations-RELR",
621 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700622 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700623 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700624 "libtest_atexit",
625 "libtest_check_order_dlsym_1_left",
626 "libtest_check_order_dlsym_2_right",
627 "libtest_check_order_dlsym_3_c",
628 "libtest_check_order_dlsym_a",
629 "libtest_check_order_dlsym_b",
630 "libtest_check_order_dlsym_d",
631 "libtest_check_order_dlsym",
632 "libtest_check_order_reloc_root_1",
633 "libtest_check_order_reloc_root_2",
634 "libtest_check_order_reloc_root",
635 "libtest_check_order_reloc_siblings_1",
636 "libtest_check_order_reloc_siblings_2",
637 "libtest_check_order_reloc_siblings_3",
638 "libtest_check_order_reloc_siblings_a",
639 "libtest_check_order_reloc_siblings_b",
640 "libtest_check_order_reloc_siblings_c_1",
641 "libtest_check_order_reloc_siblings_c_2",
642 "libtest_check_order_reloc_siblings_c",
643 "libtest_check_order_reloc_siblings_d",
644 "libtest_check_order_reloc_siblings_e",
645 "libtest_check_order_reloc_siblings_f",
646 "libtest_check_order_reloc_siblings",
647 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700648 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700649 "libtest_dlopen_from_ctor_main",
650 "libtest_dlopen_from_ctor",
651 "libtest_dlopen_weak_undefined_func",
652 "libtest_dlsym_df_1_global",
653 "libtest_dlsym_from_this_child",
654 "libtest_dlsym_from_this_grandchild",
655 "libtest_dlsym_from_this",
656 "libtest_dlsym_weak_func",
657 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800658 "libtest_elftls_dynamic",
659 "libtest_elftls_dynamic_filler_1",
660 "libtest_elftls_dynamic_filler_2",
661 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800662 "libtest_elftls_shared_var",
663 "libtest_elftls_shared_var_ie",
664 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700665 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700666 "libtest_ifunc_variable_impl",
667 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700668 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700669 "libtest_init_fini_order_child",
670 "libtest_init_fini_order_grand_child",
671 "libtest_init_fini_order_root2",
672 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700673 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700674 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700675 "libtest_missing_symbol_root",
676 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700677 "libtest_nodelete_1",
678 "libtest_nodelete_2",
679 "libtest_nodelete_dt_flags_1",
680 "libtest_pthread_atfork",
681 "libtest_relo_check_dt_needed_order_1",
682 "libtest_relo_check_dt_needed_order_2",
683 "libtest_relo_check_dt_needed_order",
684 "libtest_simple",
685 "libtest_two_parents_child",
686 "libtest_two_parents_parent1",
687 "libtest_two_parents_parent2",
688 "libtest_versioned_lib",
689 "libtest_versioned_libv1",
690 "libtest_versioned_libv2",
691 "libtest_versioned_otherlib_empty",
692 "libtest_versioned_otherlib",
693 "libtest_versioned_uselibv1",
694 "libtest_versioned_uselibv2_other",
695 "libtest_versioned_uselibv2",
696 "libtest_versioned_uselibv3_other",
697 "libtest_with_dependency_loop_a",
698 "libtest_with_dependency_loop_b",
699 "libtest_with_dependency_loop_c",
700 "libtest_with_dependency_loop",
701 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200702 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700703 "libtest_invalid-empty_shdr_table.so",
704 "libtest_invalid-rw_load_segment.so",
705 "libtest_invalid-unaligned_shdr_offset.so",
706 "libtest_invalid-zero_shdr_table_content.so",
707 "libtest_invalid-zero_shdr_table_offset.so",
708 "libtest_invalid-zero_shentsize.so",
709 "libtest_invalid-zero_shstrndx.so",
710 "libtest_invalid-textrels.so",
711 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700712 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200713 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700714 "preinit_getauxval_test_helper",
715 "preinit_syscall_test_helper",
716 "libnstest_private_external",
717 "libnstest_dlopened",
718 "libnstest_private",
719 "libnstest_root_not_isolated",
720 "libnstest_root",
721 "libnstest_public",
722 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800723 "libnstest_ns_a_public1",
724 "libnstest_ns_a_public1_internal",
725 "libnstest_ns_b_public2",
726 "libnstest_ns_b_public3",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800727 "libsegment_gap_inner",
728 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900729 "ld_preload_test_helper",
730 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700731 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900732 "ld_config_test_helper",
733 "ld_config_test_helper_lib1",
734 "ld_config_test_helper_lib2",
735 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700736 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700737}
738
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800739cc_test {
740 name: "bionic-unit-tests",
741 defaults: [
742 "bionic_unit_tests_defaults",
743 ],
744}
745
746cc_test {
747 name: "bionic-unit-tests-scudo",
748 defaults: [
749 "bionic_unit_tests_defaults",
750 ],
751
752 shared_libs: [
753 "libc_scudo",
754 ],
755}
756
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700757cc_test {
758 name: "bionic-stress-tests",
759 defaults: [
760 "bionic_tests_defaults",
761 ],
762
763 // For now, these tests run forever, so do not use the isolation framework.
764 isolated: false,
765
766 srcs: [
767 "malloc_stress_test.cpp",
768 ],
769
770 shared_libs: [
771 "libbase",
772 ],
773
774 target: {
775 android: {
776 static_libs: [
777 "libmeminfo",
778 "libprocinfo",
779 ],
780 },
781 },
782}
783
Colin Cross2722ebb2016-07-11 16:20:06 -0700784// -----------------------------------------------------------------------------
785// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900786// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
787// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700788// -----------------------------------------------------------------------------
789cc_test {
790 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700791 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700792 defaults: ["bionic_tests_defaults"],
793 host_supported: false,
794
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800795 srcs: [
796 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700797 "gtest_globals.cpp",
798 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800799
800 // The Bionic allocator has its own C++ API. It isn't packaged into its
801 // own library, so it can only be tested when it's part of libc.a.
802 "bionic_allocator_test.cpp",
803 ],
804 include_dirs: [
805 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800806 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700807 whole_static_libs: [
808 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700809 ],
810
811 static_libs: [
812 "libm",
813 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700814 "libdl",
815 "libtinyxml2",
816 "liblog",
817 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700818 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700819 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800820 "libtest_elftls_shared_var",
821 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700822 ],
823
824 static_executable: true,
825 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700826}
827
828// -----------------------------------------------------------------------------
829// Tests to run on the host and linked against glibc. Run with:
830// cd bionic/tests; mm bionic-unit-tests-glibc-run
831// -----------------------------------------------------------------------------
832
833cc_test_host {
834 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700835 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700836 defaults: ["bionic_tests_defaults"],
837
838 srcs: [
839 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700840 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700841 "dlfcn_test.cpp",
842 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700843 "gtest_globals.cpp",
844 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700845 "pthread_dlfcn_test.cpp",
846 ],
847
848 shared_libs: [
849 "libdl_preempt_test_1",
850 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700851 "libdl_test_df_1_global",
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 whole_static_libs: [
857 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800858 "libBionicElfTlsTests",
859 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700860 "libfortify1-tests-clang",
861 "libfortify2-tests-clang",
862 ],
863
864 static_libs: [
865 "libbase",
866 "liblog",
867 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700868 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700869 ],
870
871 host_ldlibs: [
872 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700873 "-lutil",
874 ],
875
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700876 include_dirs: [
877 "bionic/libc",
878 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700879
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800880 ldflags: [
881 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
882 "-Wl,--export-dynamic",
883 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700884
885 sanitize: {
886 never: false,
887 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700888
889 target: {
890 linux_bionic: {
891 enabled: false,
892 },
893 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700894}
895
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700896subdirs = ["*"]