blob: 6320eea35318ec6ba96a86def5efd3879e898016 [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",
Colin Cross2722ebb2016-07-11 16:20:06 -0700101 "fenv_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700102 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700103 "ftw_test.cpp",
104 "getauxval_test.cpp",
105 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700106 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700107 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800108 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700109 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700110 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800111 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700112 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700113 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800114 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700115 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700116 "libgen_basename_test.cpp",
117 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700118 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700119 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700120 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700121 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700122 "malloc_test.cpp",
123 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700124 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100125 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700126 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800127 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "netdb_test.cpp",
129 "net_if_test.cpp",
130 "netinet_ether_test.cpp",
131 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700132 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700133 "netinet_udp_test.cpp",
134 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700135 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700136 "pthread_test.cpp",
137 "pty_test.cpp",
138 "regex_test.cpp",
139 "resolv_test.cpp",
140 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800141 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700142 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700143 "search_test.cpp",
144 "semaphore_test.cpp",
145 "setjmp_test.cpp",
146 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700147 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700148 "stack_protector_test.cpp",
149 "stack_protector_test_helper.cpp",
150 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700151 "stdalign_test.cpp",
152 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700153 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700154 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 "stdint_test.cpp",
156 "stdio_nofortify_test.cpp",
157 "stdio_test.cpp",
158 "stdio_ext_test.cpp",
159 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700160 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700161 "string_nofortify_test.cpp",
162 "string_test.cpp",
163 "string_posix_strerror_r_test.cpp",
164 "strings_nofortify_test.cpp",
165 "strings_test.cpp",
166 "sstream_test.cpp",
167 "sys_epoll_test.cpp",
168 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700169 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700170 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700171 "sys_personality_test.cpp",
172 "sys_prctl_test.cpp",
173 "sys_procfs_test.cpp",
174 "sys_ptrace_test.cpp",
175 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700176 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700177 "sys_resource_test.cpp",
178 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700179 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700180 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700181 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800182 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700183 "sys_socket_test.cpp",
184 "sys_stat_test.cpp",
185 "sys_statvfs_test.cpp",
186 "sys_syscall_test.cpp",
187 "sys_sysinfo_test.cpp",
188 "sys_sysmacros_test.cpp",
189 "sys_time_test.cpp",
190 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700191 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700192 "sys_types_test.cpp",
193 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700194 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700195 "sys_vfs_test.cpp",
196 "sys_xattr_test.cpp",
197 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000198 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800199 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700200 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700201 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700202 "time_test.cpp",
203 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700204 "unistd_nofortify_test.cpp",
205 "unistd_test.cpp",
206 "utmp_test.cpp",
207 "wchar_test.cpp",
208 "wctype_test.cpp",
209 ],
210
211 include_dirs: [
212 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700213 ],
214
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700215 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700216 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800217 whole_static_libs: [
218 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700219 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800220 "libsystemproperties",
221 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800222 srcs: [
223 "tagged_pointers_test.cpp",
224 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700225 },
226 },
227
Dan Willemsen41567702016-08-31 16:35:01 -0700228 static_libs: [
229 "libtinyxml2",
230 "liblog",
231 "libbase",
232 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700233 shared: {
234 enabled: false,
235 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000236
237 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700238}
239
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800240cc_test_library {
241 name: "libBionicElfTlsTests",
242 defaults: ["bionic_tests_defaults"],
243 srcs: [
244 "elftls_test.cpp",
245 ],
246 include_dirs: [
247 "bionic/libc",
248 ],
249 shared: {
250 enabled: false,
251 },
252 cflags: [
253 "-fno-emulated-tls",
254 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700255 // With fuzzer builds, compiler instrumentation generates a reference to the
256 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
257 // library as an emutls symbol. The -fno-emulated-tls flag above configures
258 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
259 // symbol instead, which isn't defined. Disable the fuzzer for this test
260 // until the platform is switched to ELF TLS.
261 sanitize: {
262 fuzzer: false,
263 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800264}
265
266cc_test_library {
267 name: "libBionicElfTlsLoaderTests",
268 defaults: ["bionic_tests_defaults"],
269 srcs: [
270 "elftls_dl_test.cpp",
271 ],
272 include_dirs: [
273 "bionic/libc",
274 ],
275 static_libs: [
276 "liblog",
277 "libbase",
278 ],
279 shared: {
280 enabled: false,
281 },
282 cflags: [
283 "-fno-emulated-tls",
284 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700285 // With fuzzer builds, compiler instrumentation generates a reference to the
286 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
287 // library as an emutls symbol. The -fno-emulated-tls flag above configures
288 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
289 // symbol instead, which isn't defined. Disable the fuzzer for this test
290 // until the platform is switched to ELF TLS.
291 sanitize: {
292 fuzzer: false,
293 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800294}
295
Colin Cross2722ebb2016-07-11 16:20:06 -0700296// -----------------------------------------------------------------------------
297// Fortify tests.
298// -----------------------------------------------------------------------------
299
300cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700301 name: "bionic_clang_fortify_tests_w_flags",
302 cflags: [
303 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700304 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700305 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700306 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700307 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700308 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700309 "-Wno-strncat-size",
310 ],
311}
312
313cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700314 name: "bionic_fortify_tests_defaults",
315 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700316 "-U_FORTIFY_SOURCE",
317 ],
318 srcs: ["fortify_test_main.cpp"],
319 target: {
320 host: {
321 clang_cflags: ["-D__clang__"],
322 },
323 },
324}
325
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700326// Ensures that FORTIFY checks aren't run when ASAN is on.
327cc_test {
328 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700329 defaults: [
330 "bionic_clang_fortify_tests_w_flags",
331 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700332 cflags: [
333 "-Werror",
334 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700335 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700336 sanitize: {
337 address: true,
338 },
339 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700340}
341
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700342// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
343// it can confuse these tools pretty easily. If this builds successfully, then
344// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
345// enabled. The library that results from building this is meant to be unused.
346cc_test_library {
347 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700348 defaults: [
349 "bionic_clang_fortify_tests_w_flags",
350 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700351 cflags: [
352 "-Werror",
353 "-D_FORTIFY_SOURCE=2",
354 "-D__clang_analyzer__",
355 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700356 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700357}
358
Colin Cross2722ebb2016-07-11 16:20:06 -0700359cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700360 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800361 defaults: [
362 "bionic_fortify_tests_defaults",
363 "bionic_tests_defaults",
364 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700365 cflags: [
366 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800367 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700368 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700369 shared: {
370 enabled: false,
371 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700372}
373
374cc_test_library {
375 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800376 defaults: [
377 "bionic_fortify_tests_defaults",
378 "bionic_tests_defaults",
379 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700380 cflags: [
381 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800382 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700383 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700384 shared: {
385 enabled: false,
386 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700387}
388
George Burgess IV9a274102019-06-04 15:39:52 -0700389cc_defaults {
390 name: "bionic_new_fortify_tests_defaults",
391 defaults: [
392 "bionic_clang_fortify_tests_w_flags",
393 ],
394 cflags: [
395 "-U_FORTIFY_SOURCE",
396 ],
397 srcs: ["clang_fortify_tests.cpp"],
398 target: {
399 host: {
400 clang_cflags: ["-D__clang__"],
401 },
402 },
403}
404
405cc_test_library {
406 name: "libfortify1-new-tests-clang",
407 defaults: [
408 "bionic_new_fortify_tests_defaults",
409 "bionic_tests_defaults",
410 ],
411 cflags: [
412 "-D_FORTIFY_SOURCE=1",
413 "-DTEST_NAME=Fortify1_clang_new",
414 ],
415 shared: {
416 enabled: false,
417 },
418}
419
420cc_test_library {
421 name: "libfortify2-new-tests-clang",
422 defaults: [
423 "bionic_new_fortify_tests_defaults",
424 "bionic_tests_defaults",
425 ],
426 cflags: [
427 "-D_FORTIFY_SOURCE=2",
428 "-DTEST_NAME=Fortify2_clang_new",
429 ],
430 shared: {
431 enabled: false,
432 },
433}
434
435
Colin Cross2722ebb2016-07-11 16:20:06 -0700436// -----------------------------------------------------------------------------
437// Library of all tests (excluding the dynamic linker tests).
438// -----------------------------------------------------------------------------
439cc_test_library {
440 name: "libBionicTests",
441 defaults: ["bionic_tests_defaults"],
442 whole_static_libs: [
443 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800444 "libBionicElfTlsTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700445 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700446 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700447 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700448 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700449 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700450 shared: {
451 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700452 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700453}
454
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700455cc_test_library {
456 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800457 defaults: [
458 "bionic_tests_defaults",
459 "llvm-defaults",
460 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700461 srcs: [
462 "atexit_test.cpp",
463 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700464 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700465 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700466 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700467 "pthread_dlfcn_test.cpp",
468 ],
469 static_libs: [
470 "libbase",
471 ],
472 include_dirs: [
473 "bionic/libc",
474 ],
475 shared: {
476 enabled: false,
477 },
478 target: {
479 android: {
480 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700481 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700482 "dlext_test.cpp",
483 "libdl_test.cpp",
484 ],
485 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800486 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400487 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700488 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800489 "libLLVMObject",
490 "libLLVMBitReader",
491 "libLLVMMC",
492 "libLLVMMCParser",
493 "libLLVMCore",
494 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700495 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800496 },
Jiyong Park02586a22017-05-20 01:01:24 +0900497 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700498}
499
Colin Cross2722ebb2016-07-11 16:20:06 -0700500// -----------------------------------------------------------------------------
501// Library of bionic customized gtest main function, with normal gtest output format,
502// which is needed by bionic cts test.
503// -----------------------------------------------------------------------------
504cc_test_library {
505 name: "libBionicCtsGtestMain",
506 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700507 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700508 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700509 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700510 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700511 shared: {
512 enabled: false,
513 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700514 whole_static_libs: [
515 "libgtest_isolated",
516 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700517}
518
519// -----------------------------------------------------------------------------
520// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900521// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
522// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700523// -----------------------------------------------------------------------------
524cc_defaults {
525 name: "bionic_unit_tests_defaults",
526 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800527 gtest: false,
528
529 defaults: [
530 "bionic_tests_defaults",
531 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700532
533 whole_static_libs: [
534 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700535 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800536 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700537 ],
538
539 static_libs: [
540 "libtinyxml2",
541 "liblog",
542 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800543 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700544 ],
545
546 srcs: [
547 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700548 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700549 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800550 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700551 "thread_local_test.cpp",
552 ],
553
554 conlyflags: [
555 "-fexceptions",
556 "-fnon-call-exceptions",
557 ],
558
559 ldflags: ["-Wl,--export-dynamic"],
560
561 include_dirs: ["bionic/libc"],
562
Yabin Cui1f553ea2017-01-13 12:31:59 -0800563 stl: "libc++_static",
564
Colin Cross2722ebb2016-07-11 16:20:06 -0700565 target: {
566 android: {
567 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100568 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700569 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100570 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700571 "libdl_preempt_test_1",
572 "libdl_preempt_test_2",
573 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800574 "libtest_elftls_shared_var",
575 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700576 ],
577 static_libs: [
578 // The order of these libraries matters, do not shuffle them.
579 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800580 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700581 "libziparchive",
582 "libz",
583 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800584 "libLLVMObject",
585 "libLLVMBitReader",
586 "libLLVMMC",
587 "libLLVMMCParser",
588 "libLLVMCore",
589 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700590 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700591 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700592 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700593 "-Wl,--enable-new-dtags",
594 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700595 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800596 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700597
598 required: [
599 "cfi_test_helper",
600 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800601 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700602 "exec_linker_helper",
603 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700604 "libtest_dt_runpath_a",
605 "libtest_dt_runpath_b",
606 "libtest_dt_runpath_c",
607 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900608 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700609 "libatest_simple_zip",
610 "libcfi-test",
611 "libcfi-test-bad",
612 "libdlext_test_different_soname",
613 "libdlext_test_fd",
614 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400615 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700616 "libdlext_test_runpath_zip_zipaligned",
617 "libdlext_test",
618 "libdlext_test_zip",
619 "libdlext_test_zip_zipaligned",
620 "libdl_preempt_test_1",
621 "libdl_preempt_test_2",
622 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700623 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800624 "librelocations-ANDROID_RELR",
625 "librelocations-ANDROID_REL",
626 "librelocations-RELR",
627 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700628 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700629 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700630 "libtest_atexit",
631 "libtest_check_order_dlsym_1_left",
632 "libtest_check_order_dlsym_2_right",
633 "libtest_check_order_dlsym_3_c",
634 "libtest_check_order_dlsym_a",
635 "libtest_check_order_dlsym_b",
636 "libtest_check_order_dlsym_d",
637 "libtest_check_order_dlsym",
638 "libtest_check_order_reloc_root_1",
639 "libtest_check_order_reloc_root_2",
640 "libtest_check_order_reloc_root",
641 "libtest_check_order_reloc_siblings_1",
642 "libtest_check_order_reloc_siblings_2",
643 "libtest_check_order_reloc_siblings_3",
644 "libtest_check_order_reloc_siblings_a",
645 "libtest_check_order_reloc_siblings_b",
646 "libtest_check_order_reloc_siblings_c_1",
647 "libtest_check_order_reloc_siblings_c_2",
648 "libtest_check_order_reloc_siblings_c",
649 "libtest_check_order_reloc_siblings_d",
650 "libtest_check_order_reloc_siblings_e",
651 "libtest_check_order_reloc_siblings_f",
652 "libtest_check_order_reloc_siblings",
653 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700654 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700655 "libtest_dlopen_from_ctor_main",
656 "libtest_dlopen_from_ctor",
657 "libtest_dlopen_weak_undefined_func",
658 "libtest_dlsym_df_1_global",
659 "libtest_dlsym_from_this_child",
660 "libtest_dlsym_from_this_grandchild",
661 "libtest_dlsym_from_this",
662 "libtest_dlsym_weak_func",
663 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800664 "libtest_elftls_dynamic",
665 "libtest_elftls_dynamic_filler_1",
666 "libtest_elftls_dynamic_filler_2",
667 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800668 "libtest_elftls_shared_var",
669 "libtest_elftls_shared_var_ie",
670 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700671 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700672 "libtest_ifunc_variable_impl",
673 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700674 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700675 "libtest_init_fini_order_child",
676 "libtest_init_fini_order_grand_child",
677 "libtest_init_fini_order_root2",
678 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700679 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700680 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700681 "libtest_missing_symbol_root",
682 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700683 "libtest_nodelete_1",
684 "libtest_nodelete_2",
685 "libtest_nodelete_dt_flags_1",
686 "libtest_pthread_atfork",
687 "libtest_relo_check_dt_needed_order_1",
688 "libtest_relo_check_dt_needed_order_2",
689 "libtest_relo_check_dt_needed_order",
690 "libtest_simple",
691 "libtest_two_parents_child",
692 "libtest_two_parents_parent1",
693 "libtest_two_parents_parent2",
694 "libtest_versioned_lib",
695 "libtest_versioned_libv1",
696 "libtest_versioned_libv2",
697 "libtest_versioned_otherlib_empty",
698 "libtest_versioned_otherlib",
699 "libtest_versioned_uselibv1",
700 "libtest_versioned_uselibv2_other",
701 "libtest_versioned_uselibv2",
702 "libtest_versioned_uselibv3_other",
703 "libtest_with_dependency_loop_a",
704 "libtest_with_dependency_loop_b",
705 "libtest_with_dependency_loop_c",
706 "libtest_with_dependency_loop",
707 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200708 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700709 "libtest_invalid-empty_shdr_table.so",
710 "libtest_invalid-rw_load_segment.so",
711 "libtest_invalid-unaligned_shdr_offset.so",
712 "libtest_invalid-zero_shdr_table_content.so",
713 "libtest_invalid-zero_shdr_table_offset.so",
714 "libtest_invalid-zero_shentsize.so",
715 "libtest_invalid-zero_shstrndx.so",
716 "libtest_invalid-textrels.so",
717 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700718 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200719 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700720 "preinit_getauxval_test_helper",
721 "preinit_syscall_test_helper",
722 "libnstest_private_external",
723 "libnstest_dlopened",
724 "libnstest_private",
725 "libnstest_root_not_isolated",
726 "libnstest_root",
727 "libnstest_public",
728 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800729 "libnstest_ns_a_public1",
730 "libnstest_ns_a_public1_internal",
731 "libnstest_ns_b_public2",
732 "libnstest_ns_b_public3",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800733 "libsegment_gap_inner",
734 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900735 "ld_preload_test_helper",
736 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700737 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900738 "ld_config_test_helper",
739 "ld_config_test_helper_lib1",
740 "ld_config_test_helper_lib2",
741 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700742 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700743}
744
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800745cc_test {
746 name: "bionic-unit-tests",
747 defaults: [
748 "bionic_unit_tests_defaults",
749 ],
750}
751
752cc_test {
753 name: "bionic-unit-tests-scudo",
754 defaults: [
755 "bionic_unit_tests_defaults",
756 ],
757
758 shared_libs: [
759 "libc_scudo",
760 ],
761}
762
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700763cc_test {
764 name: "bionic-stress-tests",
765 defaults: [
766 "bionic_tests_defaults",
767 ],
768
769 // For now, these tests run forever, so do not use the isolation framework.
770 isolated: false,
771
772 srcs: [
773 "malloc_stress_test.cpp",
774 ],
775
776 shared_libs: [
777 "libbase",
778 ],
779
780 target: {
781 android: {
782 static_libs: [
783 "libmeminfo",
784 "libprocinfo",
785 ],
786 },
787 },
788}
789
Colin Cross2722ebb2016-07-11 16:20:06 -0700790// -----------------------------------------------------------------------------
791// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900792// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
793// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700794// -----------------------------------------------------------------------------
795cc_test {
796 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700797 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700798 defaults: ["bionic_tests_defaults"],
799 host_supported: false,
800
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800801 srcs: [
802 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700803 "gtest_globals.cpp",
804 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800805
806 // The Bionic allocator has its own C++ API. It isn't packaged into its
807 // own library, so it can only be tested when it's part of libc.a.
808 "bionic_allocator_test.cpp",
809 ],
810 include_dirs: [
811 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800812 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700813 whole_static_libs: [
814 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700815 ],
816
817 static_libs: [
818 "libm",
819 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700820 "libdl",
821 "libtinyxml2",
822 "liblog",
823 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700824 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700825 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800826 "libtest_elftls_shared_var",
827 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700828 ],
829
830 static_executable: true,
831 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700832}
833
834// -----------------------------------------------------------------------------
835// Tests to run on the host and linked against glibc. Run with:
836// cd bionic/tests; mm bionic-unit-tests-glibc-run
837// -----------------------------------------------------------------------------
838
839cc_test_host {
840 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700841 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700842 defaults: ["bionic_tests_defaults"],
843
844 srcs: [
845 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700846 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700847 "dlfcn_test.cpp",
848 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700849 "gtest_globals.cpp",
850 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700851 "pthread_dlfcn_test.cpp",
852 ],
853
854 shared_libs: [
855 "libdl_preempt_test_1",
856 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700857 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800858 "libtest_elftls_shared_var",
859 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700860 ],
861
862 whole_static_libs: [
863 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800864 "libBionicElfTlsTests",
865 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700866 "libfortify1-tests-clang",
867 "libfortify2-tests-clang",
868 ],
869
870 static_libs: [
871 "libbase",
872 "liblog",
873 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700874 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700875 ],
876
877 host_ldlibs: [
878 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700879 "-lutil",
880 ],
881
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700882 include_dirs: [
883 "bionic/libc",
884 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700885
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800886 ldflags: [
887 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
888 "-Wl,--export-dynamic",
889 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700890
891 sanitize: {
892 never: false,
893 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700894
895 target: {
896 linux_bionic: {
897 enabled: false,
898 },
899 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700900}
901
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700902subdirs = ["*"]