blob: 598865bd790773a77a98197c4664da529dbe66ad [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 },
Martin Stjernholma2763432020-04-23 16:47:19 +010025 android: {
26 header_libs: ["bionic_libc_platform_headers"],
27 },
28 linux_bionic: {
29 header_libs: ["bionic_libc_platform_headers"],
30 },
Colin Cross2722ebb2016-07-11 16:20:06 -070031 },
32 cflags: [
33 "-fstack-protector-all",
34 "-g",
35 "-Wall",
36 "-Wextra",
37 "-Wunused",
38 "-Werror",
39 "-fno-builtin",
40
41 // We want to test deprecated API too.
42 "-Wno-deprecated-declarations",
43
44 // For glibc.
45 "-D__STDC_LIMIT_MACROS",
46 ],
Tamas Petzd901ec62020-02-25 11:25:48 +010047 // Ensure that the tests exercise shadow call stack support and
48 // the hint space PAC/BTI instructions.
Peter Collingbourne7b70e272018-11-12 20:09:14 -080049 arch: {
50 arm64: {
Tamas Petzd901ec62020-02-25 11:25:48 +010051 cflags: [
52 "-fsanitize=shadow-call-stack",
Christopher Ferris140220b2020-03-12 17:09:38 -070053 // Disable this option for now: see b/151372823
54 //"-mbranch-protection=standard",
Tamas Petzd901ec62020-02-25 11:25:48 +010055 ],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080056 },
57 },
Colin Cross2722ebb2016-07-11 16:20:06 -070058 stl: "libc++",
59 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080060 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070061 },
Ryan Prichard3c5dff42020-03-31 17:34:03 -070062
63 // Use the bootstrap version of bionic because some tests call private APIs
64 // that aren't exposed by the APEX bionic stubs.
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090065 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080066
67 product_variables: {
68 experimental_mte: {
69 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
70 },
71 },
Colin Cross2722ebb2016-07-11 16:20:06 -070072}
73
74// -----------------------------------------------------------------------------
75// All standard tests.
76// -----------------------------------------------------------------------------
77
George Burgess IVde45dcb2018-03-16 14:15:01 -070078// Test diagnostics emitted by clang. The library that results is useless; we
79// just want to run '-Xclang -verify', which will fail if the diagnostics don't
80// match up with what the source file says they should be.
81cc_test_library {
82 name: "clang_diagnostic_tests",
83 cflags: [
84 "-Xclang",
85 "-verify",
86 ],
87 srcs: ["sys_ioctl_diag_test.cpp"],
88}
89
Colin Cross2722ebb2016-07-11 16:20:06 -070090cc_test_library {
91 name: "libBionicStandardTests",
92 defaults: ["bionic_tests_defaults"],
93 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080094 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -080095 "__cxa_atexit_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030096 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070097 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070098 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070099 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -0700100 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700101 "buffer_tests.cpp",
102 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300103 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700104 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700105 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700106 "ctype_test.cpp",
107 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -0700108 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800109 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700110 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700111 "error_test.cpp",
112 "eventfd_test.cpp",
113 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700114 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800115 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700116 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800117 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700118 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700119 "ftw_test.cpp",
120 "getauxval_test.cpp",
121 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700122 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700123 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800124 "grp_pwd_file_test.cpp",
Peter Collingbourned3060012020-04-01 19:54:48 -0700125 "heap_tagging_level_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700126 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700127 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800128 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700129 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700130 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800131 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700132 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700133 "libgen_basename_test.cpp",
134 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700135 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700136 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700137 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700138 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700139 "malloc_test.cpp",
140 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700141 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100142 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700143 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800144 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700145 "netdb_test.cpp",
146 "net_if_test.cpp",
147 "netinet_ether_test.cpp",
148 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700149 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700150 "netinet_udp_test.cpp",
151 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700152 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700153 "pthread_test.cpp",
154 "pty_test.cpp",
155 "regex_test.cpp",
156 "resolv_test.cpp",
157 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800158 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700159 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700160 "search_test.cpp",
161 "semaphore_test.cpp",
162 "setjmp_test.cpp",
163 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700164 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700165 "stack_protector_test.cpp",
166 "stack_protector_test_helper.cpp",
167 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700168 "stdalign_test.cpp",
169 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700170 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700171 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700172 "stdint_test.cpp",
173 "stdio_nofortify_test.cpp",
174 "stdio_test.cpp",
175 "stdio_ext_test.cpp",
176 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700177 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700178 "string_nofortify_test.cpp",
179 "string_test.cpp",
180 "string_posix_strerror_r_test.cpp",
181 "strings_nofortify_test.cpp",
182 "strings_test.cpp",
183 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800184 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700185 "sys_epoll_test.cpp",
186 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700187 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700188 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700189 "sys_personality_test.cpp",
190 "sys_prctl_test.cpp",
191 "sys_procfs_test.cpp",
192 "sys_ptrace_test.cpp",
193 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700194 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700195 "sys_resource_test.cpp",
196 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700197 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700198 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700199 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800200 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700201 "sys_socket_test.cpp",
202 "sys_stat_test.cpp",
203 "sys_statvfs_test.cpp",
204 "sys_syscall_test.cpp",
205 "sys_sysinfo_test.cpp",
206 "sys_sysmacros_test.cpp",
207 "sys_time_test.cpp",
208 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700209 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700210 "sys_types_test.cpp",
211 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700212 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700213 "sys_vfs_test.cpp",
214 "sys_xattr_test.cpp",
215 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000216 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800217 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700218 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700219 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700220 "time_test.cpp",
221 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700222 "unistd_nofortify_test.cpp",
223 "unistd_test.cpp",
224 "utmp_test.cpp",
225 "wchar_test.cpp",
226 "wctype_test.cpp",
227 ],
228
229 include_dirs: [
230 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700231 ],
232
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700233 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700234 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800235 whole_static_libs: [
236 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700237 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800238 "libsystemproperties",
239 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700240 },
241 },
242
Dan Willemsen41567702016-08-31 16:35:01 -0700243 static_libs: [
244 "libtinyxml2",
245 "liblog",
246 "libbase",
247 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700248 shared: {
249 enabled: false,
250 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000251
252 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700253}
254
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800255cc_test_library {
256 name: "libBionicElfTlsTests",
257 defaults: ["bionic_tests_defaults"],
258 srcs: [
259 "elftls_test.cpp",
260 ],
261 include_dirs: [
262 "bionic/libc",
263 ],
264 shared: {
265 enabled: false,
266 },
267 cflags: [
268 "-fno-emulated-tls",
269 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700270 // With fuzzer builds, compiler instrumentation generates a reference to the
271 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
272 // library as an emutls symbol. The -fno-emulated-tls flag above configures
273 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
274 // symbol instead, which isn't defined. Disable the fuzzer for this test
275 // until the platform is switched to ELF TLS.
276 sanitize: {
277 fuzzer: false,
278 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800279}
280
281cc_test_library {
282 name: "libBionicElfTlsLoaderTests",
283 defaults: ["bionic_tests_defaults"],
284 srcs: [
285 "elftls_dl_test.cpp",
286 ],
287 include_dirs: [
288 "bionic/libc",
289 ],
290 static_libs: [
291 "liblog",
292 "libbase",
293 ],
294 shared: {
295 enabled: false,
296 },
297 cflags: [
298 "-fno-emulated-tls",
299 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700300 // With fuzzer builds, compiler instrumentation generates a reference to the
301 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
302 // library as an emutls symbol. The -fno-emulated-tls flag above configures
303 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
304 // symbol instead, which isn't defined. Disable the fuzzer for this test
305 // until the platform is switched to ELF TLS.
306 sanitize: {
307 fuzzer: false,
308 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800309}
310
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800311cc_test_library {
312 name: "libBionicFramePointerTests",
313 defaults: ["bionic_tests_defaults"],
314 srcs: [
315 "android_unsafe_frame_pointer_chase_test.cpp",
316 ],
317 include_dirs: [
318 "bionic/libc",
319 ],
320 cflags: [
321 "-fno-omit-frame-pointer",
322 ],
323}
324
Colin Cross2722ebb2016-07-11 16:20:06 -0700325// -----------------------------------------------------------------------------
326// Fortify tests.
327// -----------------------------------------------------------------------------
328
329cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700330 name: "bionic_clang_fortify_tests_w_flags",
331 cflags: [
332 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700333 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700334 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700335 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700336 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700337 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700338 "-Wno-strncat-size",
339 ],
340}
341
342cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700343 name: "bionic_fortify_tests_defaults",
344 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700345 "-U_FORTIFY_SOURCE",
346 ],
347 srcs: ["fortify_test_main.cpp"],
348 target: {
349 host: {
350 clang_cflags: ["-D__clang__"],
351 },
352 },
353}
354
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700355// Ensures that FORTIFY checks aren't run when ASAN is on.
356cc_test {
357 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700358 defaults: [
359 "bionic_clang_fortify_tests_w_flags",
360 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700361 cflags: [
362 "-Werror",
363 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700364 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700365 sanitize: {
366 address: true,
367 },
368 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700369}
370
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700371// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
372// it can confuse these tools pretty easily. If this builds successfully, then
373// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
374// enabled. The library that results from building this is meant to be unused.
375cc_test_library {
376 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700377 defaults: [
378 "bionic_clang_fortify_tests_w_flags",
379 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700380 cflags: [
381 "-Werror",
382 "-D_FORTIFY_SOURCE=2",
383 "-D__clang_analyzer__",
384 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700385 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700386}
387
Colin Cross2722ebb2016-07-11 16:20:06 -0700388cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700389 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800390 defaults: [
391 "bionic_fortify_tests_defaults",
392 "bionic_tests_defaults",
393 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700394 cflags: [
395 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800396 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700397 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700398 shared: {
399 enabled: false,
400 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700401}
402
403cc_test_library {
404 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800405 defaults: [
406 "bionic_fortify_tests_defaults",
407 "bionic_tests_defaults",
408 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700409 cflags: [
410 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800411 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700412 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700413 shared: {
414 enabled: false,
415 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700416}
417
George Burgess IV9a274102019-06-04 15:39:52 -0700418cc_defaults {
419 name: "bionic_new_fortify_tests_defaults",
420 defaults: [
421 "bionic_clang_fortify_tests_w_flags",
422 ],
423 cflags: [
424 "-U_FORTIFY_SOURCE",
425 ],
426 srcs: ["clang_fortify_tests.cpp"],
427 target: {
428 host: {
429 clang_cflags: ["-D__clang__"],
430 },
431 },
432}
433
434cc_test_library {
435 name: "libfortify1-new-tests-clang",
436 defaults: [
437 "bionic_new_fortify_tests_defaults",
438 "bionic_tests_defaults",
439 ],
440 cflags: [
441 "-D_FORTIFY_SOURCE=1",
442 "-DTEST_NAME=Fortify1_clang_new",
443 ],
444 shared: {
445 enabled: false,
446 },
447}
448
449cc_test_library {
450 name: "libfortify2-new-tests-clang",
451 defaults: [
452 "bionic_new_fortify_tests_defaults",
453 "bionic_tests_defaults",
454 ],
455 cflags: [
456 "-D_FORTIFY_SOURCE=2",
457 "-DTEST_NAME=Fortify2_clang_new",
458 ],
459 shared: {
460 enabled: false,
461 },
462}
463
464
Colin Cross2722ebb2016-07-11 16:20:06 -0700465// -----------------------------------------------------------------------------
466// Library of all tests (excluding the dynamic linker tests).
467// -----------------------------------------------------------------------------
468cc_test_library {
469 name: "libBionicTests",
470 defaults: ["bionic_tests_defaults"],
471 whole_static_libs: [
472 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800473 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800474 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700475 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700476 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700477 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700478 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700479 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700480 shared: {
481 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700482 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700483}
484
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700485cc_test_library {
486 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800487 defaults: [
488 "bionic_tests_defaults",
489 "llvm-defaults",
490 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700491 srcs: [
492 "atexit_test.cpp",
493 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700494 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700495 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700496 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700497 "pthread_dlfcn_test.cpp",
498 ],
499 static_libs: [
500 "libbase",
501 ],
502 include_dirs: [
503 "bionic/libc",
504 ],
505 shared: {
506 enabled: false,
507 },
508 target: {
509 android: {
510 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700511 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700512 "dlext_test.cpp",
513 "libdl_test.cpp",
514 ],
515 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800516 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400517 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700518 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800519 "libLLVMObject",
520 "libLLVMBitReader",
521 "libLLVMMC",
522 "libLLVMMCParser",
523 "libLLVMCore",
524 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700525 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800526 },
Jiyong Park02586a22017-05-20 01:01:24 +0900527 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700528}
529
Colin Cross2722ebb2016-07-11 16:20:06 -0700530// -----------------------------------------------------------------------------
531// Library of bionic customized gtest main function, with normal gtest output format,
532// which is needed by bionic cts test.
533// -----------------------------------------------------------------------------
534cc_test_library {
535 name: "libBionicCtsGtestMain",
536 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700537 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700538 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700539 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700540 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700541 shared: {
542 enabled: false,
543 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700544 whole_static_libs: [
545 "libgtest_isolated",
546 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700547}
548
549// -----------------------------------------------------------------------------
550// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900551// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
552// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700553// -----------------------------------------------------------------------------
554cc_defaults {
555 name: "bionic_unit_tests_defaults",
556 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800557 gtest: false,
558
559 defaults: [
560 "bionic_tests_defaults",
561 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700562
563 whole_static_libs: [
564 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700565 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800566 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700567 ],
568
569 static_libs: [
570 "libtinyxml2",
571 "liblog",
572 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800573 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700574 ],
575
576 srcs: [
577 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700578 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700579 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800580 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700581 "thread_local_test.cpp",
582 ],
583
584 conlyflags: [
585 "-fexceptions",
586 "-fnon-call-exceptions",
587 ],
588
589 ldflags: ["-Wl,--export-dynamic"],
590
591 include_dirs: ["bionic/libc"],
592
Yabin Cui1f553ea2017-01-13 12:31:59 -0800593 stl: "libc++_static",
594
Colin Cross2722ebb2016-07-11 16:20:06 -0700595 target: {
596 android: {
597 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100598 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700599 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100600 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700601 "libdl_preempt_test_1",
602 "libdl_preempt_test_2",
603 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800604 "libtest_elftls_shared_var",
605 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700606 ],
607 static_libs: [
608 // The order of these libraries matters, do not shuffle them.
609 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800610 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700611 "libziparchive",
612 "libz",
613 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800614 "libLLVMObject",
615 "libLLVMBitReader",
616 "libLLVMMC",
617 "libLLVMMCParser",
618 "libLLVMCore",
619 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700620 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700621 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700622 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700623 "-Wl,--enable-new-dtags",
624 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700625 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800626 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700627
628 required: [
629 "cfi_test_helper",
630 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800631 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700632 "exec_linker_helper",
633 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700634 "libtest_dt_runpath_a",
635 "libtest_dt_runpath_b",
636 "libtest_dt_runpath_c",
637 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900638 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700639 "libatest_simple_zip",
640 "libcfi-test",
641 "libcfi-test-bad",
642 "libdlext_test_different_soname",
643 "libdlext_test_fd",
644 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400645 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700646 "libdlext_test_runpath_zip_zipaligned",
647 "libdlext_test",
648 "libdlext_test_zip",
649 "libdlext_test_zip_zipaligned",
650 "libdl_preempt_test_1",
651 "libdl_preempt_test_2",
652 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700653 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800654 "librelocations-ANDROID_RELR",
655 "librelocations-ANDROID_REL",
656 "librelocations-RELR",
657 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700658 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700659 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700660 "libtest_atexit",
661 "libtest_check_order_dlsym_1_left",
662 "libtest_check_order_dlsym_2_right",
663 "libtest_check_order_dlsym_3_c",
664 "libtest_check_order_dlsym_a",
665 "libtest_check_order_dlsym_b",
666 "libtest_check_order_dlsym_d",
667 "libtest_check_order_dlsym",
668 "libtest_check_order_reloc_root_1",
669 "libtest_check_order_reloc_root_2",
670 "libtest_check_order_reloc_root",
671 "libtest_check_order_reloc_siblings_1",
672 "libtest_check_order_reloc_siblings_2",
673 "libtest_check_order_reloc_siblings_3",
674 "libtest_check_order_reloc_siblings_a",
675 "libtest_check_order_reloc_siblings_b",
676 "libtest_check_order_reloc_siblings_c_1",
677 "libtest_check_order_reloc_siblings_c_2",
678 "libtest_check_order_reloc_siblings_c",
679 "libtest_check_order_reloc_siblings_d",
680 "libtest_check_order_reloc_siblings_e",
681 "libtest_check_order_reloc_siblings_f",
682 "libtest_check_order_reloc_siblings",
683 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700684 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700685 "libtest_dlopen_from_ctor_main",
686 "libtest_dlopen_from_ctor",
687 "libtest_dlopen_weak_undefined_func",
688 "libtest_dlsym_df_1_global",
689 "libtest_dlsym_from_this_child",
690 "libtest_dlsym_from_this_grandchild",
691 "libtest_dlsym_from_this",
692 "libtest_dlsym_weak_func",
693 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800694 "libtest_elftls_dynamic",
695 "libtest_elftls_dynamic_filler_1",
696 "libtest_elftls_dynamic_filler_2",
697 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800698 "libtest_elftls_shared_var",
699 "libtest_elftls_shared_var_ie",
700 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700701 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700702 "libtest_ifunc_variable_impl",
703 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700704 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700705 "libtest_init_fini_order_child",
706 "libtest_init_fini_order_grand_child",
707 "libtest_init_fini_order_root2",
708 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700709 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700710 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700711 "libtest_missing_symbol_root",
712 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700713 "libtest_nodelete_1",
714 "libtest_nodelete_2",
715 "libtest_nodelete_dt_flags_1",
716 "libtest_pthread_atfork",
717 "libtest_relo_check_dt_needed_order_1",
718 "libtest_relo_check_dt_needed_order_2",
719 "libtest_relo_check_dt_needed_order",
720 "libtest_simple",
721 "libtest_two_parents_child",
722 "libtest_two_parents_parent1",
723 "libtest_two_parents_parent2",
724 "libtest_versioned_lib",
725 "libtest_versioned_libv1",
726 "libtest_versioned_libv2",
727 "libtest_versioned_otherlib_empty",
728 "libtest_versioned_otherlib",
729 "libtest_versioned_uselibv1",
730 "libtest_versioned_uselibv2_other",
731 "libtest_versioned_uselibv2",
732 "libtest_versioned_uselibv3_other",
733 "libtest_with_dependency_loop_a",
734 "libtest_with_dependency_loop_b",
735 "libtest_with_dependency_loop_c",
736 "libtest_with_dependency_loop",
737 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200738 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700739 "libtest_invalid-empty_shdr_table.so",
740 "libtest_invalid-rw_load_segment.so",
741 "libtest_invalid-unaligned_shdr_offset.so",
742 "libtest_invalid-zero_shdr_table_content.so",
743 "libtest_invalid-zero_shdr_table_offset.so",
744 "libtest_invalid-zero_shentsize.so",
745 "libtest_invalid-zero_shstrndx.so",
746 "libtest_invalid-textrels.so",
747 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700748 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200749 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700750 "preinit_getauxval_test_helper",
751 "preinit_syscall_test_helper",
752 "libnstest_private_external",
753 "libnstest_dlopened",
754 "libnstest_private",
755 "libnstest_root_not_isolated",
756 "libnstest_root",
757 "libnstest_public",
758 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800759 "libnstest_ns_a_public1",
760 "libnstest_ns_a_public1_internal",
761 "libnstest_ns_b_public2",
762 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800763 "ns_hidden_child_helper",
764 "libns_hidden_child_global",
765 "libns_hidden_child_internal",
766 "libns_hidden_child_public",
767 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800768 "libsegment_gap_inner",
769 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900770 "ld_preload_test_helper",
771 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700772 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900773 "ld_config_test_helper",
774 "ld_config_test_helper_lib1",
775 "ld_config_test_helper_lib2",
776 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700777 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700778}
779
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800780cc_test {
781 name: "bionic-unit-tests",
782 defaults: [
783 "bionic_unit_tests_defaults",
784 ],
785}
786
787cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700788 name: "bionic-stress-tests",
789 defaults: [
790 "bionic_tests_defaults",
791 ],
792
793 // For now, these tests run forever, so do not use the isolation framework.
794 isolated: false,
795
796 srcs: [
797 "malloc_stress_test.cpp",
798 ],
799
800 shared_libs: [
801 "libbase",
802 ],
803
804 target: {
805 android: {
806 static_libs: [
807 "libmeminfo",
808 "libprocinfo",
809 ],
810 },
811 },
812}
813
Colin Cross2722ebb2016-07-11 16:20:06 -0700814// -----------------------------------------------------------------------------
815// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900816// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
817// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700818// -----------------------------------------------------------------------------
819cc_test {
820 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700821 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700822 defaults: ["bionic_tests_defaults"],
823 host_supported: false,
824
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800825 srcs: [
826 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700827 "gtest_globals.cpp",
828 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800829
830 // The Bionic allocator has its own C++ API. It isn't packaged into its
831 // own library, so it can only be tested when it's part of libc.a.
832 "bionic_allocator_test.cpp",
833 ],
834 include_dirs: [
835 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800836 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700837 whole_static_libs: [
838 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700839 ],
840
841 static_libs: [
842 "libm",
843 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700844 "libdl",
845 "libtinyxml2",
846 "liblog",
847 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700848 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700849 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800850 "libtest_elftls_shared_var",
851 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700852 ],
853
854 static_executable: true,
855 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700856}
857
858// -----------------------------------------------------------------------------
859// Tests to run on the host and linked against glibc. Run with:
860// cd bionic/tests; mm bionic-unit-tests-glibc-run
861// -----------------------------------------------------------------------------
862
863cc_test_host {
864 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700865 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700866 defaults: ["bionic_tests_defaults"],
867
868 srcs: [
869 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700870 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700871 "dlfcn_test.cpp",
872 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700873 "gtest_globals.cpp",
874 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700875 "pthread_dlfcn_test.cpp",
876 ],
877
878 shared_libs: [
879 "libdl_preempt_test_1",
880 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700881 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800882 "libtest_elftls_shared_var",
883 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700884 ],
885
886 whole_static_libs: [
887 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800888 "libBionicElfTlsTests",
889 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700890 "libfortify1-tests-clang",
891 "libfortify2-tests-clang",
892 ],
893
894 static_libs: [
895 "libbase",
896 "liblog",
897 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700898 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700899 ],
900
901 host_ldlibs: [
902 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700903 "-lutil",
904 ],
905
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700906 include_dirs: [
907 "bionic/libc",
908 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700909
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800910 ldflags: [
911 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
912 "-Wl,--export-dynamic",
913 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700914
915 sanitize: {
916 never: false,
917 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700918
919 target: {
920 linux_bionic: {
921 enabled: false,
922 },
923 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700924}
925
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700926subdirs = ["*"]