blob: c75108483011a7bfdc47b4924e54f222a4abdc38 [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",
Elliott Hughesa6487332017-08-15 23:16:48 -0700120 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700121 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800122 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700123 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700124 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800125 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700126 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700127 "libgen_basename_test.cpp",
128 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700129 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700130 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700131 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700132 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700133 "malloc_test.cpp",
134 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700135 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100136 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700137 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800138 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700139 "netdb_test.cpp",
140 "net_if_test.cpp",
141 "netinet_ether_test.cpp",
142 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700143 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700144 "netinet_udp_test.cpp",
145 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700146 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700147 "pthread_test.cpp",
148 "pty_test.cpp",
149 "regex_test.cpp",
150 "resolv_test.cpp",
151 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800152 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700153 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700154 "search_test.cpp",
155 "semaphore_test.cpp",
156 "setjmp_test.cpp",
157 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700158 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700159 "stack_protector_test.cpp",
160 "stack_protector_test_helper.cpp",
161 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700162 "stdalign_test.cpp",
163 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700164 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700165 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700166 "stdint_test.cpp",
167 "stdio_nofortify_test.cpp",
168 "stdio_test.cpp",
169 "stdio_ext_test.cpp",
170 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700171 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700172 "string_nofortify_test.cpp",
173 "string_test.cpp",
174 "string_posix_strerror_r_test.cpp",
175 "strings_nofortify_test.cpp",
176 "strings_test.cpp",
177 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800178 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700179 "sys_epoll_test.cpp",
180 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700181 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700182 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700183 "sys_personality_test.cpp",
184 "sys_prctl_test.cpp",
185 "sys_procfs_test.cpp",
186 "sys_ptrace_test.cpp",
187 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700188 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700189 "sys_resource_test.cpp",
190 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700191 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700192 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700193 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800194 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700195 "sys_socket_test.cpp",
196 "sys_stat_test.cpp",
197 "sys_statvfs_test.cpp",
198 "sys_syscall_test.cpp",
199 "sys_sysinfo_test.cpp",
200 "sys_sysmacros_test.cpp",
201 "sys_time_test.cpp",
202 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700203 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700204 "sys_types_test.cpp",
205 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700206 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700207 "sys_vfs_test.cpp",
208 "sys_xattr_test.cpp",
209 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000210 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800211 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700212 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700213 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700214 "time_test.cpp",
215 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700216 "unistd_nofortify_test.cpp",
217 "unistd_test.cpp",
218 "utmp_test.cpp",
219 "wchar_test.cpp",
220 "wctype_test.cpp",
221 ],
222
223 include_dirs: [
224 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700225 ],
226
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700227 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700228 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800229 whole_static_libs: [
230 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700231 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800232 "libsystemproperties",
233 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800234 srcs: [
235 "tagged_pointers_test.cpp",
236 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700237 },
238 },
239
Dan Willemsen41567702016-08-31 16:35:01 -0700240 static_libs: [
241 "libtinyxml2",
242 "liblog",
243 "libbase",
244 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700245 shared: {
246 enabled: false,
247 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000248
249 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700250}
251
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800252cc_test_library {
253 name: "libBionicElfTlsTests",
254 defaults: ["bionic_tests_defaults"],
255 srcs: [
256 "elftls_test.cpp",
257 ],
258 include_dirs: [
259 "bionic/libc",
260 ],
261 shared: {
262 enabled: false,
263 },
264 cflags: [
265 "-fno-emulated-tls",
266 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700267 // With fuzzer builds, compiler instrumentation generates a reference to the
268 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
269 // library as an emutls symbol. The -fno-emulated-tls flag above configures
270 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
271 // symbol instead, which isn't defined. Disable the fuzzer for this test
272 // until the platform is switched to ELF TLS.
273 sanitize: {
274 fuzzer: false,
275 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800276}
277
278cc_test_library {
279 name: "libBionicElfTlsLoaderTests",
280 defaults: ["bionic_tests_defaults"],
281 srcs: [
282 "elftls_dl_test.cpp",
283 ],
284 include_dirs: [
285 "bionic/libc",
286 ],
287 static_libs: [
288 "liblog",
289 "libbase",
290 ],
291 shared: {
292 enabled: false,
293 },
294 cflags: [
295 "-fno-emulated-tls",
296 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700297 // With fuzzer builds, compiler instrumentation generates a reference to the
298 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
299 // library as an emutls symbol. The -fno-emulated-tls flag above configures
300 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
301 // symbol instead, which isn't defined. Disable the fuzzer for this test
302 // until the platform is switched to ELF TLS.
303 sanitize: {
304 fuzzer: false,
305 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800306}
307
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800308cc_test_library {
309 name: "libBionicFramePointerTests",
310 defaults: ["bionic_tests_defaults"],
311 srcs: [
312 "android_unsafe_frame_pointer_chase_test.cpp",
313 ],
314 include_dirs: [
315 "bionic/libc",
316 ],
317 cflags: [
318 "-fno-omit-frame-pointer",
319 ],
320}
321
Colin Cross2722ebb2016-07-11 16:20:06 -0700322// -----------------------------------------------------------------------------
323// Fortify tests.
324// -----------------------------------------------------------------------------
325
326cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700327 name: "bionic_clang_fortify_tests_w_flags",
328 cflags: [
329 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700330 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700331 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700332 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700333 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700334 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700335 "-Wno-strncat-size",
336 ],
337}
338
339cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700340 name: "bionic_fortify_tests_defaults",
341 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700342 "-U_FORTIFY_SOURCE",
343 ],
344 srcs: ["fortify_test_main.cpp"],
345 target: {
346 host: {
347 clang_cflags: ["-D__clang__"],
348 },
349 },
350}
351
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700352// Ensures that FORTIFY checks aren't run when ASAN is on.
353cc_test {
354 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700355 defaults: [
356 "bionic_clang_fortify_tests_w_flags",
357 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700358 cflags: [
359 "-Werror",
360 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700361 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700362 sanitize: {
363 address: true,
364 },
365 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700366}
367
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700368// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
369// it can confuse these tools pretty easily. If this builds successfully, then
370// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
371// enabled. The library that results from building this is meant to be unused.
372cc_test_library {
373 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700374 defaults: [
375 "bionic_clang_fortify_tests_w_flags",
376 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700377 cflags: [
378 "-Werror",
379 "-D_FORTIFY_SOURCE=2",
380 "-D__clang_analyzer__",
381 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700382 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700383}
384
Colin Cross2722ebb2016-07-11 16:20:06 -0700385cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700386 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800387 defaults: [
388 "bionic_fortify_tests_defaults",
389 "bionic_tests_defaults",
390 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700391 cflags: [
392 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800393 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700394 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700395 shared: {
396 enabled: false,
397 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700398}
399
400cc_test_library {
401 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800402 defaults: [
403 "bionic_fortify_tests_defaults",
404 "bionic_tests_defaults",
405 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700406 cflags: [
407 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800408 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700409 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700410 shared: {
411 enabled: false,
412 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700413}
414
George Burgess IV9a274102019-06-04 15:39:52 -0700415cc_defaults {
416 name: "bionic_new_fortify_tests_defaults",
417 defaults: [
418 "bionic_clang_fortify_tests_w_flags",
419 ],
420 cflags: [
421 "-U_FORTIFY_SOURCE",
422 ],
423 srcs: ["clang_fortify_tests.cpp"],
424 target: {
425 host: {
426 clang_cflags: ["-D__clang__"],
427 },
428 },
429}
430
431cc_test_library {
432 name: "libfortify1-new-tests-clang",
433 defaults: [
434 "bionic_new_fortify_tests_defaults",
435 "bionic_tests_defaults",
436 ],
437 cflags: [
438 "-D_FORTIFY_SOURCE=1",
439 "-DTEST_NAME=Fortify1_clang_new",
440 ],
441 shared: {
442 enabled: false,
443 },
444}
445
446cc_test_library {
447 name: "libfortify2-new-tests-clang",
448 defaults: [
449 "bionic_new_fortify_tests_defaults",
450 "bionic_tests_defaults",
451 ],
452 cflags: [
453 "-D_FORTIFY_SOURCE=2",
454 "-DTEST_NAME=Fortify2_clang_new",
455 ],
456 shared: {
457 enabled: false,
458 },
459}
460
461
Colin Cross2722ebb2016-07-11 16:20:06 -0700462// -----------------------------------------------------------------------------
463// Library of all tests (excluding the dynamic linker tests).
464// -----------------------------------------------------------------------------
465cc_test_library {
466 name: "libBionicTests",
467 defaults: ["bionic_tests_defaults"],
468 whole_static_libs: [
469 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800470 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800471 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700472 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700473 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700474 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700475 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700476 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700477 shared: {
478 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700479 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700480}
481
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700482cc_test_library {
483 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800484 defaults: [
485 "bionic_tests_defaults",
486 "llvm-defaults",
487 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700488 srcs: [
489 "atexit_test.cpp",
490 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700491 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700492 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700493 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700494 "pthread_dlfcn_test.cpp",
495 ],
496 static_libs: [
497 "libbase",
498 ],
499 include_dirs: [
500 "bionic/libc",
501 ],
502 shared: {
503 enabled: false,
504 },
505 target: {
506 android: {
507 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700508 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700509 "dlext_test.cpp",
510 "libdl_test.cpp",
511 ],
512 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800513 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400514 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700515 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800516 "libLLVMObject",
517 "libLLVMBitReader",
518 "libLLVMMC",
519 "libLLVMMCParser",
520 "libLLVMCore",
521 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700522 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800523 },
Jiyong Park02586a22017-05-20 01:01:24 +0900524 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700525}
526
Colin Cross2722ebb2016-07-11 16:20:06 -0700527// -----------------------------------------------------------------------------
528// Library of bionic customized gtest main function, with normal gtest output format,
529// which is needed by bionic cts test.
530// -----------------------------------------------------------------------------
531cc_test_library {
532 name: "libBionicCtsGtestMain",
533 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700534 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700535 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700536 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700537 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700538 shared: {
539 enabled: false,
540 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700541 whole_static_libs: [
542 "libgtest_isolated",
543 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700544}
545
546// -----------------------------------------------------------------------------
547// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900548// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
549// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700550// -----------------------------------------------------------------------------
551cc_defaults {
552 name: "bionic_unit_tests_defaults",
553 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800554 gtest: false,
555
556 defaults: [
557 "bionic_tests_defaults",
558 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700559
560 whole_static_libs: [
561 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700562 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800563 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700564 ],
565
566 static_libs: [
567 "libtinyxml2",
568 "liblog",
569 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800570 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700571 ],
572
573 srcs: [
574 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700575 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700576 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800577 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700578 "thread_local_test.cpp",
579 ],
580
581 conlyflags: [
582 "-fexceptions",
583 "-fnon-call-exceptions",
584 ],
585
586 ldflags: ["-Wl,--export-dynamic"],
587
588 include_dirs: ["bionic/libc"],
589
Yabin Cui1f553ea2017-01-13 12:31:59 -0800590 stl: "libc++_static",
591
Colin Cross2722ebb2016-07-11 16:20:06 -0700592 target: {
593 android: {
594 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100595 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700596 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100597 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700598 "libdl_preempt_test_1",
599 "libdl_preempt_test_2",
600 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800601 "libtest_elftls_shared_var",
602 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700603 ],
604 static_libs: [
605 // The order of these libraries matters, do not shuffle them.
606 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800607 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700608 "libziparchive",
609 "libz",
610 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800611 "libLLVMObject",
612 "libLLVMBitReader",
613 "libLLVMMC",
614 "libLLVMMCParser",
615 "libLLVMCore",
616 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700617 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700618 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700619 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700620 "-Wl,--enable-new-dtags",
621 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700622 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800623 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700624
625 required: [
626 "cfi_test_helper",
627 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800628 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700629 "exec_linker_helper",
630 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700631 "libtest_dt_runpath_a",
632 "libtest_dt_runpath_b",
633 "libtest_dt_runpath_c",
634 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900635 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700636 "libatest_simple_zip",
637 "libcfi-test",
638 "libcfi-test-bad",
639 "libdlext_test_different_soname",
640 "libdlext_test_fd",
641 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400642 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700643 "libdlext_test_runpath_zip_zipaligned",
644 "libdlext_test",
645 "libdlext_test_zip",
646 "libdlext_test_zip_zipaligned",
647 "libdl_preempt_test_1",
648 "libdl_preempt_test_2",
649 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700650 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800651 "librelocations-ANDROID_RELR",
652 "librelocations-ANDROID_REL",
653 "librelocations-RELR",
654 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700655 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700656 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700657 "libtest_atexit",
658 "libtest_check_order_dlsym_1_left",
659 "libtest_check_order_dlsym_2_right",
660 "libtest_check_order_dlsym_3_c",
661 "libtest_check_order_dlsym_a",
662 "libtest_check_order_dlsym_b",
663 "libtest_check_order_dlsym_d",
664 "libtest_check_order_dlsym",
665 "libtest_check_order_reloc_root_1",
666 "libtest_check_order_reloc_root_2",
667 "libtest_check_order_reloc_root",
668 "libtest_check_order_reloc_siblings_1",
669 "libtest_check_order_reloc_siblings_2",
670 "libtest_check_order_reloc_siblings_3",
671 "libtest_check_order_reloc_siblings_a",
672 "libtest_check_order_reloc_siblings_b",
673 "libtest_check_order_reloc_siblings_c_1",
674 "libtest_check_order_reloc_siblings_c_2",
675 "libtest_check_order_reloc_siblings_c",
676 "libtest_check_order_reloc_siblings_d",
677 "libtest_check_order_reloc_siblings_e",
678 "libtest_check_order_reloc_siblings_f",
679 "libtest_check_order_reloc_siblings",
680 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700681 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700682 "libtest_dlopen_from_ctor_main",
683 "libtest_dlopen_from_ctor",
684 "libtest_dlopen_weak_undefined_func",
685 "libtest_dlsym_df_1_global",
686 "libtest_dlsym_from_this_child",
687 "libtest_dlsym_from_this_grandchild",
688 "libtest_dlsym_from_this",
689 "libtest_dlsym_weak_func",
690 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800691 "libtest_elftls_dynamic",
692 "libtest_elftls_dynamic_filler_1",
693 "libtest_elftls_dynamic_filler_2",
694 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800695 "libtest_elftls_shared_var",
696 "libtest_elftls_shared_var_ie",
697 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700698 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700699 "libtest_ifunc_variable_impl",
700 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700701 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700702 "libtest_init_fini_order_child",
703 "libtest_init_fini_order_grand_child",
704 "libtest_init_fini_order_root2",
705 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700706 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700707 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700708 "libtest_missing_symbol_root",
709 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700710 "libtest_nodelete_1",
711 "libtest_nodelete_2",
712 "libtest_nodelete_dt_flags_1",
713 "libtest_pthread_atfork",
714 "libtest_relo_check_dt_needed_order_1",
715 "libtest_relo_check_dt_needed_order_2",
716 "libtest_relo_check_dt_needed_order",
717 "libtest_simple",
718 "libtest_two_parents_child",
719 "libtest_two_parents_parent1",
720 "libtest_two_parents_parent2",
721 "libtest_versioned_lib",
722 "libtest_versioned_libv1",
723 "libtest_versioned_libv2",
724 "libtest_versioned_otherlib_empty",
725 "libtest_versioned_otherlib",
726 "libtest_versioned_uselibv1",
727 "libtest_versioned_uselibv2_other",
728 "libtest_versioned_uselibv2",
729 "libtest_versioned_uselibv3_other",
730 "libtest_with_dependency_loop_a",
731 "libtest_with_dependency_loop_b",
732 "libtest_with_dependency_loop_c",
733 "libtest_with_dependency_loop",
734 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200735 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700736 "libtest_invalid-empty_shdr_table.so",
737 "libtest_invalid-rw_load_segment.so",
738 "libtest_invalid-unaligned_shdr_offset.so",
739 "libtest_invalid-zero_shdr_table_content.so",
740 "libtest_invalid-zero_shdr_table_offset.so",
741 "libtest_invalid-zero_shentsize.so",
742 "libtest_invalid-zero_shstrndx.so",
743 "libtest_invalid-textrels.so",
744 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700745 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200746 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700747 "preinit_getauxval_test_helper",
748 "preinit_syscall_test_helper",
749 "libnstest_private_external",
750 "libnstest_dlopened",
751 "libnstest_private",
752 "libnstest_root_not_isolated",
753 "libnstest_root",
754 "libnstest_public",
755 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800756 "libnstest_ns_a_public1",
757 "libnstest_ns_a_public1_internal",
758 "libnstest_ns_b_public2",
759 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800760 "ns_hidden_child_helper",
761 "libns_hidden_child_global",
762 "libns_hidden_child_internal",
763 "libns_hidden_child_public",
764 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800765 "libsegment_gap_inner",
766 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900767 "ld_preload_test_helper",
768 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700769 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900770 "ld_config_test_helper",
771 "ld_config_test_helper_lib1",
772 "ld_config_test_helper_lib2",
773 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700774 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700775}
776
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800777cc_test {
778 name: "bionic-unit-tests",
779 defaults: [
780 "bionic_unit_tests_defaults",
781 ],
782}
783
784cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700785 name: "bionic-stress-tests",
786 defaults: [
787 "bionic_tests_defaults",
788 ],
789
790 // For now, these tests run forever, so do not use the isolation framework.
791 isolated: false,
792
793 srcs: [
794 "malloc_stress_test.cpp",
795 ],
796
797 shared_libs: [
798 "libbase",
799 ],
800
801 target: {
802 android: {
803 static_libs: [
804 "libmeminfo",
805 "libprocinfo",
806 ],
807 },
808 },
809}
810
Colin Cross2722ebb2016-07-11 16:20:06 -0700811// -----------------------------------------------------------------------------
812// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900813// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
814// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700815// -----------------------------------------------------------------------------
816cc_test {
817 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700818 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700819 defaults: ["bionic_tests_defaults"],
820 host_supported: false,
821
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800822 srcs: [
823 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700824 "gtest_globals.cpp",
825 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800826
827 // The Bionic allocator has its own C++ API. It isn't packaged into its
828 // own library, so it can only be tested when it's part of libc.a.
829 "bionic_allocator_test.cpp",
830 ],
831 include_dirs: [
832 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800833 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700834 whole_static_libs: [
835 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700836 ],
837
838 static_libs: [
839 "libm",
840 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700841 "libdl",
842 "libtinyxml2",
843 "liblog",
844 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700845 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700846 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800847 "libtest_elftls_shared_var",
848 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700849 ],
850
851 static_executable: true,
852 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700853}
854
855// -----------------------------------------------------------------------------
856// Tests to run on the host and linked against glibc. Run with:
857// cd bionic/tests; mm bionic-unit-tests-glibc-run
858// -----------------------------------------------------------------------------
859
860cc_test_host {
861 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700862 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700863 defaults: ["bionic_tests_defaults"],
864
865 srcs: [
866 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700867 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700868 "dlfcn_test.cpp",
869 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700870 "gtest_globals.cpp",
871 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700872 "pthread_dlfcn_test.cpp",
873 ],
874
875 shared_libs: [
876 "libdl_preempt_test_1",
877 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700878 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800879 "libtest_elftls_shared_var",
880 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700881 ],
882
883 whole_static_libs: [
884 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800885 "libBionicElfTlsTests",
886 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700887 "libfortify1-tests-clang",
888 "libfortify2-tests-clang",
889 ],
890
891 static_libs: [
892 "libbase",
893 "liblog",
894 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700895 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700896 ],
897
898 host_ldlibs: [
899 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700900 "-lutil",
901 ],
902
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700903 include_dirs: [
904 "bionic/libc",
905 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700906
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800907 ldflags: [
908 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
909 "-Wl,--export-dynamic",
910 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700911
912 sanitize: {
913 never: false,
914 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700915
916 target: {
917 linux_bionic: {
918 enabled: false,
919 },
920 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700921}
922
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700923subdirs = ["*"]