blob: b840f367b9fabb5ca25e390f6fc01d4b1bc72e79 [file] [log] [blame]
Colin Cross2722ebb2016-07-11 16:20:06 -07001//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "bionic_tests_defaults",
19 host_supported: true,
Tom Cherry60ddedf2018-02-20 15:40:02 -080020 cpp_std: "experimental",
Colin Cross2722ebb2016-07-11 16:20:06 -070021 target: {
22 darwin: {
23 enabled: false,
24 },
25 },
26 cflags: [
27 "-fstack-protector-all",
28 "-g",
29 "-Wall",
30 "-Wextra",
31 "-Wunused",
32 "-Werror",
33 "-fno-builtin",
34
35 // We want to test deprecated API too.
36 "-Wno-deprecated-declarations",
37
38 // For glibc.
39 "-D__STDC_LIMIT_MACROS",
40 ],
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080041 header_libs: ["bionic_libc_platform_headers"],
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",
48 "-mbranch-protection=standard",
49 ],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080050 },
51 },
Colin Cross2722ebb2016-07-11 16:20:06 -070052 stl: "libc++",
53 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080054 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070055 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090056 bootstrap: true,
Peter Collingbourne6f1fd682020-01-29 16:27:31 -080057
58 product_variables: {
59 experimental_mte: {
60 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
61 },
62 },
Colin Cross2722ebb2016-07-11 16:20:06 -070063}
64
65// -----------------------------------------------------------------------------
66// All standard tests.
67// -----------------------------------------------------------------------------
68
George Burgess IVde45dcb2018-03-16 14:15:01 -070069// Test diagnostics emitted by clang. The library that results is useless; we
70// just want to run '-Xclang -verify', which will fail if the diagnostics don't
71// match up with what the source file says they should be.
72cc_test_library {
73 name: "clang_diagnostic_tests",
74 cflags: [
75 "-Xclang",
76 "-verify",
77 ],
78 srcs: ["sys_ioctl_diag_test.cpp"],
79}
80
Colin Cross2722ebb2016-07-11 16:20:06 -070081cc_test_library {
82 name: "libBionicStandardTests",
83 defaults: ["bionic_tests_defaults"],
84 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -080085 "__aeabi_read_tp_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030086 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -070087 "android_get_device_api_level.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070088 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070089 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070090 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070091 "buffer_tests.cpp",
92 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +030093 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070094 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -070095 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070096 "ctype_test.cpp",
97 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -070098 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080099 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700100 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700101 "error_test.cpp",
102 "eventfd_test.cpp",
103 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700104 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800105 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700106 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800107 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700108 "float_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700109 "ftw_test.cpp",
110 "getauxval_test.cpp",
111 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700112 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700113 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800114 "grp_pwd_file_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700115 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700116 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800117 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700118 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700119 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800120 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700121 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700122 "libgen_basename_test.cpp",
123 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700124 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700125 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700126 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700127 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700128 "malloc_test.cpp",
129 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700130 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100131 "membarrier_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700132 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800133 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700134 "netdb_test.cpp",
135 "net_if_test.cpp",
136 "netinet_ether_test.cpp",
137 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700138 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700139 "netinet_udp_test.cpp",
140 "nl_types_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700141 "poll_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700142 "pthread_test.cpp",
143 "pty_test.cpp",
144 "regex_test.cpp",
145 "resolv_test.cpp",
146 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800147 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700148 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700149 "search_test.cpp",
150 "semaphore_test.cpp",
151 "setjmp_test.cpp",
152 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700153 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700154 "stack_protector_test.cpp",
155 "stack_protector_test_helper.cpp",
156 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700157 "stdalign_test.cpp",
158 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700159 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700160 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700161 "stdint_test.cpp",
162 "stdio_nofortify_test.cpp",
163 "stdio_test.cpp",
164 "stdio_ext_test.cpp",
165 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700166 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700167 "string_nofortify_test.cpp",
168 "string_test.cpp",
169 "string_posix_strerror_r_test.cpp",
170 "strings_nofortify_test.cpp",
171 "strings_test.cpp",
172 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800173 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700174 "sys_epoll_test.cpp",
175 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700176 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700177 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700178 "sys_personality_test.cpp",
179 "sys_prctl_test.cpp",
180 "sys_procfs_test.cpp",
181 "sys_ptrace_test.cpp",
182 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700183 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700184 "sys_resource_test.cpp",
185 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700186 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700187 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700188 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800189 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700190 "sys_socket_test.cpp",
191 "sys_stat_test.cpp",
192 "sys_statvfs_test.cpp",
193 "sys_syscall_test.cpp",
194 "sys_sysinfo_test.cpp",
195 "sys_sysmacros_test.cpp",
196 "sys_time_test.cpp",
197 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700198 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700199 "sys_types_test.cpp",
200 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700201 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700202 "sys_vfs_test.cpp",
203 "sys_xattr_test.cpp",
204 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000205 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800206 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700207 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700208 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700209 "time_test.cpp",
210 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700211 "unistd_nofortify_test.cpp",
212 "unistd_test.cpp",
213 "utmp_test.cpp",
214 "wchar_test.cpp",
215 "wctype_test.cpp",
216 ],
217
218 include_dirs: [
219 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700220 ],
221
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700222 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700223 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800224 whole_static_libs: [
225 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700226 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800227 "libsystemproperties",
228 ],
Mitch Phillips3b21ada2020-01-07 15:47:47 -0800229 srcs: [
230 "tagged_pointers_test.cpp",
231 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700232 },
233 },
234
Dan Willemsen41567702016-08-31 16:35:01 -0700235 static_libs: [
236 "libtinyxml2",
237 "liblog",
238 "libbase",
239 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700240 shared: {
241 enabled: false,
242 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000243
244 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700245}
246
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800247cc_test_library {
248 name: "libBionicElfTlsTests",
249 defaults: ["bionic_tests_defaults"],
250 srcs: [
251 "elftls_test.cpp",
252 ],
253 include_dirs: [
254 "bionic/libc",
255 ],
256 shared: {
257 enabled: false,
258 },
259 cflags: [
260 "-fno-emulated-tls",
261 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700262 // With fuzzer builds, compiler instrumentation generates a reference to the
263 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
264 // library as an emutls symbol. The -fno-emulated-tls flag above configures
265 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
266 // symbol instead, which isn't defined. Disable the fuzzer for this test
267 // until the platform is switched to ELF TLS.
268 sanitize: {
269 fuzzer: false,
270 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800271}
272
273cc_test_library {
274 name: "libBionicElfTlsLoaderTests",
275 defaults: ["bionic_tests_defaults"],
276 srcs: [
277 "elftls_dl_test.cpp",
278 ],
279 include_dirs: [
280 "bionic/libc",
281 ],
282 static_libs: [
283 "liblog",
284 "libbase",
285 ],
286 shared: {
287 enabled: false,
288 },
289 cflags: [
290 "-fno-emulated-tls",
291 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700292 // With fuzzer builds, compiler instrumentation generates a reference to the
293 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
294 // library as an emutls symbol. The -fno-emulated-tls flag above configures
295 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
296 // symbol instead, which isn't defined. Disable the fuzzer for this test
297 // until the platform is switched to ELF TLS.
298 sanitize: {
299 fuzzer: false,
300 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800301}
302
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800303cc_test_library {
304 name: "libBionicFramePointerTests",
305 defaults: ["bionic_tests_defaults"],
306 srcs: [
307 "android_unsafe_frame_pointer_chase_test.cpp",
308 ],
309 include_dirs: [
310 "bionic/libc",
311 ],
312 cflags: [
313 "-fno-omit-frame-pointer",
314 ],
315}
316
Colin Cross2722ebb2016-07-11 16:20:06 -0700317// -----------------------------------------------------------------------------
318// Fortify tests.
319// -----------------------------------------------------------------------------
320
321cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700322 name: "bionic_clang_fortify_tests_w_flags",
323 cflags: [
324 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700325 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700326 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700327 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700328 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700329 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700330 "-Wno-strncat-size",
331 ],
332}
333
334cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700335 name: "bionic_fortify_tests_defaults",
336 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700337 "-U_FORTIFY_SOURCE",
338 ],
339 srcs: ["fortify_test_main.cpp"],
340 target: {
341 host: {
342 clang_cflags: ["-D__clang__"],
343 },
344 },
345}
346
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700347// Ensures that FORTIFY checks aren't run when ASAN is on.
348cc_test {
349 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700350 defaults: [
351 "bionic_clang_fortify_tests_w_flags",
352 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700353 cflags: [
354 "-Werror",
355 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700356 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700357 sanitize: {
358 address: true,
359 },
360 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700361}
362
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700363// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
364// it can confuse these tools pretty easily. If this builds successfully, then
365// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
366// enabled. The library that results from building this is meant to be unused.
367cc_test_library {
368 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700369 defaults: [
370 "bionic_clang_fortify_tests_w_flags",
371 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700372 cflags: [
373 "-Werror",
374 "-D_FORTIFY_SOURCE=2",
375 "-D__clang_analyzer__",
376 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700377 srcs: ["clang_fortify_tests.cpp"],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700378}
379
Colin Cross2722ebb2016-07-11 16:20:06 -0700380cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700381 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800382 defaults: [
383 "bionic_fortify_tests_defaults",
384 "bionic_tests_defaults",
385 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700386 cflags: [
387 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800388 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700389 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700390 shared: {
391 enabled: false,
392 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700393}
394
395cc_test_library {
396 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800397 defaults: [
398 "bionic_fortify_tests_defaults",
399 "bionic_tests_defaults",
400 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700401 cflags: [
402 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800403 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700404 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700405 shared: {
406 enabled: false,
407 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700408}
409
George Burgess IV9a274102019-06-04 15:39:52 -0700410cc_defaults {
411 name: "bionic_new_fortify_tests_defaults",
412 defaults: [
413 "bionic_clang_fortify_tests_w_flags",
414 ],
415 cflags: [
416 "-U_FORTIFY_SOURCE",
417 ],
418 srcs: ["clang_fortify_tests.cpp"],
419 target: {
420 host: {
421 clang_cflags: ["-D__clang__"],
422 },
423 },
424}
425
426cc_test_library {
427 name: "libfortify1-new-tests-clang",
428 defaults: [
429 "bionic_new_fortify_tests_defaults",
430 "bionic_tests_defaults",
431 ],
432 cflags: [
433 "-D_FORTIFY_SOURCE=1",
434 "-DTEST_NAME=Fortify1_clang_new",
435 ],
436 shared: {
437 enabled: false,
438 },
439}
440
441cc_test_library {
442 name: "libfortify2-new-tests-clang",
443 defaults: [
444 "bionic_new_fortify_tests_defaults",
445 "bionic_tests_defaults",
446 ],
447 cflags: [
448 "-D_FORTIFY_SOURCE=2",
449 "-DTEST_NAME=Fortify2_clang_new",
450 ],
451 shared: {
452 enabled: false,
453 },
454}
455
456
Colin Cross2722ebb2016-07-11 16:20:06 -0700457// -----------------------------------------------------------------------------
458// Library of all tests (excluding the dynamic linker tests).
459// -----------------------------------------------------------------------------
460cc_test_library {
461 name: "libBionicTests",
462 defaults: ["bionic_tests_defaults"],
463 whole_static_libs: [
464 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800465 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800466 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700467 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700468 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700469 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700470 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700471 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700472 shared: {
473 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700474 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700475}
476
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700477cc_test_library {
478 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800479 defaults: [
480 "bionic_tests_defaults",
481 "llvm-defaults",
482 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700483 srcs: [
484 "atexit_test.cpp",
485 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700486 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700487 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700488 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700489 "pthread_dlfcn_test.cpp",
490 ],
491 static_libs: [
492 "libbase",
493 ],
494 include_dirs: [
495 "bionic/libc",
496 ],
497 shared: {
498 enabled: false,
499 },
500 target: {
501 android: {
502 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700503 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700504 "dlext_test.cpp",
505 "libdl_test.cpp",
506 ],
507 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800508 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400509 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700510 "libziparchive",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800511 "libLLVMObject",
512 "libLLVMBitReader",
513 "libLLVMMC",
514 "libLLVMMCParser",
515 "libLLVMCore",
516 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700517 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800518 },
Jiyong Park02586a22017-05-20 01:01:24 +0900519 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700520}
521
Colin Cross2722ebb2016-07-11 16:20:06 -0700522// -----------------------------------------------------------------------------
523// Library of bionic customized gtest main function, with normal gtest output format,
524// which is needed by bionic cts test.
525// -----------------------------------------------------------------------------
526cc_test_library {
527 name: "libBionicCtsGtestMain",
528 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700529 srcs: [
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700530 "gtest_globals_cts.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700531 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700532 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700533 shared: {
534 enabled: false,
535 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700536 whole_static_libs: [
537 "libgtest_isolated",
538 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700539}
540
541// -----------------------------------------------------------------------------
542// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900543// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
544// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700545// -----------------------------------------------------------------------------
546cc_defaults {
547 name: "bionic_unit_tests_defaults",
548 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800549 gtest: false,
550
551 defaults: [
552 "bionic_tests_defaults",
553 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700554
555 whole_static_libs: [
556 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700557 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800558 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700559 ],
560
561 static_libs: [
562 "libtinyxml2",
563 "liblog",
564 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800565 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700566 ],
567
568 srcs: [
569 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700570 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700571 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800572 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700573 "thread_local_test.cpp",
574 ],
575
576 conlyflags: [
577 "-fexceptions",
578 "-fnon-call-exceptions",
579 ],
580
581 ldflags: ["-Wl,--export-dynamic"],
582
583 include_dirs: ["bionic/libc"],
584
Yabin Cui1f553ea2017-01-13 12:31:59 -0800585 stl: "libc++_static",
586
Colin Cross2722ebb2016-07-11 16:20:06 -0700587 target: {
588 android: {
589 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100590 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700591 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100592 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700593 "libdl_preempt_test_1",
594 "libdl_preempt_test_2",
595 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800596 "libtest_elftls_shared_var",
597 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700598 ],
599 static_libs: [
600 // The order of these libraries matters, do not shuffle them.
601 "libbase",
Sandeep Patile3f39a02019-01-21 14:22:05 -0800602 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700603 "libziparchive",
604 "libz",
605 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800606 "libLLVMObject",
607 "libLLVMBitReader",
608 "libLLVMMC",
609 "libLLVMMCParser",
610 "libLLVMCore",
611 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700612 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700613 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700614 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700615 "-Wl,--enable-new-dtags",
616 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700617 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800618 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700619
620 required: [
621 "cfi_test_helper",
622 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800623 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700624 "exec_linker_helper",
625 "exec_linker_helper_lib",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700626 "libtest_dt_runpath_a",
627 "libtest_dt_runpath_b",
628 "libtest_dt_runpath_c",
629 "libtest_dt_runpath_x",
Jiyong Parkd7ca6782019-01-20 01:41:42 +0900630 "libtest_dt_runpath_y",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700631 "libatest_simple_zip",
632 "libcfi-test",
633 "libcfi-test-bad",
634 "libdlext_test_different_soname",
635 "libdlext_test_fd",
636 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400637 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700638 "libdlext_test_runpath_zip_zipaligned",
639 "libdlext_test",
640 "libdlext_test_zip",
641 "libdlext_test_zip_zipaligned",
642 "libdl_preempt_test_1",
643 "libdl_preempt_test_2",
644 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700645 "libgnu-hash-table-library",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800646 "librelocations-ANDROID_RELR",
647 "librelocations-ANDROID_REL",
648 "librelocations-RELR",
649 "librelocations-fat",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700650 "libsysv-hash-table-library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700651 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700652 "libtest_atexit",
653 "libtest_check_order_dlsym_1_left",
654 "libtest_check_order_dlsym_2_right",
655 "libtest_check_order_dlsym_3_c",
656 "libtest_check_order_dlsym_a",
657 "libtest_check_order_dlsym_b",
658 "libtest_check_order_dlsym_d",
659 "libtest_check_order_dlsym",
660 "libtest_check_order_reloc_root_1",
661 "libtest_check_order_reloc_root_2",
662 "libtest_check_order_reloc_root",
663 "libtest_check_order_reloc_siblings_1",
664 "libtest_check_order_reloc_siblings_2",
665 "libtest_check_order_reloc_siblings_3",
666 "libtest_check_order_reloc_siblings_a",
667 "libtest_check_order_reloc_siblings_b",
668 "libtest_check_order_reloc_siblings_c_1",
669 "libtest_check_order_reloc_siblings_c_2",
670 "libtest_check_order_reloc_siblings_c",
671 "libtest_check_order_reloc_siblings_d",
672 "libtest_check_order_reloc_siblings_e",
673 "libtest_check_order_reloc_siblings_f",
674 "libtest_check_order_reloc_siblings",
675 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700676 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700677 "libtest_dlopen_from_ctor_main",
678 "libtest_dlopen_from_ctor",
679 "libtest_dlopen_weak_undefined_func",
680 "libtest_dlsym_df_1_global",
681 "libtest_dlsym_from_this_child",
682 "libtest_dlsym_from_this_grandchild",
683 "libtest_dlsym_from_this",
684 "libtest_dlsym_weak_func",
685 "libtest_dt_runpath_d",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800686 "libtest_elftls_dynamic",
687 "libtest_elftls_dynamic_filler_1",
688 "libtest_elftls_dynamic_filler_2",
689 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800690 "libtest_elftls_shared_var",
691 "libtest_elftls_shared_var_ie",
692 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700693 "libtest_empty",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700694 "libtest_ifunc_variable_impl",
695 "libtest_ifunc_variable",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700696 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700697 "libtest_init_fini_order_child",
698 "libtest_init_fini_order_grand_child",
699 "libtest_init_fini_order_root2",
700 "libtest_init_fini_order_root",
Pirama Arumuga Nainar1395f702018-03-28 15:27:12 -0700701 "libtest_missing_symbol_child_public",
Elliott Hughes06d31c92018-03-29 11:28:53 -0700702 "libtest_missing_symbol_child_private",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700703 "libtest_missing_symbol_root",
704 "libtest_missing_symbol",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700705 "libtest_nodelete_1",
706 "libtest_nodelete_2",
707 "libtest_nodelete_dt_flags_1",
708 "libtest_pthread_atfork",
709 "libtest_relo_check_dt_needed_order_1",
710 "libtest_relo_check_dt_needed_order_2",
711 "libtest_relo_check_dt_needed_order",
712 "libtest_simple",
713 "libtest_two_parents_child",
714 "libtest_two_parents_parent1",
715 "libtest_two_parents_parent2",
716 "libtest_versioned_lib",
717 "libtest_versioned_libv1",
718 "libtest_versioned_libv2",
719 "libtest_versioned_otherlib_empty",
720 "libtest_versioned_otherlib",
721 "libtest_versioned_uselibv1",
722 "libtest_versioned_uselibv2_other",
723 "libtest_versioned_uselibv2",
724 "libtest_versioned_uselibv3_other",
725 "libtest_with_dependency_loop_a",
726 "libtest_with_dependency_loop_b",
727 "libtest_with_dependency_loop_c",
728 "libtest_with_dependency_loop",
729 "libtest_with_dependency",
dimitry55547db2018-05-25 14:17:37 +0200730 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700731 "libtest_invalid-empty_shdr_table.so",
732 "libtest_invalid-rw_load_segment.so",
733 "libtest_invalid-unaligned_shdr_offset.so",
734 "libtest_invalid-zero_shdr_table_content.so",
735 "libtest_invalid-zero_shdr_table_offset.so",
736 "libtest_invalid-zero_shentsize.so",
737 "libtest_invalid-zero_shstrndx.so",
738 "libtest_invalid-textrels.so",
739 "libtest_invalid-textrels2.so",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700740 "libtest_thread_local_dtor",
dimitry55547db2018-05-25 14:17:37 +0200741 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700742 "preinit_getauxval_test_helper",
743 "preinit_syscall_test_helper",
744 "libnstest_private_external",
745 "libnstest_dlopened",
746 "libnstest_private",
747 "libnstest_root_not_isolated",
748 "libnstest_root",
749 "libnstest_public",
750 "libnstest_public_internal",
Logan Chien9ee45912018-01-18 12:05:09 +0800751 "libnstest_ns_a_public1",
752 "libnstest_ns_a_public1_internal",
753 "libnstest_ns_b_public2",
754 "libnstest_ns_b_public3",
Ryan Prichard22fa3dd2020-01-31 14:47:48 -0800755 "ns_hidden_child_helper",
756 "libns_hidden_child_global",
757 "libns_hidden_child_internal",
758 "libns_hidden_child_public",
759 "libns_hidden_child_app",
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -0800760 "libsegment_gap_inner",
761 "libsegment_gap_outer",
Jiyong Parkce10b162018-03-29 10:34:41 +0900762 "ld_preload_test_helper",
763 "ld_preload_test_helper_lib1",
Elliott Hughes51466522018-03-29 11:17:37 -0700764 "ld_preload_test_helper_lib2",
Jiyong Parkce10b162018-03-29 10:34:41 +0900765 "ld_config_test_helper",
766 "ld_config_test_helper_lib1",
767 "ld_config_test_helper_lib2",
768 "ld_config_test_helper_lib3",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700769 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700770}
771
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800772cc_test {
773 name: "bionic-unit-tests",
774 defaults: [
775 "bionic_unit_tests_defaults",
776 ],
777}
778
779cc_test {
780 name: "bionic-unit-tests-scudo",
781 defaults: [
782 "bionic_unit_tests_defaults",
783 ],
784
785 shared_libs: [
786 "libc_scudo",
787 ],
788}
789
Christopher Ferrisee0ce442019-10-21 12:35:05 -0700790cc_test {
791 name: "bionic-stress-tests",
792 defaults: [
793 "bionic_tests_defaults",
794 ],
795
796 // For now, these tests run forever, so do not use the isolation framework.
797 isolated: false,
798
799 srcs: [
800 "malloc_stress_test.cpp",
801 ],
802
803 shared_libs: [
804 "libbase",
805 ],
806
807 target: {
808 android: {
809 static_libs: [
810 "libmeminfo",
811 "libprocinfo",
812 ],
813 },
814 },
815}
816
Colin Cross2722ebb2016-07-11 16:20:06 -0700817// -----------------------------------------------------------------------------
818// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900819// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
820// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -0700821// -----------------------------------------------------------------------------
822cc_test {
823 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700824 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700825 defaults: ["bionic_tests_defaults"],
826 host_supported: false,
827
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800828 srcs: [
829 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700830 "gtest_globals.cpp",
831 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -0800832
833 // The Bionic allocator has its own C++ API. It isn't packaged into its
834 // own library, so it can only be tested when it's part of libc.a.
835 "bionic_allocator_test.cpp",
836 ],
837 include_dirs: [
838 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800839 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700840 whole_static_libs: [
841 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700842 ],
843
844 static_libs: [
845 "libm",
846 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700847 "libdl",
848 "libtinyxml2",
849 "liblog",
850 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700851 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700852 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800853 "libtest_elftls_shared_var",
854 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700855 ],
856
857 static_executable: true,
858 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -0700859}
860
861// -----------------------------------------------------------------------------
862// Tests to run on the host and linked against glibc. Run with:
863// cd bionic/tests; mm bionic-unit-tests-glibc-run
864// -----------------------------------------------------------------------------
865
866cc_test_host {
867 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700868 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700869 defaults: ["bionic_tests_defaults"],
870
871 srcs: [
872 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700873 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700874 "dlfcn_test.cpp",
875 "dl_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700876 "gtest_globals.cpp",
877 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700878 "pthread_dlfcn_test.cpp",
879 ],
880
881 shared_libs: [
882 "libdl_preempt_test_1",
883 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -0700884 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800885 "libtest_elftls_shared_var",
886 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700887 ],
888
889 whole_static_libs: [
890 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800891 "libBionicElfTlsTests",
892 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700893 "libfortify1-tests-clang",
894 "libfortify2-tests-clang",
895 ],
896
897 static_libs: [
898 "libbase",
899 "liblog",
900 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700901 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700902 ],
903
904 host_ldlibs: [
905 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -0700906 "-lutil",
907 ],
908
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700909 include_dirs: [
910 "bionic/libc",
911 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700912
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800913 ldflags: [
914 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
915 "-Wl,--export-dynamic",
916 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700917
918 sanitize: {
919 never: false,
920 },
Dan Willemsen268ae362017-09-21 16:56:06 -0700921
922 target: {
923 linux_bionic: {
924 enabled: false,
925 },
926 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700927}
928
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700929subdirs = ["*"]