blob: 226453ae55cf1e500efe6bac3a79f4ad83b883db [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
Bob Badouraa7d8352021-02-19 13:06:22 -080017package {
Aditya Choudharyd9d37c02024-02-02 13:57:12 +000018 default_team: "trendy_team_native_tools_libraries",
Bob Badouraa7d8352021-02-19 13:06:22 -080019 default_applicable_licenses: ["bionic_tests_license"],
20}
21
22license {
23 name: "bionic_tests_license",
24 visibility: [":__subpackages__"],
25 license_kinds: [
26 "SPDX-license-identifier-Apache-2.0",
27 "SPDX-license-identifier-BSD",
28 ],
29 license_text: [
30 "NOTICE",
31 ],
32}
33
Colin Cross2722ebb2016-07-11 16:20:06 -070034cc_defaults {
35 name: "bionic_tests_defaults",
36 host_supported: true,
37 target: {
38 darwin: {
39 enabled: false,
40 },
Martin Stjernholma2763432020-04-23 16:47:19 +010041 android: {
42 header_libs: ["bionic_libc_platform_headers"],
43 },
44 linux_bionic: {
45 header_libs: ["bionic_libc_platform_headers"],
46 },
Colin Cross2722ebb2016-07-11 16:20:06 -070047 },
48 cflags: [
49 "-fstack-protector-all",
50 "-g",
51 "-Wall",
52 "-Wextra",
53 "-Wunused",
54 "-Werror",
55 "-fno-builtin",
56
57 // We want to test deprecated API too.
58 "-Wno-deprecated-declarations",
59
Peter Collingbourne4edf74a2020-10-02 13:47:03 -070060 // Needed to test pthread_internal_t layout.
61 "-Wno-invalid-offsetof",
62
Christopher Ferris1de7a482023-09-12 11:06:29 -070063 // This warning does not provide any benefit to the tests.
64 "-Wno-reorder-init-list",
Colin Cross2722ebb2016-07-11 16:20:06 -070065 ],
Mitch Phillipse6997d52020-11-30 15:04:14 -080066 header_libs: [
67 "libcutils_headers",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +000068 "gwp_asan_headers",
Mitch Phillipse6997d52020-11-30 15:04:14 -080069 ],
Elliott Hughes9a7155d2023-02-10 02:00:03 +000070 stl: "libc++",
71
72 // Ensure that the tests exercise shadow call stack support.
73 // We don't use `scs: true` here because that would give us a second
74 // variant of this library where we actually just want to say "this
75 // library should always be built this way".
Peter Collingbourne7b70e272018-11-12 20:09:14 -080076 arch: {
77 arm64: {
Elliott Hughes9a7155d2023-02-10 02:00:03 +000078 cflags: ["-fsanitize=shadow-call-stack"],
79 },
80 riscv64: {
81 cflags: ["-fsanitize=shadow-call-stack"],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080082 },
83 },
Colin Cross2722ebb2016-07-11 16:20:06 -070084 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080085 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070086 },
Ryan Prichard3c5dff42020-03-31 17:34:03 -070087
88 // Use the bootstrap version of bionic because some tests call private APIs
89 // that aren't exposed by the APEX bionic stubs.
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090090 bootstrap: true,
Colin Cross2722ebb2016-07-11 16:20:06 -070091}
92
93// -----------------------------------------------------------------------------
Chris Parsonscab794c2020-06-15 18:22:10 -040094// Prebuilt shared libraries for use in tests.
95// -----------------------------------------------------------------------------
96
97cc_prebuilt_test_library_shared {
98 name: "libtest_invalid-rw_load_segment",
99 strip: {
100 none: true,
101 },
102 check_elf_files: false,
103 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
104 arch: {
105 arm: {
106 srcs: ["prebuilt-elf-files/arm/libtest_invalid-rw_load_segment.so"],
107 },
108 arm64: {
109 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so"],
110 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000111 riscv64: {
112 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-rw_load_segment.so"],
113 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400114 x86: {
115 srcs: ["prebuilt-elf-files/x86/libtest_invalid-rw_load_segment.so"],
116 },
117 x86_64: {
118 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so"],
119 },
120 },
121}
122
123cc_prebuilt_test_library_shared {
124 name: "libtest_invalid-unaligned_shdr_offset",
125 strip: {
126 none: true,
127 },
128 check_elf_files: false,
129 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
130 arch: {
131 arm: {
132 srcs: ["prebuilt-elf-files/arm/libtest_invalid-unaligned_shdr_offset.so"],
133 },
134 arm64: {
135 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-unaligned_shdr_offset.so"],
136 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000137 riscv64: {
138 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-unaligned_shdr_offset.so"],
139 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400140 x86: {
141 srcs: ["prebuilt-elf-files/x86/libtest_invalid-unaligned_shdr_offset.so"],
142 },
143 x86_64: {
144 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-unaligned_shdr_offset.so"],
145 },
146 },
147}
148
149cc_prebuilt_test_library_shared {
150 name: "libtest_invalid-zero_shentsize",
151 strip: {
152 none: true,
153 },
154 check_elf_files: false,
155 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
156 arch: {
157 arm: {
158 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shentsize.so"],
159 },
160 arm64: {
161 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shentsize.so"],
162 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000163 riscv64: {
164 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shentsize.so"],
165 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400166 x86: {
167 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shentsize.so"],
168 },
169 x86_64: {
170 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shentsize.so"],
171 },
172 },
173}
174
175cc_prebuilt_test_library_shared {
176 name: "libtest_invalid-zero_shstrndx",
177 strip: {
178 none: true,
179 },
180 check_elf_files: false,
181 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
182 arch: {
183 arm: {
184 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shstrndx.so"],
185 },
186 arm64: {
187 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shstrndx.so"],
188 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000189 riscv64: {
190 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shstrndx.so"],
191 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400192 x86: {
193 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shstrndx.so"],
194 },
195 x86_64: {
196 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shstrndx.so"],
197 },
198 },
199}
200
201cc_prebuilt_test_library_shared {
202 name: "libtest_invalid-empty_shdr_table",
203 strip: {
204 none: true,
205 },
206 check_elf_files: false,
207 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
208 arch: {
209 arm: {
210 srcs: ["prebuilt-elf-files/arm/libtest_invalid-empty_shdr_table.so"],
211 },
212 arm64: {
213 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-empty_shdr_table.so"],
214 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000215 riscv64: {
216 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-empty_shdr_table.so"],
217 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400218 x86: {
219 srcs: ["prebuilt-elf-files/x86/libtest_invalid-empty_shdr_table.so"],
220 },
221 x86_64: {
222 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-empty_shdr_table.so"],
223 },
224 },
225}
226
227cc_prebuilt_test_library_shared {
228 name: "libtest_invalid-zero_shdr_table_offset",
229 strip: {
230 none: true,
231 },
232 check_elf_files: false,
233 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
234 arch: {
235 arm: {
236 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_offset.so"],
237 },
238 arm64: {
239 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_offset.so"],
240 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000241 riscv64: {
242 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shdr_table_offset.so"],
243 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400244 x86: {
245 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_offset.so"],
246 },
247 x86_64: {
248 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_offset.so"],
249 },
250 },
251}
252
253cc_prebuilt_test_library_shared {
254 name: "libtest_invalid-zero_shdr_table_content",
255 strip: {
256 none: true,
257 },
258 check_elf_files: false,
259 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
260 arch: {
261 arm: {
262 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_content.so"],
263 },
264 arm64: {
265 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_content.so"],
266 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000267 riscv64: {
268 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shdr_table_content.so"],
269 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400270 x86: {
271 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_content.so"],
272 },
273 x86_64: {
274 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_content.so"],
275 },
276 },
277}
278
279cc_prebuilt_test_library_shared {
280 name: "libtest_invalid-textrels",
281 strip: {
282 none: true,
283 },
284 check_elf_files: false,
285 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
286 arch: {
287 arm: {
288 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels.so"],
289 },
290 arm64: {
291 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels.so"],
292 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000293 riscv64: {
294 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-textrels.so"],
295 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400296 x86: {
297 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels.so"],
298 },
299 x86_64: {
300 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels.so"],
301 },
302 },
303}
304
305cc_prebuilt_test_library_shared {
306 name: "libtest_invalid-textrels2",
307 strip: {
308 none: true,
309 },
310 check_elf_files: false,
311 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
312 arch: {
313 arm: {
314 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels2.so"],
315 },
316 arm64: {
317 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels2.so"],
318 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000319 riscv64: {
320 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-textrels2.so"],
321 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400322 x86: {
323 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels2.so"],
324 },
325 x86_64: {
326 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels2.so"],
327 },
328 },
329}
330
Ryan Prichard8ea6af52022-03-24 21:14:27 -0700331cc_prebuilt_test_library_shared {
332 name: "libtest_invalid-local-tls",
333 strip: {
334 none: true,
335 },
336 check_elf_files: false,
337 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
338 arch: {
339 arm: {
340 srcs: ["prebuilt-elf-files/arm/libtest_invalid-local-tls.so"],
341 },
342 arm64: {
343 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-local-tls.so"],
344 },
345 x86: {
346 srcs: ["prebuilt-elf-files/x86/libtest_invalid-local-tls.so"],
347 },
348 x86_64: {
349 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-local-tls.so"],
350 },
351 },
352}
353
Chris Parsonscab794c2020-06-15 18:22:10 -0400354// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -0700355// All standard tests.
356// -----------------------------------------------------------------------------
357
George Burgess IVde45dcb2018-03-16 14:15:01 -0700358// Test diagnostics emitted by clang. The library that results is useless; we
359// just want to run '-Xclang -verify', which will fail if the diagnostics don't
360// match up with what the source file says they should be.
361cc_test_library {
362 name: "clang_diagnostic_tests",
363 cflags: [
Elliott Hughes2a34a672024-07-10 11:42:33 +0000364 "-Xclang -verify",
George Burgess IVde45dcb2018-03-16 14:15:01 -0700365 ],
366 srcs: ["sys_ioctl_diag_test.cpp"],
367}
368
Colin Cross2722ebb2016-07-11 16:20:06 -0700369cc_test_library {
370 name: "libBionicStandardTests",
Dennis Shen5951b412023-12-21 19:57:13 +0000371 defaults: [
372 "bionic_tests_defaults",
373 "large_system_property_node_defaults",
374 ],
Chih-Hung Hsieh6fae6142022-12-15 19:30:55 -0800375 tidy_disabled_srcs: [
376 "malloc_test.cpp", // timed out with clang-tidy, and too many warnings
377 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700378 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -0800379 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -0800380 "__cxa_atexit_test.cpp",
Elliott Hughes413817f2020-10-26 15:05:35 -0700381 "__cxa_demangle_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300382 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -0700383 "android_get_device_api_level.cpp",
Christopher Ferrisbbf9cd82022-04-11 16:01:37 -0700384 "android_set_abort_message_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700385 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700386 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -0700387 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700388 "buffer_tests.cpp",
389 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300390 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700391 "complex_test.cpp",
392 "ctype_test.cpp",
393 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -0700394 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800395 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700396 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700397 "error_test.cpp",
398 "eventfd_test.cpp",
399 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700400 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800401 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700402 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800403 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700404 "float_test.cpp",
Elliott Hughes6675ad32020-11-20 16:51:21 -0800405 "fnmatch_test.cpp",
Elliott Hughesda81ec42024-06-27 22:09:03 +0000406 "fts_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700407 "ftw_test.cpp",
408 "getauxval_test.cpp",
409 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700410 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700411 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800412 "grp_pwd_file_test.cpp",
Peter Collingbourned3060012020-04-01 19:54:48 -0700413 "heap_tagging_level_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700414 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700415 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800416 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700417 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700418 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800419 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700420 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700421 "libgen_basename_test.cpp",
422 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700423 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700424 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700425 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700426 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700427 "malloc_test.cpp",
428 "math_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100429 "membarrier_test.cpp",
Florian Mayerc82d7fc2022-08-31 20:57:03 +0000430 "memtag_stack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700431 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800432 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700433 "netdb_test.cpp",
434 "net_if_test.cpp",
435 "netinet_ether_test.cpp",
Elliott Hughes72962742024-06-17 15:38:29 +0000436 "netinet_igmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700437 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700438 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700439 "netinet_udp_test.cpp",
440 "nl_types_test.cpp",
Josh Gao3de19152021-02-22 18:09:48 -0800441 "pidfd_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700442 "poll_test.cpp",
Matthew Maurerde306352020-10-23 09:55:33 -0700443 "prio_ctor_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700444 "pthread_test.cpp",
445 "pty_test.cpp",
446 "regex_test.cpp",
447 "resolv_test.cpp",
448 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800449 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700450 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700451 "search_test.cpp",
452 "semaphore_test.cpp",
453 "setjmp_test.cpp",
454 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700455 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700456 "stack_protector_test.cpp",
457 "stack_protector_test_helper.cpp",
458 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700459 "stdalign_test.cpp",
460 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700461 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700462 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700463 "stdint_test.cpp",
464 "stdio_nofortify_test.cpp",
465 "stdio_test.cpp",
466 "stdio_ext_test.cpp",
467 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700468 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700469 "string_nofortify_test.cpp",
470 "string_test.cpp",
471 "string_posix_strerror_r_test.cpp",
Colin Cross4408b8a2021-07-29 22:45:34 -0700472 "string_posix_strerror_r_wrapper.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700473 "strings_nofortify_test.cpp",
474 "strings_test.cpp",
Peter Collingbourne4edf74a2020-10-02 13:47:03 -0700475 "struct_layout_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700476 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800477 "sys_auxv_test.cpp",
Elliott Hughes74d97652023-07-12 16:30:55 -0700478 "sys_cachectl_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700479 "sys_epoll_test.cpp",
Elliott Hughesf3d6b442023-07-27 16:53:30 -0700480 "sys_hwprobe_test.cpp",
Elliott Hughesf274a202024-06-17 15:07:25 +0000481 "sys_io_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700482 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700483 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700484 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700485 "sys_personality_test.cpp",
486 "sys_prctl_test.cpp",
487 "sys_procfs_test.cpp",
488 "sys_ptrace_test.cpp",
489 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700490 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700491 "sys_resource_test.cpp",
492 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700493 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700494 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700495 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800496 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700497 "sys_socket_test.cpp",
498 "sys_stat_test.cpp",
499 "sys_statvfs_test.cpp",
500 "sys_syscall_test.cpp",
501 "sys_sysinfo_test.cpp",
502 "sys_sysmacros_test.cpp",
503 "sys_time_test.cpp",
504 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700505 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700506 "sys_types_test.cpp",
507 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700508 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700509 "sys_vfs_test.cpp",
Elliott Hughes7cebf832020-08-12 14:25:41 -0700510 "sys_wait_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700511 "sys_xattr_test.cpp",
Elliott Hughes213d9432023-03-01 22:56:13 +0000512 "syslog_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700513 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000514 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800515 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700516 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700517 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700518 "time_test.cpp",
519 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700520 "unistd_nofortify_test.cpp",
521 "unistd_test.cpp",
Mitch Phillips9634c362022-06-23 11:07:00 -0700522 "utils.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700523 "utmp_test.cpp",
Elliott Hughesdbf5b2e2023-04-03 16:30:39 -0700524 "utmpx_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700525 "wchar_test.cpp",
526 "wctype_test.cpp",
527 ],
528
529 include_dirs: [
530 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700531 ],
532
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700533 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700534 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800535 whole_static_libs: [
536 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700537 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800538 "libsystemproperties",
539 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700540 },
Colin Cross7da20342021-07-28 11:18:11 -0700541 musl: {
542 exclude_srcs: [
543 // musl doesn't have error.h
544 "error_test.cpp",
545
546 // musl doesn't define noreturn for C++
547 "stdnoreturn_test.cpp",
548
549 // unsupported relocation type 37
550 "ifunc_test.cpp",
Colin Cross118202b2023-04-14 09:33:11 -0700551
552 // musl #defines utmp to utmpx, causing a collision with
553 // utmpx_test.cpp
554 "utmp_test.cpp",
Colin Cross7da20342021-07-28 11:18:11 -0700555 ],
556 },
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700557 },
558
Dan Willemsen41567702016-08-31 16:35:01 -0700559 static_libs: [
560 "libtinyxml2",
561 "liblog",
562 "libbase",
563 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700564 shared: {
565 enabled: false,
566 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000567
568 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700569}
570
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800571cc_test_library {
572 name: "libBionicElfTlsTests",
573 defaults: ["bionic_tests_defaults"],
574 srcs: [
575 "elftls_test.cpp",
576 ],
577 include_dirs: [
578 "bionic/libc",
579 ],
Ryan Prichard43963922024-03-14 16:51:27 -0700580 static_libs: [
581 "libbase",
582 ],
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800583 shared: {
584 enabled: false,
585 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800586}
587
588cc_test_library {
589 name: "libBionicElfTlsLoaderTests",
590 defaults: ["bionic_tests_defaults"],
591 srcs: [
592 "elftls_dl_test.cpp",
593 ],
594 include_dirs: [
595 "bionic/libc",
596 ],
597 static_libs: [
598 "liblog",
599 "libbase",
600 ],
601 shared: {
602 enabled: false,
603 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800604}
605
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800606cc_test_library {
607 name: "libBionicFramePointerTests",
608 defaults: ["bionic_tests_defaults"],
609 srcs: [
610 "android_unsafe_frame_pointer_chase_test.cpp",
611 ],
612 include_dirs: [
613 "bionic/libc",
614 ],
615 cflags: [
616 "-fno-omit-frame-pointer",
617 ],
618}
619
Colin Cross2722ebb2016-07-11 16:20:06 -0700620// -----------------------------------------------------------------------------
621// Fortify tests.
622// -----------------------------------------------------------------------------
623
624cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700625 name: "bionic_clang_fortify_tests_w_flags",
626 cflags: [
627 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700628 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700629 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700630 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700631 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700632 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700633 "-Wno-strncat-size",
634 ],
Elliott Hughes141b9172021-04-09 17:13:09 -0700635 static_libs: [
636 "libbase",
637 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700638}
639
640cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700641 name: "bionic_fortify_tests_defaults",
642 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700643 "-U_FORTIFY_SOURCE",
644 ],
645 srcs: ["fortify_test_main.cpp"],
Elliott Hughes141b9172021-04-09 17:13:09 -0700646 static_libs: [
647 "libbase",
648 ],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800649 tidy: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700650 target: {
Colin Crossa48237b2022-02-03 10:28:12 -0800651 musl: {
652 // Musl doesn't have fortify
653 enabled: false,
654 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700655 },
656}
657
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700658// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
659// it can confuse these tools pretty easily. If this builds successfully, then
660// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
661// enabled. The library that results from building this is meant to be unused.
662cc_test_library {
663 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700664 defaults: [
665 "bionic_clang_fortify_tests_w_flags",
666 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700667 cflags: [
668 "-Werror",
669 "-D_FORTIFY_SOURCE=2",
670 "-D__clang_analyzer__",
671 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700672 srcs: ["clang_fortify_tests.cpp"],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800673 tidy: false,
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700674}
675
Colin Cross2722ebb2016-07-11 16:20:06 -0700676cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700677 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800678 defaults: [
679 "bionic_fortify_tests_defaults",
680 "bionic_tests_defaults",
681 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700682 cflags: [
683 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800684 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700685 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700686 shared: {
687 enabled: false,
688 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700689}
690
691cc_test_library {
692 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800693 defaults: [
694 "bionic_fortify_tests_defaults",
695 "bionic_tests_defaults",
696 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700697 cflags: [
698 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800699 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700700 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700701 shared: {
702 enabled: false,
703 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700704}
705
George Burgess IV9a274102019-06-04 15:39:52 -0700706cc_defaults {
707 name: "bionic_new_fortify_tests_defaults",
708 defaults: [
709 "bionic_clang_fortify_tests_w_flags",
710 ],
711 cflags: [
712 "-U_FORTIFY_SOURCE",
713 ],
714 srcs: ["clang_fortify_tests.cpp"],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800715 tidy: false,
George Burgess IV9a274102019-06-04 15:39:52 -0700716}
717
718cc_test_library {
719 name: "libfortify1-new-tests-clang",
720 defaults: [
721 "bionic_new_fortify_tests_defaults",
722 "bionic_tests_defaults",
723 ],
724 cflags: [
725 "-D_FORTIFY_SOURCE=1",
726 "-DTEST_NAME=Fortify1_clang_new",
727 ],
728 shared: {
729 enabled: false,
730 },
731}
732
733cc_test_library {
734 name: "libfortify2-new-tests-clang",
735 defaults: [
736 "bionic_new_fortify_tests_defaults",
737 "bionic_tests_defaults",
738 ],
739 cflags: [
740 "-D_FORTIFY_SOURCE=2",
741 "-DTEST_NAME=Fortify2_clang_new",
742 ],
743 shared: {
744 enabled: false,
745 },
746}
747
George Burgess IV86da38c2024-08-05 13:02:51 -0600748cc_defaults {
749 name: "bionic_fortify_c_tests_defaults",
750 defaults: [
751 "bionic_clang_fortify_tests_w_flags",
752 "bionic_tests_defaults",
753 ],
754 cflags: [
755 "-U_FORTIFY_SOURCE",
756 // -fbuiltin is required here to counteract -fno-builtin from
757 // `bionic_tests_defaults`. With `-fno-builtin`, Clang won't
758 // const-evaluate calls to `strlen`, which is tested for here.
759 "-fbuiltin",
760 ],
761 srcs: [
762 "clang_fortify_c_only_tests.c",
763 ],
764 tidy: false,
765 shared: {
766 enabled: false,
767 },
768}
769
770cc_test_library {
771 name: "libfortify1-c-tests-clang",
772 defaults: ["bionic_fortify_c_tests_defaults"],
773 cflags: ["-D_FORTIFY_SOURCE=1"],
774}
775
776cc_test_library {
777 name: "libfortify2-c-tests-clang",
778 defaults: ["bionic_fortify_c_tests_defaults"],
779 cflags: ["-D_FORTIFY_SOURCE=2"],
780}
781
Colin Cross2722ebb2016-07-11 16:20:06 -0700782// -----------------------------------------------------------------------------
783// Library of all tests (excluding the dynamic linker tests).
784// -----------------------------------------------------------------------------
785cc_test_library {
786 name: "libBionicTests",
787 defaults: ["bionic_tests_defaults"],
Colin Crossa48237b2022-02-03 10:28:12 -0800788 host_supported: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700789 whole_static_libs: [
790 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800791 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800792 "libBionicFramePointerTests",
George Burgess IV86da38c2024-08-05 13:02:51 -0600793 "libfortify1-c-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700794 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700795 "libfortify1-new-tests-clang",
George Burgess IV86da38c2024-08-05 13:02:51 -0600796 "libfortify2-c-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700797 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700798 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700799 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700800 shared: {
801 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700802 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700803}
804
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700805cc_test_library {
806 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800807 defaults: [
808 "bionic_tests_defaults",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800809 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700810 srcs: [
811 "atexit_test.cpp",
812 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700813 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700814 "dlfcn_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +0000815 "execinfo_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700816 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700817 "pthread_dlfcn_test.cpp",
818 ],
819 static_libs: [
820 "libbase",
Kalesh Singh4084b552024-03-13 13:35:49 -0700821 "libprocinfo",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700822 ],
823 include_dirs: [
824 "bionic/libc",
825 ],
826 shared: {
827 enabled: false,
828 },
829 target: {
830 android: {
831 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700832 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700833 "dlext_test.cpp",
834 "libdl_test.cpp",
835 ],
836 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800837 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400838 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700839 "libziparchive",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700840 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800841 },
Jiyong Park02586a22017-05-20 01:01:24 +0900842 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700843}
844
Colin Cross2722ebb2016-07-11 16:20:06 -0700845// -----------------------------------------------------------------------------
846// Library of bionic customized gtest main function, with normal gtest output format,
847// which is needed by bionic cts test.
848// -----------------------------------------------------------------------------
849cc_test_library {
850 name: "libBionicCtsGtestMain",
851 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700852 srcs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700853 "gtest_globals.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700854 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700855 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700856 shared: {
857 enabled: false,
858 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700859 whole_static_libs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700860 "libbase",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700861 "libgtest_isolated",
862 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700863}
864
Colin Cross2722ebb2016-07-11 16:20:06 -0700865cc_defaults {
Mitch Phillipsf5c9a652023-08-21 13:53:15 +0200866 name: "bionic_unit_tests_data",
Colin Crossbadcb382021-09-24 17:49:58 -0700867 data_bins: [
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700868 "cfi_test_helper",
869 "cfi_test_helper2",
Ryan Prichard43963922024-03-14 16:51:27 -0700870 "elftls_align_test_helper",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800871 "elftls_dlopen_ie_error_helper",
Ryan Prichard98731dc2024-02-29 22:56:36 -0800872 "elftls_dtv_resize_helper",
Ryan Prichard43963922024-03-14 16:51:27 -0700873 "elftls_skew_align_test_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700874 "exec_linker_helper",
875 "exec_linker_helper_lib",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800876 "heap_tagging_async_helper",
877 "heap_tagging_disabled_helper",
878 "heap_tagging_static_async_helper",
879 "heap_tagging_static_disabled_helper",
880 "heap_tagging_static_sync_helper",
881 "heap_tagging_sync_helper",
Florian Mayerc82d7fc2022-08-31 20:57:03 +0000882 "stack_tagging_helper",
883 "stack_tagging_static_helper",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800884 "ld_config_test_helper",
885 "ld_config_test_helper_lib1",
886 "ld_config_test_helper_lib2",
887 "ld_config_test_helper_lib3",
888 "ld_preload_test_helper",
889 "ld_preload_test_helper_lib1",
890 "ld_preload_test_helper_lib2",
Colin Crossbadcb382021-09-24 17:49:58 -0700891 "ns_hidden_child_helper",
892 "preinit_getauxval_test_helper",
893 "preinit_syscall_test_helper",
894 "thread_exit_cb_helper",
895 "tls_properties_helper",
896 ],
Colin Crossbadcb382021-09-24 17:49:58 -0700897 data_libs: [
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700898 "libatest_simple_zip",
899 "libcfi-test",
900 "libcfi-test-bad",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800901 "libdl_preempt_test_1",
902 "libdl_preempt_test_2",
903 "libdl_test_df_1_global",
904 "libdlext_test",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700905 "libdlext_test_different_soname",
906 "libdlext_test_fd",
907 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400908 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700909 "libdlext_test_zip",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700910 "libgnu-hash-table-library",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800911 "libns_hidden_child_app",
912 "libns_hidden_child_global",
913 "libns_hidden_child_internal",
914 "libns_hidden_child_public",
915 "libnstest_dlopened",
916 "libnstest_ns_a_public1",
917 "libnstest_ns_a_public1_internal",
918 "libnstest_ns_b_public2",
919 "libnstest_ns_b_public3",
920 "libnstest_private",
921 "libnstest_private_external",
922 "libnstest_public",
923 "libnstest_public_internal",
924 "libnstest_root",
925 "libnstest_root_not_isolated",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800926 "librelocations-ANDROID_REL",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800927 "librelocations-ANDROID_RELR",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800928 "librelocations-RELR",
929 "librelocations-fat",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800930 "libsegment_gap_inner",
931 "libsegment_gap_outer",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700932 "libsysv-hash-table-library",
933 "libtest_atexit",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800934 "libtest_check_order_dlsym",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700935 "libtest_check_order_dlsym_1_left",
936 "libtest_check_order_dlsym_2_right",
937 "libtest_check_order_dlsym_3_c",
938 "libtest_check_order_dlsym_a",
939 "libtest_check_order_dlsym_b",
940 "libtest_check_order_dlsym_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800941 "libtest_check_order_reloc_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700942 "libtest_check_order_reloc_root_1",
943 "libtest_check_order_reloc_root_2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800944 "libtest_check_order_reloc_siblings",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700945 "libtest_check_order_reloc_siblings_1",
946 "libtest_check_order_reloc_siblings_2",
947 "libtest_check_order_reloc_siblings_3",
948 "libtest_check_order_reloc_siblings_a",
949 "libtest_check_order_reloc_siblings_b",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800950 "libtest_check_order_reloc_siblings_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700951 "libtest_check_order_reloc_siblings_c_1",
952 "libtest_check_order_reloc_siblings_c_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700953 "libtest_check_order_reloc_siblings_d",
954 "libtest_check_order_reloc_siblings_e",
955 "libtest_check_order_reloc_siblings_f",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700956 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700957 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700958 "libtest_dlopen_from_ctor",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800959 "libtest_dlopen_from_ctor_main",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700960 "libtest_dlopen_weak_undefined_func",
961 "libtest_dlsym_df_1_global",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800962 "libtest_dlsym_from_this",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700963 "libtest_dlsym_from_this_child",
964 "libtest_dlsym_from_this_grandchild",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700965 "libtest_dlsym_weak_func",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800966 "libtest_dt_runpath_a",
967 "libtest_dt_runpath_b",
968 "libtest_dt_runpath_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700969 "libtest_dt_runpath_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800970 "libtest_dt_runpath_x",
971 "libtest_dt_runpath_y",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800972 "libtest_elftls_dynamic",
973 "libtest_elftls_dynamic_filler_1",
974 "libtest_elftls_dynamic_filler_2",
975 "libtest_elftls_dynamic_filler_3",
Ryan Prichard98731dc2024-02-29 22:56:36 -0800976 "libtest_elftls_dynamic_filler_4",
977 "libtest_elftls_dynamic_filler_5",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800978 "libtest_elftls_shared_var",
979 "libtest_elftls_shared_var_ie",
980 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700981 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700982 "libtest_ifunc",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800983 "libtest_ifunc_variable",
984 "libtest_ifunc_variable_impl",
985 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700986 "libtest_init_fini_order_child",
987 "libtest_init_fini_order_grand_child",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700988 "libtest_init_fini_order_root",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800989 "libtest_init_fini_order_root2",
990 "libtest_invalid-empty_shdr_table",
Ryan Prichard8ea6af52022-03-24 21:14:27 -0700991 "libtest_invalid-local-tls",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800992 "libtest_invalid-rw_load_segment",
993 "libtest_invalid-textrels",
994 "libtest_invalid-textrels2",
995 "libtest_invalid-unaligned_shdr_offset",
996 "libtest_invalid-zero_shdr_table_content",
997 "libtest_invalid-zero_shdr_table_offset",
998 "libtest_invalid-zero_shentsize",
999 "libtest_invalid-zero_shstrndx",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -07001000 "libtest_missing_symbol",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001001 "libtest_missing_symbol_child_private",
1002 "libtest_missing_symbol_child_public",
1003 "libtest_missing_symbol_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001004 "libtest_nodelete_1",
1005 "libtest_nodelete_2",
1006 "libtest_nodelete_dt_flags_1",
1007 "libtest_pthread_atfork",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001008 "libtest_relo_check_dt_needed_order",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001009 "libtest_relo_check_dt_needed_order_1",
1010 "libtest_relo_check_dt_needed_order_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001011 "libtest_simple",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001012 "libtest_thread_local_dtor",
1013 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001014 "libtest_two_parents_child",
1015 "libtest_two_parents_parent1",
1016 "libtest_two_parents_parent2",
1017 "libtest_versioned_lib",
1018 "libtest_versioned_libv1",
1019 "libtest_versioned_libv2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001020 "libtest_versioned_otherlib",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001021 "libtest_versioned_otherlib_empty",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001022 "libtest_versioned_uselibv1",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001023 "libtest_versioned_uselibv2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001024 "libtest_versioned_uselibv2_other",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001025 "libtest_versioned_uselibv3_other",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001026 "libtest_with_dependency",
1027 "libtest_with_dependency_loop",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001028 "libtest_with_dependency_loop_a",
1029 "libtest_with_dependency_loop_b",
1030 "libtest_with_dependency_loop_c",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001031 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001032 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001033}
1034
Mitch Phillipsf5c9a652023-08-21 13:53:15 +02001035// -----------------------------------------------------------------------------
1036// Tests for the device using bionic's .so. Run with:
1037// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
1038// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
1039// -----------------------------------------------------------------------------
1040cc_defaults {
1041 name: "bionic_unit_tests_defaults",
1042 host_supported: false,
1043 gtest: false,
1044
1045 defaults: [
1046 "bionic_tests_defaults",
1047 "bionic_unit_tests_data",
1048 ],
1049
1050 whole_static_libs: [
1051 "libBionicTests",
1052 "libBionicLoaderTests",
1053 "libBionicElfTlsLoaderTests",
1054 ],
1055
1056 static_libs: [
1057 "libtinyxml2",
1058 "liblog",
1059 "libbase",
1060 "libgtest_isolated",
1061 ],
1062
1063 srcs: [
1064 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
1065 "__cxa_thread_atexit_test.cpp",
1066 "gtest_globals.cpp",
1067 "gtest_main.cpp",
1068 "gwp_asan_test.cpp",
1069 "thread_local_test.cpp",
1070 ],
1071
1072 conlyflags: [
1073 "-fexceptions",
1074 "-fnon-call-exceptions",
1075 ],
1076
1077 ldflags: ["-Wl,--export-dynamic"],
1078
1079 include_dirs: ["bionic/libc"],
1080
1081 stl: "libc++_static",
1082
1083 target: {
1084 android: {
1085 shared_libs: [
1086 "ld-android",
1087 "libdl",
1088 "libdl_android",
1089 "libdl_preempt_test_1",
1090 "libdl_preempt_test_2",
1091 "libdl_test_df_1_global",
1092 "libtest_elftls_shared_var",
1093 "libtest_elftls_tprel",
1094 ],
1095 static_libs: [
1096 // The order of these libraries matters, do not shuffle them.
1097 "libmeminfo",
1098 "libziparchive",
1099 "libz",
1100 "libutils",
1101 ],
1102 ldflags: [
1103 "-Wl,--rpath,${ORIGIN}/bionic-loader-test-libs",
1104 "-Wl,--enable-new-dtags",
1105 ],
1106 },
1107 },
1108}
1109
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001110cc_test {
1111 name: "bionic-unit-tests",
1112 defaults: [
1113 "bionic_unit_tests_defaults",
1114 ],
Colin Cross0cc60af2021-09-30 14:04:39 -07001115 test_suites: ["device-tests"],
Colin Crossbadcb382021-09-24 17:49:58 -07001116 data: [
1117 ":libdlext_test_runpath_zip_zipaligned",
1118 ":libdlext_test_zip_zipaligned",
1119 ],
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001120}
1121
1122cc_test {
Florian Mayerc10d0642023-03-22 16:12:49 -07001123 name: "hwasan_test",
1124 enabled: false,
1125 // This does not use bionic_tests_defaults because it is not supported on
1126 // host.
1127 arch: {
1128 arm64: {
1129 enabled: true,
1130 },
1131 },
1132 sanitize: {
1133 hwaddress: true,
1134 },
1135 srcs: [
1136 "hwasan_test.cpp",
1137 ],
1138 shared_libs: [
1139 "libbase",
1140 ],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001141 data_libs: [
1142 "libtest_simple_hwasan",
1143 "libtest_simple_hwasan_nohwasan",
1144 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001145 header_libs: ["bionic_libc_platform_headers"],
1146 test_suites: ["device-tests"],
1147}
1148
1149cc_test {
Florian Mayere65e1932024-02-15 22:20:54 +00001150 name: "memtag_stack_dlopen_test",
1151 enabled: false,
1152 // This does not use bionic_tests_defaults because it is not supported on
1153 // host.
1154 arch: {
1155 arm64: {
1156 enabled: true,
1157 },
1158 },
1159 sanitize: {
1160 memtag_heap: true,
1161 memtag_stack: false,
1162 },
1163 srcs: [
1164 "memtag_stack_dlopen_test.cpp",
1165 ],
1166 shared_libs: [
1167 "libbase",
1168 ],
Kelly Hung9fb1a6c2024-05-24 13:54:42 +00001169 data_libs: [
1170 "libtest_simple_memtag_stack",
1171 "libtest_depends_on_simple_memtag_stack",
1172 ],
Florian Mayere65e1932024-02-15 22:20:54 +00001173 data_bins: [
1174 "testbinary_depends_on_simple_memtag_stack",
1175 "testbinary_depends_on_depends_on_simple_memtag_stack",
Kelly Hung9fb1a6c2024-05-24 13:54:42 +00001176 "testbinary_is_stack_mte_after_dlopen",
Florian Mayere65e1932024-02-15 22:20:54 +00001177 ],
1178 header_libs: ["bionic_libc_platform_headers"],
1179 test_suites: ["device-tests"],
1180}
1181
1182cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001183 name: "bionic-stress-tests",
1184 defaults: [
1185 "bionic_tests_defaults",
1186 ],
1187
1188 // For now, these tests run forever, so do not use the isolation framework.
1189 isolated: false,
Julien Desprez11874f82021-02-05 00:52:14 +00001190 // Running forever, do not consider unit test.
1191 test_options: {
1192 unit_test: false,
1193 },
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001194
1195 srcs: [
1196 "malloc_stress_test.cpp",
1197 ],
1198
1199 shared_libs: [
1200 "libbase",
1201 ],
1202
1203 target: {
1204 android: {
1205 static_libs: [
1206 "libmeminfo",
1207 "libprocinfo",
1208 ],
1209 },
1210 },
1211}
1212
Colin Cross2722ebb2016-07-11 16:20:06 -07001213// -----------------------------------------------------------------------------
1214// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +09001215// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
1216// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -07001217// -----------------------------------------------------------------------------
1218cc_test {
1219 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001220 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001221 defaults: ["bionic_tests_defaults"],
Colin Cross0cc60af2021-09-30 14:04:39 -07001222 test_suites: ["device-tests"],
Colin Cross2722ebb2016-07-11 16:20:06 -07001223 host_supported: false,
1224
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001225 srcs: [
1226 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001227 "gtest_globals.cpp",
1228 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -08001229
Ryan Prichard43963922024-03-14 16:51:27 -07001230 // Test internal parts of Bionic that aren't exposed via libc.so.
Ryan Prichard083d8502019-01-24 13:47:13 -08001231 "bionic_allocator_test.cpp",
Ryan Prichard43963922024-03-14 16:51:27 -07001232 "static_tls_layout_test.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -08001233 ],
1234 include_dirs: [
1235 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001236 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001237 whole_static_libs: [
1238 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001239 ],
1240
1241 static_libs: [
1242 "libm",
1243 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -07001244 "libdl",
1245 "libtinyxml2",
1246 "liblog",
1247 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -07001248 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001249 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001250 "libtest_elftls_shared_var",
1251 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001252 ],
1253
1254 static_executable: true,
1255 stl: "libc++_static",
Yi Kongb952a772021-10-21 17:31:35 +08001256 // Clang cannot build ifunc with LTO.
1257 // http://b/203737712
1258 lto: {
1259 never: true,
1260 },
Mitch Phillips9425b162022-02-04 17:13:27 -08001261 data_bins: [
Ryan Prichard43963922024-03-14 16:51:27 -07001262 "elftls_align_test_helper",
1263 "elftls_skew_align_test_helper",
Mitch Phillips9425b162022-02-04 17:13:27 -08001264 "heap_tagging_async_helper",
1265 "heap_tagging_disabled_helper",
1266 "heap_tagging_static_async_helper",
1267 "heap_tagging_static_disabled_helper",
1268 "heap_tagging_static_sync_helper",
1269 "heap_tagging_sync_helper",
Florian Mayerc82d7fc2022-08-31 20:57:03 +00001270 "stack_tagging_helper",
1271 "stack_tagging_static_helper",
Mitch Phillips9425b162022-02-04 17:13:27 -08001272 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001273}
1274
1275// -----------------------------------------------------------------------------
1276// Tests to run on the host and linked against glibc. Run with:
1277// cd bionic/tests; mm bionic-unit-tests-glibc-run
1278// -----------------------------------------------------------------------------
1279
1280cc_test_host {
1281 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001282 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001283 defaults: ["bionic_tests_defaults"],
1284
1285 srcs: [
1286 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -07001287 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001288 "dlfcn_test.cpp",
1289 "dl_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +00001290 "execinfo_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001291 "gtest_globals.cpp",
1292 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001293 "pthread_dlfcn_test.cpp",
1294 ],
1295
1296 shared_libs: [
1297 "libdl_preempt_test_1",
1298 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -07001299 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001300 "libtest_elftls_shared_var",
1301 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001302 ],
1303
1304 whole_static_libs: [
1305 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001306 "libBionicElfTlsTests",
1307 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001308 "libfortify1-tests-clang",
1309 "libfortify2-tests-clang",
1310 ],
1311
1312 static_libs: [
1313 "libbase",
1314 "liblog",
1315 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001316 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -07001317 ],
1318
1319 host_ldlibs: [
1320 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -07001321 "-lutil",
1322 ],
1323
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001324 include_dirs: [
1325 "bionic/libc",
1326 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001327
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -08001328 ldflags: [
1329 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
1330 "-Wl,--export-dynamic",
1331 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001332
1333 sanitize: {
1334 never: false,
1335 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001336
1337 target: {
1338 linux_bionic: {
1339 enabled: false,
1340 },
Colin Cross7da20342021-07-28 11:18:11 -07001341 musl: {
1342 exclude_static_libs: [
1343 // Musl doesn't have fortify
1344 "libfortify1-tests-clang",
1345 "libfortify2-tests-clang",
1346 ],
1347 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001348 },
Colin Cross2722ebb2016-07-11 16:20:06 -07001349}
1350
Kelly Hung9fb1a6c2024-05-24 13:54:42 +00001351cc_defaults {
1352 name: "bionic_compile_time_tests_defaults",
1353 enabled: false,
1354 target: {
1355 linux_x86: {
1356 enabled: true,
1357 },
1358 linux_x86_64: {
1359 enabled: true,
1360 },
1361 },
1362 tidy: false,
1363 clang_verify: true,
1364 cflags: [
1365 "-Wall",
1366 "-Wno-error",
1367 "-fno-color-diagnostics",
1368 "-ferror-limit=10000",
1369 "-DCOMPILATION_TESTS=1",
1370 "-Wformat-nonliteral",
1371 "-U_FORTIFY_SOURCE",
1372 ],
1373 srcs: ["clang_fortify_tests.cpp"],
1374}
1375
1376cc_library_static {
1377 name: "bionic-compile-time-tests1-clang++",
1378 defaults: [
1379 "bionic_compile_time_tests_defaults",
1380 ],
1381 cppflags: [
1382 "-D_FORTIFY_SOURCE=1",
1383 ],
1384}
1385
1386cc_library_static {
1387 name: "bionic-compile-time-tests2-clang++",
1388 defaults: [
1389 "bionic_compile_time_tests_defaults",
1390 ],
1391 cppflags: [
1392 "-D_FORTIFY_SOURCE=2",
1393 ],
1394}