blob: f0fe5e6251fe19613fb38a136867ca249c12b3de [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",
Colin Cross2722ebb2016-07-11 16:20:06 -070094 "fenv_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -070095 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070096 "ftw_test.cpp",
97 "getauxval_test.cpp",
98 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -070099 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700100 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800101 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700102 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700103 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800104 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700105 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700106 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800107 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700108 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700109 "libgen_basename_test.cpp",
110 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700111 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700112 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700113 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700114 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700115 "malloc_test.cpp",
116 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700117 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100118 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700119 "mntent_test.cpp",
120 "netdb_test.cpp",
121 "net_if_test.cpp",
122 "netinet_ether_test.cpp",
123 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700124 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700125 "netinet_udp_test.cpp",
126 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700127 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "pthread_test.cpp",
129 "pty_test.cpp",
130 "regex_test.cpp",
131 "resolv_test.cpp",
132 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800133 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700134 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700135 "search_test.cpp",
136 "semaphore_test.cpp",
137 "setjmp_test.cpp",
138 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700139 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700140 "stack_protector_test.cpp",
141 "stack_protector_test_helper.cpp",
142 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700143 "stdalign_test.cpp",
144 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700145 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700146 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700147 "stdint_test.cpp",
148 "stdio_nofortify_test.cpp",
149 "stdio_test.cpp",
150 "stdio_ext_test.cpp",
151 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700152 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700153 "string_nofortify_test.cpp",
154 "string_test.cpp",
155 "string_posix_strerror_r_test.cpp",
156 "strings_nofortify_test.cpp",
157 "strings_test.cpp",
158 "sstream_test.cpp",
159 "sys_epoll_test.cpp",
160 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700161 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700162 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700163 "sys_personality_test.cpp",
164 "sys_prctl_test.cpp",
165 "sys_procfs_test.cpp",
166 "sys_ptrace_test.cpp",
167 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700168 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700169 "sys_resource_test.cpp",
170 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700171 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700172 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700173 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800174 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700175 "sys_socket_test.cpp",
176 "sys_stat_test.cpp",
177 "sys_statvfs_test.cpp",
178 "sys_syscall_test.cpp",
179 "sys_sysinfo_test.cpp",
180 "sys_sysmacros_test.cpp",
181 "sys_time_test.cpp",
182 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700183 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700184 "sys_types_test.cpp",
185 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700186 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700187 "sys_vfs_test.cpp",
188 "sys_xattr_test.cpp",
189 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000190 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800191 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700192 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700193 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700194 "time_test.cpp",
195 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700196 "unistd_nofortify_test.cpp",
197 "unistd_test.cpp",
198 "utmp_test.cpp",
199 "wchar_test.cpp",
200 "wctype_test.cpp",
201 ],
202
203 include_dirs: [
204 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700205 ],
206
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700207 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700208 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800209 whole_static_libs: [
210 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700211 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800212 "libsystemproperties",
213 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700214 },
215 },
216
Dan Willemsen41567702016-08-31 16:35:01 -0700217 static_libs: [
218 "libtinyxml2",
219 "liblog",
220 "libbase",
221 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700222 shared: {
223 enabled: false,
224 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000225
226 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700227}
228
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800229cc_test_library {
230 name: "libBionicElfTlsTests",
231 defaults: ["bionic_tests_defaults"],
232 srcs: [
233 "elftls_test.cpp",
234 ],
235 include_dirs: [
236 "bionic/libc",
237 ],
238 shared: {
239 enabled: false,
240 },
241 cflags: [
242 "-fno-emulated-tls",
243 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700244 // With fuzzer builds, compiler instrumentation generates a reference to the
245 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
246 // library as an emutls symbol. The -fno-emulated-tls flag above configures
247 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
248 // symbol instead, which isn't defined. Disable the fuzzer for this test
249 // until the platform is switched to ELF TLS.
250 sanitize: {
251 fuzzer: false,
252 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800253}
254
255cc_test_library {
256 name: "libBionicElfTlsLoaderTests",
257 defaults: ["bionic_tests_defaults"],
258 srcs: [
259 "elftls_dl_test.cpp",
260 ],
261 include_dirs: [
262 "bionic/libc",
263 ],
264 static_libs: [
265 "liblog",
266 "libbase",
267 ],
268 shared: {
269 enabled: false,
270 },
271 cflags: [
272 "-fno-emulated-tls",
273 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700274 // With fuzzer builds, compiler instrumentation generates a reference to the
275 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
276 // library as an emutls symbol. The -fno-emulated-tls flag above configures
277 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
278 // symbol instead, which isn't defined. Disable the fuzzer for this test
279 // until the platform is switched to ELF TLS.
280 sanitize: {
281 fuzzer: false,
282 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800283}
284
Colin Cross2722ebb2016-07-11 16:20:06 -0700285// -----------------------------------------------------------------------------
286// Fortify tests.
287// -----------------------------------------------------------------------------
288
289cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700290 name: "bionic_clang_fortify_tests_w_flags",
291 cflags: [
292 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700293 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700294 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700295 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700296 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700297 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700298 "-Wno-strncat-size",
299 ],
300}
301
302cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700303 name: "bionic_fortify_tests_defaults",
304 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700305 "-U_FORTIFY_SOURCE",
306 ],
307 srcs: ["fortify_test_main.cpp"],
308 target: {
309 host: {
310 clang_cflags: ["-D__clang__"],
311 },
312 },
313}
314
George Burgess IVd9551db2017-08-17 18:51:02 -0700315// If building this fails, then we have both FORTIFY and ASAN enabled, which
316// isn't desirable. (Ideally, we'd emit FORTIFY diagnostics even with ASAN
317// enabled, but that's not a reality today.) This is meant to be otherwise
318// unused.
319cc_test_library {
320 name: "fortify_disabled_for_asan",
George Burgess IV9a274102019-06-04 15:39:52 -0700321 defaults: [
322 "bionic_clang_fortify_tests_w_flags",
323 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700324 cflags: [
325 "-Werror",
326 "-D_FORTIFY_SOURCE=2",
327 // "sanitize: address" doesn't work on platforms where libasan isn't
328 // enabled. Since the intent is just to build this, we can get away with
329 // passing this flag on its own.
330 "-fsanitize=address",
331 ],
332 // Ignore that we don't have ASAN symbols linked in.
333 allow_undefined_symbols: true,
George Burgess IV9a274102019-06-04 15:39:52 -0700334 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700335}
336
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700337// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
338// it can confuse these tools pretty easily. If this builds successfully, then
339// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
340// enabled. The library that results from building this is meant to be unused.
341cc_test_library {
342 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700343 defaults: [
344 "bionic_clang_fortify_tests_w_flags",
345 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700346 cflags: [
347 "-Werror",
348 "-D_FORTIFY_SOURCE=2",
349 "-D__clang_analyzer__",
350 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700351 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700352}
353
Colin Cross2722ebb2016-07-11 16:20:06 -0700354cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700355 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800356 defaults: [
357 "bionic_fortify_tests_defaults",
358 "bionic_tests_defaults",
359 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700360 cflags: [
361 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800362 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700363 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700364 shared: {
365 enabled: false,
366 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700367}
368
369cc_test_library {
370 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800371 defaults: [
372 "bionic_fortify_tests_defaults",
373 "bionic_tests_defaults",
374 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700375 cflags: [
376 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800377 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700378 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700379 shared: {
380 enabled: false,
381 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700382}
383
George Burgess IV9a274102019-06-04 15:39:52 -0700384cc_defaults {
385 name: "bionic_new_fortify_tests_defaults",
386 defaults: [
387 "bionic_clang_fortify_tests_w_flags",
388 ],
389 cflags: [
390 "-U_FORTIFY_SOURCE",
391 ],
392 srcs: ["clang_fortify_tests.cpp"],
393 target: {
394 host: {
395 clang_cflags: ["-D__clang__"],
396 },
397 },
398}
399
400cc_test_library {
401 name: "libfortify1-new-tests-clang",
402 defaults: [
403 "bionic_new_fortify_tests_defaults",
404 "bionic_tests_defaults",
405 ],
406 cflags: [
407 "-D_FORTIFY_SOURCE=1",
408 "-DTEST_NAME=Fortify1_clang_new",
409 ],
410 shared: {
411 enabled: false,
412 },
413}
414
415cc_test_library {
416 name: "libfortify2-new-tests-clang",
417 defaults: [
418 "bionic_new_fortify_tests_defaults",
419 "bionic_tests_defaults",
420 ],
421 cflags: [
422 "-D_FORTIFY_SOURCE=2",
423 "-DTEST_NAME=Fortify2_clang_new",
424 ],
425 shared: {
426 enabled: false,
427 },
428}
429
430
Colin Cross2722ebb2016-07-11 16:20:06 -0700431// -----------------------------------------------------------------------------
432// Library of all tests (excluding the dynamic linker tests).
433// -----------------------------------------------------------------------------
434cc_test_library {
435 name: "libBionicTests",
436 defaults: ["bionic_tests_defaults"],
437 whole_static_libs: [
438 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800439 "libBionicElfTlsTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700440 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700441 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700442 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700443 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700444 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700445 shared: {
446 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700447 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700448}
449
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700450cc_test_library {
451 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800452 defaults: [
453 "bionic_tests_defaults",
454 "llvm-defaults",
455 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700456 srcs: [
457 "atexit_test.cpp",
458 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700459 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700460 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700461 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700462 "pthread_dlfcn_test.cpp",
463 ],
464 static_libs: [
465 "libbase",
466 ],
467 include_dirs: [
468 "bionic/libc",
469 ],
470 shared: {
471 enabled: false,
472 },
473 target: {
474 android: {
475 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700476 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700477 "dlext_test.cpp",
478 "libdl_test.cpp",
479 ],
480 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800481 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400482 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700483 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800484 "libLLVMObject",
485 "libLLVMBitReader",
486 "libLLVMMC",
487 "libLLVMMCParser",
488 "libLLVMCore",
489 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700490 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800491 },
Jiyong Park02586a22017-05-20 01:01:24 +0900492 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700493}
494
Colin Cross2722ebb2016-07-11 16:20:06 -0700495// -----------------------------------------------------------------------------
496// Library of bionic customized gtest main function, with normal gtest output format,
497// which is needed by bionic cts test.
498// -----------------------------------------------------------------------------
499cc_test_library {
500 name: "libBionicCtsGtestMain",
501 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700502 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700503 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700504 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700505 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700506 shared: {
507 enabled: false,
508 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700509 whole_static_libs: [
510 "libgtest_isolated",
511 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700512}
513
514// -----------------------------------------------------------------------------
515// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900516// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
517// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700518// -----------------------------------------------------------------------------
519cc_defaults {
520 name: "bionic_unit_tests_defaults",
521 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800522 gtest: false,
523
524 defaults: [
525 "bionic_tests_defaults",
526 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700527
528 whole_static_libs: [
529 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700530 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800531 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700532 ],
533
534 static_libs: [
535 "libtinyxml2",
536 "liblog",
537 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800538 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700539 ],
540
541 srcs: [
542 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700543 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700544 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800545 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700546 "thread_local_test.cpp",
547 ],
548
549 conlyflags: [
550 "-fexceptions",
551 "-fnon-call-exceptions",
552 ],
553
554 ldflags: ["-Wl,--export-dynamic"],
555
556 include_dirs: ["bionic/libc"],
557
Yabin Cui1f553ea2017-01-13 12:31:59 -0800558 stl: "libc++_static",
559
Colin Cross2722ebb2016-07-11 16:20:06 -0700560 target: {
561 android: {
562 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100563 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700564 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100565 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700566 "libdl_preempt_test_1",
567 "libdl_preempt_test_2",
568 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800569 "libtest_elftls_shared_var",
570 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700571 ],
572 static_libs: [
573 // The order of these libraries matters, do not shuffle them.
574 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800575 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700576 "libziparchive",
577 "libz",
578 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800579 "libLLVMObject",
580 "libLLVMBitReader",
581 "libLLVMMC",
582 "libLLVMMCParser",
583 "libLLVMCore",
584 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700585 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700586 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700587 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700588 "-Wl,--enable-new-dtags",
589 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700590 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800591 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700592
593 required: [
594 "cfi_test_helper",
595 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800596 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700597 "exec_linker_helper",
598 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700599 "libtest_dt_runpath_a",
600 "libtest_dt_runpath_b",
601 "libtest_dt_runpath_c",
602 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900603 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700604 "libatest_simple_zip",
605 "libcfi-test",
606 "libcfi-test-bad",
607 "libdlext_test_different_soname",
608 "libdlext_test_fd",
609 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400610 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700611 "libdlext_test_runpath_zip_zipaligned",
612 "libdlext_test",
613 "libdlext_test_zip",
614 "libdlext_test_zip_zipaligned",
615 "libdl_preempt_test_1",
616 "libdl_preempt_test_2",
617 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700618 "libgnu-hash-table-library",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700619 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700620 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700621 "libtest_atexit",
622 "libtest_check_order_dlsym_1_left",
623 "libtest_check_order_dlsym_2_right",
624 "libtest_check_order_dlsym_3_c",
625 "libtest_check_order_dlsym_a",
626 "libtest_check_order_dlsym_b",
627 "libtest_check_order_dlsym_d",
628 "libtest_check_order_dlsym",
629 "libtest_check_order_reloc_root_1",
630 "libtest_check_order_reloc_root_2",
631 "libtest_check_order_reloc_root",
632 "libtest_check_order_reloc_siblings_1",
633 "libtest_check_order_reloc_siblings_2",
634 "libtest_check_order_reloc_siblings_3",
635 "libtest_check_order_reloc_siblings_a",
636 "libtest_check_order_reloc_siblings_b",
637 "libtest_check_order_reloc_siblings_c_1",
638 "libtest_check_order_reloc_siblings_c_2",
639 "libtest_check_order_reloc_siblings_c",
640 "libtest_check_order_reloc_siblings_d",
641 "libtest_check_order_reloc_siblings_e",
642 "libtest_check_order_reloc_siblings_f",
643 "libtest_check_order_reloc_siblings",
644 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700645 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700646 "libtest_dlopen_from_ctor_main",
647 "libtest_dlopen_from_ctor",
648 "libtest_dlopen_weak_undefined_func",
649 "libtest_dlsym_df_1_global",
650 "libtest_dlsym_from_this_child",
651 "libtest_dlsym_from_this_grandchild",
652 "libtest_dlsym_from_this",
653 "libtest_dlsym_weak_func",
654 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800655 "libtest_elftls_dynamic",
656 "libtest_elftls_dynamic_filler_1",
657 "libtest_elftls_dynamic_filler_2",
658 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800659 "libtest_elftls_shared_var",
660 "libtest_elftls_shared_var_ie",
661 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700662 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700663 "libtest_ifunc_variable_impl",
664 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700665 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700666 "libtest_init_fini_order_child",
667 "libtest_init_fini_order_grand_child",
668 "libtest_init_fini_order_root2",
669 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700670 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700671 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700672 "libtest_missing_symbol_root",
673 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700674 "libtest_nodelete_1",
675 "libtest_nodelete_2",
676 "libtest_nodelete_dt_flags_1",
677 "libtest_pthread_atfork",
678 "libtest_relo_check_dt_needed_order_1",
679 "libtest_relo_check_dt_needed_order_2",
680 "libtest_relo_check_dt_needed_order",
681 "libtest_simple",
682 "libtest_two_parents_child",
683 "libtest_two_parents_parent1",
684 "libtest_two_parents_parent2",
685 "libtest_versioned_lib",
686 "libtest_versioned_libv1",
687 "libtest_versioned_libv2",
688 "libtest_versioned_otherlib_empty",
689 "libtest_versioned_otherlib",
690 "libtest_versioned_uselibv1",
691 "libtest_versioned_uselibv2_other",
692 "libtest_versioned_uselibv2",
693 "libtest_versioned_uselibv3_other",
694 "libtest_with_dependency_loop_a",
695 "libtest_with_dependency_loop_b",
696 "libtest_with_dependency_loop_c",
697 "libtest_with_dependency_loop",
698 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200699 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700700 "libtest_invalid-empty_shdr_table.so",
701 "libtest_invalid-rw_load_segment.so",
702 "libtest_invalid-unaligned_shdr_offset.so",
703 "libtest_invalid-zero_shdr_table_content.so",
704 "libtest_invalid-zero_shdr_table_offset.so",
705 "libtest_invalid-zero_shentsize.so",
706 "libtest_invalid-zero_shstrndx.so",
707 "libtest_invalid-textrels.so",
708 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700709 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200710 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700711 "preinit_getauxval_test_helper",
712 "preinit_syscall_test_helper",
713 "libnstest_private_external",
714 "libnstest_dlopened",
715 "libnstest_private",
716 "libnstest_root_not_isolated",
717 "libnstest_root",
718 "libnstest_public",
719 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800720 "libnstest_ns_a_public1",
721 "libnstest_ns_a_public1_internal",
722 "libnstest_ns_b_public2",
723 "libnstest_ns_b_public3",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800724 "libsegment_gap_inner",
725 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900726 "ld_preload_test_helper",
727 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700728 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900729 "ld_config_test_helper",
730 "ld_config_test_helper_lib1",
731 "ld_config_test_helper_lib2",
732 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700733 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700734}
735
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800736cc_test {
737 name: "bionic-unit-tests",
738 defaults: [
739 "bionic_unit_tests_defaults",
740 ],
741}
742
743cc_test {
744 name: "bionic-unit-tests-scudo",
745 defaults: [
746 "bionic_unit_tests_defaults",
747 ],
748
749 shared_libs: [
750 "libc_scudo",
751 ],
752}
753
Colin Cross2722ebb2016-07-11 16:20:06 -0700754// -----------------------------------------------------------------------------
755// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900756// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
757// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700758// -----------------------------------------------------------------------------
759cc_test {
760 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700761 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700762 defaults: ["bionic_tests_defaults"],
763 host_supported: false,
764
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800765 srcs: [
766 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700767 "gtest_globals.cpp",
768 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800769
770 // The Bionic allocator has its own C++ API. It isn't packaged into its
771 // own library, so it can only be tested when it's part of libc.a.
772 "bionic_allocator_test.cpp",
773 ],
774 include_dirs: [
775 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800776 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700777 whole_static_libs: [
778 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700779 ],
780
781 static_libs: [
782 "libm",
783 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700784 "libdl",
785 "libtinyxml2",
786 "liblog",
787 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700788 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700789 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800790 "libtest_elftls_shared_var",
791 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700792 ],
793
794 static_executable: true,
795 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700796}
797
798// -----------------------------------------------------------------------------
799// Tests to run on the host and linked against glibc. Run with:
800// cd bionic/tests; mm bionic-unit-tests-glibc-run
801// -----------------------------------------------------------------------------
802
803cc_test_host {
804 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700805 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700806 defaults: ["bionic_tests_defaults"],
807
808 srcs: [
809 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700810 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700811 "dlfcn_test.cpp",
812 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700813 "gtest_globals.cpp",
814 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700815 "pthread_dlfcn_test.cpp",
816 ],
817
818 shared_libs: [
819 "libdl_preempt_test_1",
820 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700821 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800822 "libtest_elftls_shared_var",
823 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700824 ],
825
826 whole_static_libs: [
827 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800828 "libBionicElfTlsTests",
829 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700830 "libfortify1-tests-clang",
831 "libfortify2-tests-clang",
832 ],
833
834 static_libs: [
835 "libbase",
836 "liblog",
837 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700838 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700839 ],
840
841 host_ldlibs: [
842 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700843 "-lutil",
844 ],
845
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700846 include_dirs: [
847 "bionic/libc",
848 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700849
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800850 ldflags: [
851 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
852 "-Wl,--export-dynamic",
853 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700854
855 sanitize: {
856 never: false,
857 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700858
859 target: {
860 linux_bionic: {
861 enabled: false,
862 },
863 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700864}
865
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700866subdirs = ["*"]