blob: e5301323b18b226be1dc6b6480197db1c900c951 [file] [log] [blame]
Colin Cross2722ebb2016-07-11 16:20:06 -07001//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "bionic_tests_defaults",
19 host_supported: true,
Tom Cherry60ddedf2018-02-20 15:40:02 -080020 cpp_std: "experimental",
Colin Cross2722ebb2016-07-11 16:20:06 -070021 target: {
22 darwin: {
23 enabled: false,
24 },
25 },
26 cflags: [
27 "-fstack-protector-all",
28 "-g",
29 "-Wall",
30 "-Wextra",
31 "-Wunused",
32 "-Werror",
33 "-fno-builtin",
34
35 // We want to test deprecated API too.
36 "-Wno-deprecated-declarations",
37
38 // For glibc.
39 "-D__STDC_LIMIT_MACROS",
40 ],
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080041 header_libs: ["bionic_libc_platform_headers"],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080042 // Make the bionic tests implicitly test bionic's shadow call stack support.
43 arch: {
44 arm64: {
45 cflags: ["-fsanitize=shadow-call-stack"],
46 },
47 },
Colin Cross2722ebb2016-07-11 16:20:06 -070048 stl: "libc++",
49 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080050 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070051 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090052 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080053
54 product_variables: {
55 experimental_mte: {
56 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
57 },
58 },
Colin Cross2722ebb2016-07-11 16:20:06 -070059}
60
61// -----------------------------------------------------------------------------
62// All standard tests.
63// -----------------------------------------------------------------------------
64
George Burgess IVde45dcb2018-03-16 14:15:01 -070065// Test diagnostics emitted by clang. The library that results is useless; we
66// just want to run '-Xclang -verify', which will fail if the diagnostics don't
67// match up with what the source file says they should be.
68cc_test_library {
69 name: "clang_diagnostic_tests",
70 cflags: [
71 "-Xclang",
72 "-verify",
73 ],
74 srcs: ["sys_ioctl_diag_test.cpp"],
75}
76
Colin Cross2722ebb2016-07-11 16:20:06 -070077cc_test_library {
78 name: "libBionicStandardTests",
79 defaults: ["bionic_tests_defaults"],
80 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080081 "__aeabi_read_tp_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030082 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070083 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070084 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070085 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070086 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070087 "buffer_tests.cpp",
88 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030089 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070090 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070091 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070092 "ctype_test.cpp",
93 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -070094 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080095 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -070096 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070097 "error_test.cpp",
98 "eventfd_test.cpp",
99 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700100 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800101 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700102 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800103 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700104 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700105 "ftw_test.cpp",
106 "getauxval_test.cpp",
107 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700108 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700109 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800110 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700111 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700112 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800113 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700114 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700115 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800116 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700117 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700118 "libgen_basename_test.cpp",
119 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700120 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700121 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700122 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700123 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700124 "malloc_test.cpp",
125 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700126 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100127 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800129 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700130 "netdb_test.cpp",
131 "net_if_test.cpp",
132 "netinet_ether_test.cpp",
133 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700134 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700135 "netinet_udp_test.cpp",
136 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700137 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700138 "pthread_test.cpp",
139 "pty_test.cpp",
140 "regex_test.cpp",
141 "resolv_test.cpp",
142 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800143 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700144 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700145 "search_test.cpp",
146 "semaphore_test.cpp",
147 "setjmp_test.cpp",
148 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700149 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700150 "stack_protector_test.cpp",
151 "stack_protector_test_helper.cpp",
152 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700153 "stdalign_test.cpp",
154 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700156 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700157 "stdint_test.cpp",
158 "stdio_nofortify_test.cpp",
159 "stdio_test.cpp",
160 "stdio_ext_test.cpp",
161 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700162 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700163 "string_nofortify_test.cpp",
164 "string_test.cpp",
165 "string_posix_strerror_r_test.cpp",
166 "strings_nofortify_test.cpp",
167 "strings_test.cpp",
168 "sstream_test.cpp",
169 "sys_epoll_test.cpp",
170 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700171 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700172 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700173 "sys_personality_test.cpp",
174 "sys_prctl_test.cpp",
175 "sys_procfs_test.cpp",
176 "sys_ptrace_test.cpp",
177 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700178 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700179 "sys_resource_test.cpp",
180 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700181 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700182 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700183 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800184 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700185 "sys_socket_test.cpp",
186 "sys_stat_test.cpp",
187 "sys_statvfs_test.cpp",
188 "sys_syscall_test.cpp",
189 "sys_sysinfo_test.cpp",
190 "sys_sysmacros_test.cpp",
191 "sys_time_test.cpp",
192 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700193 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700194 "sys_types_test.cpp",
195 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700196 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700197 "sys_vfs_test.cpp",
198 "sys_xattr_test.cpp",
199 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000200 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800201 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700202 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700203 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700204 "time_test.cpp",
205 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700206 "unistd_nofortify_test.cpp",
207 "unistd_test.cpp",
208 "utmp_test.cpp",
209 "wchar_test.cpp",
210 "wctype_test.cpp",
211 ],
212
213 include_dirs: [
214 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700215 ],
216
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700217 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700218 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800219 whole_static_libs: [
220 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700221 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800222 "libsystemproperties",
223 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800224 srcs: [
225 "tagged_pointers_test.cpp",
226 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700227 },
228 },
229
Dan Willemsen41567702016-08-31 16:35:01 -0700230 static_libs: [
231 "libtinyxml2",
232 "liblog",
233 "libbase",
234 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700235 shared: {
236 enabled: false,
237 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000238
239 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700240}
241
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800242cc_test_library {
243 name: "libBionicElfTlsTests",
244 defaults: ["bionic_tests_defaults"],
245 srcs: [
246 "elftls_test.cpp",
247 ],
248 include_dirs: [
249 "bionic/libc",
250 ],
251 shared: {
252 enabled: false,
253 },
254 cflags: [
255 "-fno-emulated-tls",
256 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700257 // With fuzzer builds, compiler instrumentation generates a reference to the
258 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
259 // library as an emutls symbol. The -fno-emulated-tls flag above configures
260 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
261 // symbol instead, which isn't defined. Disable the fuzzer for this test
262 // until the platform is switched to ELF TLS.
263 sanitize: {
264 fuzzer: false,
265 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800266}
267
268cc_test_library {
269 name: "libBionicElfTlsLoaderTests",
270 defaults: ["bionic_tests_defaults"],
271 srcs: [
272 "elftls_dl_test.cpp",
273 ],
274 include_dirs: [
275 "bionic/libc",
276 ],
277 static_libs: [
278 "liblog",
279 "libbase",
280 ],
281 shared: {
282 enabled: false,
283 },
284 cflags: [
285 "-fno-emulated-tls",
286 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700287 // With fuzzer builds, compiler instrumentation generates a reference to the
288 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
289 // library as an emutls symbol. The -fno-emulated-tls flag above configures
290 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
291 // symbol instead, which isn't defined. Disable the fuzzer for this test
292 // until the platform is switched to ELF TLS.
293 sanitize: {
294 fuzzer: false,
295 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800296}
297
Colin Cross2722ebb2016-07-11 16:20:06 -0700298// -----------------------------------------------------------------------------
299// Fortify tests.
300// -----------------------------------------------------------------------------
301
302cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700303 name: "bionic_clang_fortify_tests_w_flags",
304 cflags: [
305 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700306 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700307 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700308 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700309 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700310 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700311 "-Wno-strncat-size",
312 ],
313}
314
315cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700316 name: "bionic_fortify_tests_defaults",
317 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700318 "-U_FORTIFY_SOURCE",
319 ],
320 srcs: ["fortify_test_main.cpp"],
321 target: {
322 host: {
323 clang_cflags: ["-D__clang__"],
324 },
325 },
326}
327
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700328// Ensures that FORTIFY checks aren't run when ASAN is on.
329cc_test {
330 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700331 defaults: [
332 "bionic_clang_fortify_tests_w_flags",
333 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700334 cflags: [
335 "-Werror",
336 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700337 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700338 sanitize: {
339 address: true,
340 },
341 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700342}
343
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700344// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
345// it can confuse these tools pretty easily. If this builds successfully, then
346// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
347// enabled. The library that results from building this is meant to be unused.
348cc_test_library {
349 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700350 defaults: [
351 "bionic_clang_fortify_tests_w_flags",
352 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700353 cflags: [
354 "-Werror",
355 "-D_FORTIFY_SOURCE=2",
356 "-D__clang_analyzer__",
357 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700358 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700359}
360
Colin Cross2722ebb2016-07-11 16:20:06 -0700361cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700362 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800363 defaults: [
364 "bionic_fortify_tests_defaults",
365 "bionic_tests_defaults",
366 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700367 cflags: [
368 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800369 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700370 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700371 shared: {
372 enabled: false,
373 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700374}
375
376cc_test_library {
377 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800378 defaults: [
379 "bionic_fortify_tests_defaults",
380 "bionic_tests_defaults",
381 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700382 cflags: [
383 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800384 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700385 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700386 shared: {
387 enabled: false,
388 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700389}
390
George Burgess IV9a274102019-06-04 15:39:52 -0700391cc_defaults {
392 name: "bionic_new_fortify_tests_defaults",
393 defaults: [
394 "bionic_clang_fortify_tests_w_flags",
395 ],
396 cflags: [
397 "-U_FORTIFY_SOURCE",
398 ],
399 srcs: ["clang_fortify_tests.cpp"],
400 target: {
401 host: {
402 clang_cflags: ["-D__clang__"],
403 },
404 },
405}
406
407cc_test_library {
408 name: "libfortify1-new-tests-clang",
409 defaults: [
410 "bionic_new_fortify_tests_defaults",
411 "bionic_tests_defaults",
412 ],
413 cflags: [
414 "-D_FORTIFY_SOURCE=1",
415 "-DTEST_NAME=Fortify1_clang_new",
416 ],
417 shared: {
418 enabled: false,
419 },
420}
421
422cc_test_library {
423 name: "libfortify2-new-tests-clang",
424 defaults: [
425 "bionic_new_fortify_tests_defaults",
426 "bionic_tests_defaults",
427 ],
428 cflags: [
429 "-D_FORTIFY_SOURCE=2",
430 "-DTEST_NAME=Fortify2_clang_new",
431 ],
432 shared: {
433 enabled: false,
434 },
435}
436
437
Colin Cross2722ebb2016-07-11 16:20:06 -0700438// -----------------------------------------------------------------------------
439// Library of all tests (excluding the dynamic linker tests).
440// -----------------------------------------------------------------------------
441cc_test_library {
442 name: "libBionicTests",
443 defaults: ["bionic_tests_defaults"],
444 whole_static_libs: [
445 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800446 "libBionicElfTlsTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700447 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700448 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700449 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700450 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700451 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700452 shared: {
453 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700454 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700455}
456
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700457cc_test_library {
458 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800459 defaults: [
460 "bionic_tests_defaults",
461 "llvm-defaults",
462 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700463 srcs: [
464 "atexit_test.cpp",
465 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700466 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700467 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700468 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700469 "pthread_dlfcn_test.cpp",
470 ],
471 static_libs: [
472 "libbase",
473 ],
474 include_dirs: [
475 "bionic/libc",
476 ],
477 shared: {
478 enabled: false,
479 },
480 target: {
481 android: {
482 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700483 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700484 "dlext_test.cpp",
485 "libdl_test.cpp",
486 ],
487 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800488 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400489 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700490 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800491 "libLLVMObject",
492 "libLLVMBitReader",
493 "libLLVMMC",
494 "libLLVMMCParser",
495 "libLLVMCore",
496 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700497 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800498 },
Jiyong Park02586a22017-05-20 01:01:24 +0900499 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700500}
501
Colin Cross2722ebb2016-07-11 16:20:06 -0700502// -----------------------------------------------------------------------------
503// Library of bionic customized gtest main function, with normal gtest output format,
504// which is needed by bionic cts test.
505// -----------------------------------------------------------------------------
506cc_test_library {
507 name: "libBionicCtsGtestMain",
508 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700509 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700510 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700511 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700512 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700513 shared: {
514 enabled: false,
515 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700516 whole_static_libs: [
517 "libgtest_isolated",
518 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700519}
520
521// -----------------------------------------------------------------------------
522// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900523// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
524// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700525// -----------------------------------------------------------------------------
526cc_defaults {
527 name: "bionic_unit_tests_defaults",
528 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800529 gtest: false,
530
531 defaults: [
532 "bionic_tests_defaults",
533 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700534
535 whole_static_libs: [
536 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700537 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800538 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700539 ],
540
541 static_libs: [
542 "libtinyxml2",
543 "liblog",
544 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800545 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700546 ],
547
548 srcs: [
549 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700550 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700551 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800552 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700553 "thread_local_test.cpp",
554 ],
555
556 conlyflags: [
557 "-fexceptions",
558 "-fnon-call-exceptions",
559 ],
560
561 ldflags: ["-Wl,--export-dynamic"],
562
563 include_dirs: ["bionic/libc"],
564
Yabin Cui1f553ea2017-01-13 12:31:59 -0800565 stl: "libc++_static",
566
Colin Cross2722ebb2016-07-11 16:20:06 -0700567 target: {
568 android: {
569 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100570 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700571 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100572 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700573 "libdl_preempt_test_1",
574 "libdl_preempt_test_2",
575 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800576 "libtest_elftls_shared_var",
577 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700578 ],
579 static_libs: [
580 // The order of these libraries matters, do not shuffle them.
581 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800582 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700583 "libziparchive",
584 "libz",
585 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800586 "libLLVMObject",
587 "libLLVMBitReader",
588 "libLLVMMC",
589 "libLLVMMCParser",
590 "libLLVMCore",
591 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700592 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700593 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700594 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700595 "-Wl,--enable-new-dtags",
596 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700597 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800598 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700599
600 required: [
601 "cfi_test_helper",
602 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800603 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700604 "exec_linker_helper",
605 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700606 "libtest_dt_runpath_a",
607 "libtest_dt_runpath_b",
608 "libtest_dt_runpath_c",
609 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900610 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700611 "libatest_simple_zip",
612 "libcfi-test",
613 "libcfi-test-bad",
614 "libdlext_test_different_soname",
615 "libdlext_test_fd",
616 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400617 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700618 "libdlext_test_runpath_zip_zipaligned",
619 "libdlext_test",
620 "libdlext_test_zip",
621 "libdlext_test_zip_zipaligned",
622 "libdl_preempt_test_1",
623 "libdl_preempt_test_2",
624 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700625 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800626 "librelocations-ANDROID_RELR",
627 "librelocations-ANDROID_REL",
628 "librelocations-RELR",
629 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700630 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700631 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700632 "libtest_atexit",
633 "libtest_check_order_dlsym_1_left",
634 "libtest_check_order_dlsym_2_right",
635 "libtest_check_order_dlsym_3_c",
636 "libtest_check_order_dlsym_a",
637 "libtest_check_order_dlsym_b",
638 "libtest_check_order_dlsym_d",
639 "libtest_check_order_dlsym",
640 "libtest_check_order_reloc_root_1",
641 "libtest_check_order_reloc_root_2",
642 "libtest_check_order_reloc_root",
643 "libtest_check_order_reloc_siblings_1",
644 "libtest_check_order_reloc_siblings_2",
645 "libtest_check_order_reloc_siblings_3",
646 "libtest_check_order_reloc_siblings_a",
647 "libtest_check_order_reloc_siblings_b",
648 "libtest_check_order_reloc_siblings_c_1",
649 "libtest_check_order_reloc_siblings_c_2",
650 "libtest_check_order_reloc_siblings_c",
651 "libtest_check_order_reloc_siblings_d",
652 "libtest_check_order_reloc_siblings_e",
653 "libtest_check_order_reloc_siblings_f",
654 "libtest_check_order_reloc_siblings",
655 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700656 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700657 "libtest_dlopen_from_ctor_main",
658 "libtest_dlopen_from_ctor",
659 "libtest_dlopen_weak_undefined_func",
660 "libtest_dlsym_df_1_global",
661 "libtest_dlsym_from_this_child",
662 "libtest_dlsym_from_this_grandchild",
663 "libtest_dlsym_from_this",
664 "libtest_dlsym_weak_func",
665 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800666 "libtest_elftls_dynamic",
667 "libtest_elftls_dynamic_filler_1",
668 "libtest_elftls_dynamic_filler_2",
669 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800670 "libtest_elftls_shared_var",
671 "libtest_elftls_shared_var_ie",
672 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700673 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700674 "libtest_ifunc_variable_impl",
675 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700676 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700677 "libtest_init_fini_order_child",
678 "libtest_init_fini_order_grand_child",
679 "libtest_init_fini_order_root2",
680 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700681 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700682 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700683 "libtest_missing_symbol_root",
684 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700685 "libtest_nodelete_1",
686 "libtest_nodelete_2",
687 "libtest_nodelete_dt_flags_1",
688 "libtest_pthread_atfork",
689 "libtest_relo_check_dt_needed_order_1",
690 "libtest_relo_check_dt_needed_order_2",
691 "libtest_relo_check_dt_needed_order",
692 "libtest_simple",
693 "libtest_two_parents_child",
694 "libtest_two_parents_parent1",
695 "libtest_two_parents_parent2",
696 "libtest_versioned_lib",
697 "libtest_versioned_libv1",
698 "libtest_versioned_libv2",
699 "libtest_versioned_otherlib_empty",
700 "libtest_versioned_otherlib",
701 "libtest_versioned_uselibv1",
702 "libtest_versioned_uselibv2_other",
703 "libtest_versioned_uselibv2",
704 "libtest_versioned_uselibv3_other",
705 "libtest_with_dependency_loop_a",
706 "libtest_with_dependency_loop_b",
707 "libtest_with_dependency_loop_c",
708 "libtest_with_dependency_loop",
709 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200710 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700711 "libtest_invalid-empty_shdr_table.so",
712 "libtest_invalid-rw_load_segment.so",
713 "libtest_invalid-unaligned_shdr_offset.so",
714 "libtest_invalid-zero_shdr_table_content.so",
715 "libtest_invalid-zero_shdr_table_offset.so",
716 "libtest_invalid-zero_shentsize.so",
717 "libtest_invalid-zero_shstrndx.so",
718 "libtest_invalid-textrels.so",
719 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700720 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200721 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700722 "preinit_getauxval_test_helper",
723 "preinit_syscall_test_helper",
724 "libnstest_private_external",
725 "libnstest_dlopened",
726 "libnstest_private",
727 "libnstest_root_not_isolated",
728 "libnstest_root",
729 "libnstest_public",
730 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800731 "libnstest_ns_a_public1",
732 "libnstest_ns_a_public1_internal",
733 "libnstest_ns_b_public2",
734 "libnstest_ns_b_public3",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800735 "libsegment_gap_inner",
736 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900737 "ld_preload_test_helper",
738 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700739 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900740 "ld_config_test_helper",
741 "ld_config_test_helper_lib1",
742 "ld_config_test_helper_lib2",
743 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700744 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700745}
746
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800747cc_test {
748 name: "bionic-unit-tests",
749 defaults: [
750 "bionic_unit_tests_defaults",
751 ],
752}
753
754cc_test {
755 name: "bionic-unit-tests-scudo",
756 defaults: [
757 "bionic_unit_tests_defaults",
758 ],
759
760 shared_libs: [
761 "libc_scudo",
762 ],
763}
764
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700765cc_test {
766 name: "bionic-stress-tests",
767 defaults: [
768 "bionic_tests_defaults",
769 ],
770
771 // For now, these tests run forever, so do not use the isolation framework.
772 isolated: false,
773
774 srcs: [
775 "malloc_stress_test.cpp",
776 ],
777
778 shared_libs: [
779 "libbase",
780 ],
781
782 target: {
783 android: {
784 static_libs: [
785 "libmeminfo",
786 "libprocinfo",
787 ],
788 },
789 },
790}
791
Colin Cross2722ebb2016-07-11 16:20:06 -0700792// -----------------------------------------------------------------------------
793// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900794// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
795// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700796// -----------------------------------------------------------------------------
797cc_test {
798 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700799 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700800 defaults: ["bionic_tests_defaults"],
801 host_supported: false,
802
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800803 srcs: [
804 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700805 "gtest_globals.cpp",
806 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800807
808 // The Bionic allocator has its own C++ API. It isn't packaged into its
809 // own library, so it can only be tested when it's part of libc.a.
810 "bionic_allocator_test.cpp",
811 ],
812 include_dirs: [
813 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800814 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700815 whole_static_libs: [
816 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700817 ],
818
819 static_libs: [
820 "libm",
821 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700822 "libdl",
823 "libtinyxml2",
824 "liblog",
825 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700826 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700827 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800828 "libtest_elftls_shared_var",
829 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700830 ],
831
832 static_executable: true,
833 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700834}
835
836// -----------------------------------------------------------------------------
837// Tests to run on the host and linked against glibc. Run with:
838// cd bionic/tests; mm bionic-unit-tests-glibc-run
839// -----------------------------------------------------------------------------
840
841cc_test_host {
842 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700843 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700844 defaults: ["bionic_tests_defaults"],
845
846 srcs: [
847 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700848 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700849 "dlfcn_test.cpp",
850 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700851 "gtest_globals.cpp",
852 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700853 "pthread_dlfcn_test.cpp",
854 ],
855
856 shared_libs: [
857 "libdl_preempt_test_1",
858 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700859 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800860 "libtest_elftls_shared_var",
861 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700862 ],
863
864 whole_static_libs: [
865 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800866 "libBionicElfTlsTests",
867 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700868 "libfortify1-tests-clang",
869 "libfortify2-tests-clang",
870 ],
871
872 static_libs: [
873 "libbase",
874 "liblog",
875 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700876 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700877 ],
878
879 host_ldlibs: [
880 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700881 "-lutil",
882 ],
883
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700884 include_dirs: [
885 "bionic/libc",
886 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700887
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800888 ldflags: [
889 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
890 "-Wl,--export-dynamic",
891 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700892
893 sanitize: {
894 never: false,
895 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700896
897 target: {
898 linux_bionic: {
899 enabled: false,
900 },
901 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700902}
903
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700904subdirs = ["*"]