blob: 1f45595f2400f74a2df20b02eec5a4ce7df65ea4 [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 ],
Martin Stjernholmed95d012020-04-29 12:14:09 +000041 header_libs: ["bionic_libc_platform_headers"],
Tamas Petzd901ec62020-02-25 11:25:48 +010042 // Ensure that the tests exercise shadow call stack support and
43 // the hint space PAC/BTI instructions.
Peter Collingbourne7b70e272018-11-12 20:09:14 -080044 arch: {
45 arm64: {
Tamas Petzd901ec62020-02-25 11:25:48 +010046 cflags: [
47 "-fsanitize=shadow-call-stack",
Christopher Ferris140220b2020-03-12 17:09:38 -070048 // Disable this option for now: see b/151372823
49 //"-mbranch-protection=standard",
Tamas Petzd901ec62020-02-25 11:25:48 +010050 ],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080051 },
52 },
Colin Cross2722ebb2016-07-11 16:20:06 -070053 stl: "libc++",
54 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080055 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070056 },
Ryan Prichard3c5dff42020-03-31 17:34:03 -070057
58 // Use the bootstrap version of bionic because some tests call private APIs
59 // that aren't exposed by the APEX bionic stubs.
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090060 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080061
62 product_variables: {
63 experimental_mte: {
64 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
65 },
66 },
Colin Cross2722ebb2016-07-11 16:20:06 -070067}
68
69// -----------------------------------------------------------------------------
70// All standard tests.
71// -----------------------------------------------------------------------------
72
George Burgess IVde45dcb2018-03-16 14:15:01 -070073// Test diagnostics emitted by clang. The library that results is useless; we
74// just want to run '-Xclang -verify', which will fail if the diagnostics don't
75// match up with what the source file says they should be.
76cc_test_library {
77 name: "clang_diagnostic_tests",
78 cflags: [
79 "-Xclang",
80 "-verify",
81 ],
82 srcs: ["sys_ioctl_diag_test.cpp"],
83}
84
Colin Cross2722ebb2016-07-11 16:20:06 -070085cc_test_library {
86 name: "libBionicStandardTests",
87 defaults: ["bionic_tests_defaults"],
88 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080089 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -080090 "__cxa_atexit_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030091 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070092 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070093 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070094 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070095 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070096 "buffer_tests.cpp",
97 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030098 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070099 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700100 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700101 "ctype_test.cpp",
102 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -0700103 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800104 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700105 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700106 "error_test.cpp",
107 "eventfd_test.cpp",
108 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700109 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800110 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700111 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800112 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700113 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700114 "ftw_test.cpp",
115 "getauxval_test.cpp",
116 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700117 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700118 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800119 "grp_pwd_file_test.cpp",
Peter Collingbourned3060012020-04-01 19:54:48 -0700120 "heap_tagging_level_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700121 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700122 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800123 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700124 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700125 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800126 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700127 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "libgen_basename_test.cpp",
129 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700130 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700131 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700132 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700133 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700134 "malloc_test.cpp",
135 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700136 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100137 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700138 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800139 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700140 "netdb_test.cpp",
141 "net_if_test.cpp",
142 "netinet_ether_test.cpp",
143 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700144 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700145 "netinet_udp_test.cpp",
146 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700147 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700148 "pthread_test.cpp",
149 "pty_test.cpp",
150 "regex_test.cpp",
151 "resolv_test.cpp",
152 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800153 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700154 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 "search_test.cpp",
156 "semaphore_test.cpp",
157 "setjmp_test.cpp",
158 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700159 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700160 "stack_protector_test.cpp",
161 "stack_protector_test_helper.cpp",
162 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700163 "stdalign_test.cpp",
164 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700165 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700166 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700167 "stdint_test.cpp",
168 "stdio_nofortify_test.cpp",
169 "stdio_test.cpp",
170 "stdio_ext_test.cpp",
171 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700172 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700173 "string_nofortify_test.cpp",
174 "string_test.cpp",
175 "string_posix_strerror_r_test.cpp",
176 "strings_nofortify_test.cpp",
177 "strings_test.cpp",
178 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800179 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700180 "sys_epoll_test.cpp",
181 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700182 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700183 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700184 "sys_personality_test.cpp",
185 "sys_prctl_test.cpp",
186 "sys_procfs_test.cpp",
187 "sys_ptrace_test.cpp",
188 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700189 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700190 "sys_resource_test.cpp",
191 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700192 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700193 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700194 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800195 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700196 "sys_socket_test.cpp",
197 "sys_stat_test.cpp",
198 "sys_statvfs_test.cpp",
199 "sys_syscall_test.cpp",
200 "sys_sysinfo_test.cpp",
201 "sys_sysmacros_test.cpp",
202 "sys_time_test.cpp",
203 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700204 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700205 "sys_types_test.cpp",
206 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700207 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700208 "sys_vfs_test.cpp",
209 "sys_xattr_test.cpp",
210 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000211 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800212 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700213 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700214 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700215 "time_test.cpp",
216 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700217 "unistd_nofortify_test.cpp",
218 "unistd_test.cpp",
219 "utmp_test.cpp",
220 "wchar_test.cpp",
221 "wctype_test.cpp",
222 ],
223
224 include_dirs: [
225 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700226 ],
227
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700228 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700229 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800230 whole_static_libs: [
231 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700232 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800233 "libsystemproperties",
234 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700235 },
236 },
237
Dan Willemsen41567702016-08-31 16:35:01 -0700238 static_libs: [
239 "libtinyxml2",
240 "liblog",
241 "libbase",
242 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700243 shared: {
244 enabled: false,
245 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000246
247 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700248}
249
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800250cc_test_library {
251 name: "libBionicElfTlsTests",
252 defaults: ["bionic_tests_defaults"],
253 srcs: [
254 "elftls_test.cpp",
255 ],
256 include_dirs: [
257 "bionic/libc",
258 ],
259 shared: {
260 enabled: false,
261 },
262 cflags: [
263 "-fno-emulated-tls",
264 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700265 // With fuzzer builds, compiler instrumentation generates a reference to the
266 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
267 // library as an emutls symbol. The -fno-emulated-tls flag above configures
268 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
269 // symbol instead, which isn't defined. Disable the fuzzer for this test
270 // until the platform is switched to ELF TLS.
271 sanitize: {
272 fuzzer: false,
273 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800274}
275
276cc_test_library {
277 name: "libBionicElfTlsLoaderTests",
278 defaults: ["bionic_tests_defaults"],
279 srcs: [
280 "elftls_dl_test.cpp",
281 ],
282 include_dirs: [
283 "bionic/libc",
284 ],
285 static_libs: [
286 "liblog",
287 "libbase",
288 ],
289 shared: {
290 enabled: false,
291 },
292 cflags: [
293 "-fno-emulated-tls",
294 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700295 // With fuzzer builds, compiler instrumentation generates a reference to the
296 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
297 // library as an emutls symbol. The -fno-emulated-tls flag above configures
298 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
299 // symbol instead, which isn't defined. Disable the fuzzer for this test
300 // until the platform is switched to ELF TLS.
301 sanitize: {
302 fuzzer: false,
303 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800304}
305
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800306cc_test_library {
307 name: "libBionicFramePointerTests",
308 defaults: ["bionic_tests_defaults"],
309 srcs: [
310 "android_unsafe_frame_pointer_chase_test.cpp",
311 ],
312 include_dirs: [
313 "bionic/libc",
314 ],
315 cflags: [
316 "-fno-omit-frame-pointer",
317 ],
318}
319
Colin Cross2722ebb2016-07-11 16:20:06 -0700320// -----------------------------------------------------------------------------
321// Fortify tests.
322// -----------------------------------------------------------------------------
323
324cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700325 name: "bionic_clang_fortify_tests_w_flags",
326 cflags: [
327 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700328 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700329 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700330 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700331 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700332 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700333 "-Wno-strncat-size",
334 ],
335}
336
337cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700338 name: "bionic_fortify_tests_defaults",
339 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700340 "-U_FORTIFY_SOURCE",
341 ],
342 srcs: ["fortify_test_main.cpp"],
343 target: {
344 host: {
345 clang_cflags: ["-D__clang__"],
346 },
347 },
348}
349
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700350// Ensures that FORTIFY checks aren't run when ASAN is on.
351cc_test {
352 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700353 defaults: [
354 "bionic_clang_fortify_tests_w_flags",
355 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700356 cflags: [
357 "-Werror",
358 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700359 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700360 sanitize: {
361 address: true,
362 },
363 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700364}
365
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700366// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
367// it can confuse these tools pretty easily. If this builds successfully, then
368// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
369// enabled. The library that results from building this is meant to be unused.
370cc_test_library {
371 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700372 defaults: [
373 "bionic_clang_fortify_tests_w_flags",
374 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700375 cflags: [
376 "-Werror",
377 "-D_FORTIFY_SOURCE=2",
378 "-D__clang_analyzer__",
379 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700380 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700381}
382
Colin Cross2722ebb2016-07-11 16:20:06 -0700383cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700384 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800385 defaults: [
386 "bionic_fortify_tests_defaults",
387 "bionic_tests_defaults",
388 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700389 cflags: [
390 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800391 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700392 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700393 shared: {
394 enabled: false,
395 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700396}
397
398cc_test_library {
399 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800400 defaults: [
401 "bionic_fortify_tests_defaults",
402 "bionic_tests_defaults",
403 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700404 cflags: [
405 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800406 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700407 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700408 shared: {
409 enabled: false,
410 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700411}
412
George Burgess IV9a274102019-06-04 15:39:52 -0700413cc_defaults {
414 name: "bionic_new_fortify_tests_defaults",
415 defaults: [
416 "bionic_clang_fortify_tests_w_flags",
417 ],
418 cflags: [
419 "-U_FORTIFY_SOURCE",
420 ],
421 srcs: ["clang_fortify_tests.cpp"],
422 target: {
423 host: {
424 clang_cflags: ["-D__clang__"],
425 },
426 },
427}
428
429cc_test_library {
430 name: "libfortify1-new-tests-clang",
431 defaults: [
432 "bionic_new_fortify_tests_defaults",
433 "bionic_tests_defaults",
434 ],
435 cflags: [
436 "-D_FORTIFY_SOURCE=1",
437 "-DTEST_NAME=Fortify1_clang_new",
438 ],
439 shared: {
440 enabled: false,
441 },
442}
443
444cc_test_library {
445 name: "libfortify2-new-tests-clang",
446 defaults: [
447 "bionic_new_fortify_tests_defaults",
448 "bionic_tests_defaults",
449 ],
450 cflags: [
451 "-D_FORTIFY_SOURCE=2",
452 "-DTEST_NAME=Fortify2_clang_new",
453 ],
454 shared: {
455 enabled: false,
456 },
457}
458
459
Colin Cross2722ebb2016-07-11 16:20:06 -0700460// -----------------------------------------------------------------------------
461// Library of all tests (excluding the dynamic linker tests).
462// -----------------------------------------------------------------------------
463cc_test_library {
464 name: "libBionicTests",
465 defaults: ["bionic_tests_defaults"],
466 whole_static_libs: [
467 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800468 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800469 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700470 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700471 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700472 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700473 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700474 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700475 shared: {
476 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700477 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700478}
479
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700480cc_test_library {
481 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800482 defaults: [
483 "bionic_tests_defaults",
484 "llvm-defaults",
485 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700486 srcs: [
487 "atexit_test.cpp",
488 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700489 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700490 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700491 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700492 "pthread_dlfcn_test.cpp",
493 ],
494 static_libs: [
495 "libbase",
496 ],
497 include_dirs: [
498 "bionic/libc",
499 ],
500 shared: {
501 enabled: false,
502 },
503 target: {
504 android: {
505 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700506 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700507 "dlext_test.cpp",
508 "libdl_test.cpp",
509 ],
510 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800511 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400512 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700513 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800514 "libLLVMObject",
515 "libLLVMBitReader",
516 "libLLVMMC",
517 "libLLVMMCParser",
518 "libLLVMCore",
519 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700520 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800521 },
Jiyong Park02586a22017-05-20 01:01:24 +0900522 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700523}
524
Colin Cross2722ebb2016-07-11 16:20:06 -0700525// -----------------------------------------------------------------------------
526// Library of bionic customized gtest main function, with normal gtest output format,
527// which is needed by bionic cts test.
528// -----------------------------------------------------------------------------
529cc_test_library {
530 name: "libBionicCtsGtestMain",
531 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700532 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700533 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700534 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700535 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700536 shared: {
537 enabled: false,
538 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700539 whole_static_libs: [
540 "libgtest_isolated",
541 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700542}
543
544// -----------------------------------------------------------------------------
545// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900546// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
547// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700548// -----------------------------------------------------------------------------
549cc_defaults {
550 name: "bionic_unit_tests_defaults",
551 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800552 gtest: false,
553
554 defaults: [
555 "bionic_tests_defaults",
556 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700557
558 whole_static_libs: [
559 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700560 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800561 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700562 ],
563
564 static_libs: [
565 "libtinyxml2",
566 "liblog",
567 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800568 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700569 ],
570
571 srcs: [
572 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700573 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700574 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800575 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700576 "thread_local_test.cpp",
577 ],
578
579 conlyflags: [
580 "-fexceptions",
581 "-fnon-call-exceptions",
582 ],
583
584 ldflags: ["-Wl,--export-dynamic"],
585
586 include_dirs: ["bionic/libc"],
587
Yabin Cui1f553ea2017-01-13 12:31:59 -0800588 stl: "libc++_static",
589
Colin Cross2722ebb2016-07-11 16:20:06 -0700590 target: {
591 android: {
592 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100593 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700594 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100595 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700596 "libdl_preempt_test_1",
597 "libdl_preempt_test_2",
598 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800599 "libtest_elftls_shared_var",
600 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700601 ],
602 static_libs: [
603 // The order of these libraries matters, do not shuffle them.
604 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800605 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700606 "libziparchive",
607 "libz",
608 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800609 "libLLVMObject",
610 "libLLVMBitReader",
611 "libLLVMMC",
612 "libLLVMMCParser",
613 "libLLVMCore",
614 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700615 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700616 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700617 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700618 "-Wl,--enable-new-dtags",
619 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700620 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800621 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700622
623 required: [
624 "cfi_test_helper",
625 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800626 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700627 "exec_linker_helper",
628 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700629 "libtest_dt_runpath_a",
630 "libtest_dt_runpath_b",
631 "libtest_dt_runpath_c",
632 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900633 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700634 "libatest_simple_zip",
635 "libcfi-test",
636 "libcfi-test-bad",
637 "libdlext_test_different_soname",
638 "libdlext_test_fd",
639 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400640 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700641 "libdlext_test_runpath_zip_zipaligned",
642 "libdlext_test",
643 "libdlext_test_zip",
644 "libdlext_test_zip_zipaligned",
645 "libdl_preempt_test_1",
646 "libdl_preempt_test_2",
647 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700648 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800649 "librelocations-ANDROID_RELR",
650 "librelocations-ANDROID_REL",
651 "librelocations-RELR",
652 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700653 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700654 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700655 "libtest_atexit",
656 "libtest_check_order_dlsym_1_left",
657 "libtest_check_order_dlsym_2_right",
658 "libtest_check_order_dlsym_3_c",
659 "libtest_check_order_dlsym_a",
660 "libtest_check_order_dlsym_b",
661 "libtest_check_order_dlsym_d",
662 "libtest_check_order_dlsym",
663 "libtest_check_order_reloc_root_1",
664 "libtest_check_order_reloc_root_2",
665 "libtest_check_order_reloc_root",
666 "libtest_check_order_reloc_siblings_1",
667 "libtest_check_order_reloc_siblings_2",
668 "libtest_check_order_reloc_siblings_3",
669 "libtest_check_order_reloc_siblings_a",
670 "libtest_check_order_reloc_siblings_b",
671 "libtest_check_order_reloc_siblings_c_1",
672 "libtest_check_order_reloc_siblings_c_2",
673 "libtest_check_order_reloc_siblings_c",
674 "libtest_check_order_reloc_siblings_d",
675 "libtest_check_order_reloc_siblings_e",
676 "libtest_check_order_reloc_siblings_f",
677 "libtest_check_order_reloc_siblings",
678 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700679 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700680 "libtest_dlopen_from_ctor_main",
681 "libtest_dlopen_from_ctor",
682 "libtest_dlopen_weak_undefined_func",
683 "libtest_dlsym_df_1_global",
684 "libtest_dlsym_from_this_child",
685 "libtest_dlsym_from_this_grandchild",
686 "libtest_dlsym_from_this",
687 "libtest_dlsym_weak_func",
688 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800689 "libtest_elftls_dynamic",
690 "libtest_elftls_dynamic_filler_1",
691 "libtest_elftls_dynamic_filler_2",
692 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800693 "libtest_elftls_shared_var",
694 "libtest_elftls_shared_var_ie",
695 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700696 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700697 "libtest_ifunc_variable_impl",
698 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700699 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700700 "libtest_init_fini_order_child",
701 "libtest_init_fini_order_grand_child",
702 "libtest_init_fini_order_root2",
703 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700704 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700705 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700706 "libtest_missing_symbol_root",
707 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700708 "libtest_nodelete_1",
709 "libtest_nodelete_2",
710 "libtest_nodelete_dt_flags_1",
711 "libtest_pthread_atfork",
712 "libtest_relo_check_dt_needed_order_1",
713 "libtest_relo_check_dt_needed_order_2",
714 "libtest_relo_check_dt_needed_order",
715 "libtest_simple",
716 "libtest_two_parents_child",
717 "libtest_two_parents_parent1",
718 "libtest_two_parents_parent2",
719 "libtest_versioned_lib",
720 "libtest_versioned_libv1",
721 "libtest_versioned_libv2",
722 "libtest_versioned_otherlib_empty",
723 "libtest_versioned_otherlib",
724 "libtest_versioned_uselibv1",
725 "libtest_versioned_uselibv2_other",
726 "libtest_versioned_uselibv2",
727 "libtest_versioned_uselibv3_other",
728 "libtest_with_dependency_loop_a",
729 "libtest_with_dependency_loop_b",
730 "libtest_with_dependency_loop_c",
731 "libtest_with_dependency_loop",
732 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200733 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700734 "libtest_invalid-empty_shdr_table.so",
735 "libtest_invalid-rw_load_segment.so",
736 "libtest_invalid-unaligned_shdr_offset.so",
737 "libtest_invalid-zero_shdr_table_content.so",
738 "libtest_invalid-zero_shdr_table_offset.so",
739 "libtest_invalid-zero_shentsize.so",
740 "libtest_invalid-zero_shstrndx.so",
741 "libtest_invalid-textrels.so",
742 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700743 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200744 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700745 "preinit_getauxval_test_helper",
746 "preinit_syscall_test_helper",
747 "libnstest_private_external",
748 "libnstest_dlopened",
749 "libnstest_private",
750 "libnstest_root_not_isolated",
751 "libnstest_root",
752 "libnstest_public",
753 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800754 "libnstest_ns_a_public1",
755 "libnstest_ns_a_public1_internal",
756 "libnstest_ns_b_public2",
757 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800758 "ns_hidden_child_helper",
759 "libns_hidden_child_global",
760 "libns_hidden_child_internal",
761 "libns_hidden_child_public",
762 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800763 "libsegment_gap_inner",
764 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900765 "ld_preload_test_helper",
766 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700767 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900768 "ld_config_test_helper",
769 "ld_config_test_helper_lib1",
770 "ld_config_test_helper_lib2",
771 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700772 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700773}
774
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800775cc_test {
776 name: "bionic-unit-tests",
777 defaults: [
778 "bionic_unit_tests_defaults",
779 ],
780}
781
782cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700783 name: "bionic-stress-tests",
784 defaults: [
785 "bionic_tests_defaults",
786 ],
787
788 // For now, these tests run forever, so do not use the isolation framework.
789 isolated: false,
790
791 srcs: [
792 "malloc_stress_test.cpp",
793 ],
794
795 shared_libs: [
796 "libbase",
797 ],
798
799 target: {
800 android: {
801 static_libs: [
802 "libmeminfo",
803 "libprocinfo",
804 ],
805 },
806 },
807}
808
Colin Cross2722ebb2016-07-11 16:20:06 -0700809// -----------------------------------------------------------------------------
810// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900811// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
812// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700813// -----------------------------------------------------------------------------
814cc_test {
815 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700816 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700817 defaults: ["bionic_tests_defaults"],
818 host_supported: false,
819
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800820 srcs: [
821 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700822 "gtest_globals.cpp",
823 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800824
825 // The Bionic allocator has its own C++ API. It isn't packaged into its
826 // own library, so it can only be tested when it's part of libc.a.
827 "bionic_allocator_test.cpp",
828 ],
829 include_dirs: [
830 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800831 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700832 whole_static_libs: [
833 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700834 ],
835
836 static_libs: [
837 "libm",
838 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700839 "libdl",
840 "libtinyxml2",
841 "liblog",
842 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700843 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700844 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800845 "libtest_elftls_shared_var",
846 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700847 ],
848
849 static_executable: true,
850 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700851}
852
853// -----------------------------------------------------------------------------
854// Tests to run on the host and linked against glibc. Run with:
855// cd bionic/tests; mm bionic-unit-tests-glibc-run
856// -----------------------------------------------------------------------------
857
858cc_test_host {
859 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700860 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700861 defaults: ["bionic_tests_defaults"],
862
863 srcs: [
864 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700865 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700866 "dlfcn_test.cpp",
867 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700868 "gtest_globals.cpp",
869 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700870 "pthread_dlfcn_test.cpp",
871 ],
872
873 shared_libs: [
874 "libdl_preempt_test_1",
875 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700876 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800877 "libtest_elftls_shared_var",
878 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700879 ],
880
881 whole_static_libs: [
882 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800883 "libBionicElfTlsTests",
884 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700885 "libfortify1-tests-clang",
886 "libfortify2-tests-clang",
887 ],
888
889 static_libs: [
890 "libbase",
891 "liblog",
892 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700893 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700894 ],
895
896 host_ldlibs: [
897 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700898 "-lutil",
899 ],
900
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700901 include_dirs: [
902 "bionic/libc",
903 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700904
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800905 ldflags: [
906 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
907 "-Wl,--export-dynamic",
908 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700909
910 sanitize: {
911 never: false,
912 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700913
914 target: {
915 linux_bionic: {
916 enabled: false,
917 },
918 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700919}
920
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700921subdirs = ["*"]