blob: 281e29d6aab127306b1379836297c4584c68f322 [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 {
18 default_applicable_licenses: ["bionic_tests_license"],
19}
20
21license {
22 name: "bionic_tests_license",
23 visibility: [":__subpackages__"],
24 license_kinds: [
25 "SPDX-license-identifier-Apache-2.0",
26 "SPDX-license-identifier-BSD",
27 ],
28 license_text: [
29 "NOTICE",
30 ],
31}
32
Colin Cross2722ebb2016-07-11 16:20:06 -070033cc_defaults {
34 name: "bionic_tests_defaults",
35 host_supported: true,
36 target: {
37 darwin: {
38 enabled: false,
39 },
Martin Stjernholma2763432020-04-23 16:47:19 +010040 android: {
41 header_libs: ["bionic_libc_platform_headers"],
42 },
43 linux_bionic: {
44 header_libs: ["bionic_libc_platform_headers"],
45 },
Colin Cross2722ebb2016-07-11 16:20:06 -070046 },
47 cflags: [
48 "-fstack-protector-all",
49 "-g",
50 "-Wall",
51 "-Wextra",
52 "-Wunused",
53 "-Werror",
54 "-fno-builtin",
55
56 // We want to test deprecated API too.
57 "-Wno-deprecated-declarations",
58
Peter Collingbourne4edf74a2020-10-02 13:47:03 -070059 // Needed to test pthread_internal_t layout.
60 "-Wno-invalid-offsetof",
61
Colin Cross2722ebb2016-07-11 16:20:06 -070062 // For glibc.
63 "-D__STDC_LIMIT_MACROS",
64 ],
Mitch Phillipse6997d52020-11-30 15:04:14 -080065 header_libs: [
66 "libcutils_headers",
67 "gwp_asan_headers"
68 ],
Elliott Hughes9a7155d2023-02-10 02:00:03 +000069 stl: "libc++",
70
71 // Ensure that the tests exercise shadow call stack support.
72 // We don't use `scs: true` here because that would give us a second
73 // variant of this library where we actually just want to say "this
74 // library should always be built this way".
Peter Collingbourne7b70e272018-11-12 20:09:14 -080075 arch: {
76 arm64: {
Elliott Hughes9a7155d2023-02-10 02:00:03 +000077 cflags: ["-fsanitize=shadow-call-stack"],
78 },
79 riscv64: {
80 cflags: ["-fsanitize=shadow-call-stack"],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080081 },
82 },
Colin Cross2722ebb2016-07-11 16:20:06 -070083 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080084 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070085 },
Ryan Prichard3c5dff42020-03-31 17:34:03 -070086
87 // Use the bootstrap version of bionic because some tests call private APIs
88 // that aren't exposed by the APEX bionic stubs.
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090089 bootstrap: true,
Colin Cross2722ebb2016-07-11 16:20:06 -070090}
91
92// -----------------------------------------------------------------------------
Chris Parsonscab794c2020-06-15 18:22:10 -040093// Prebuilt shared libraries for use in tests.
94// -----------------------------------------------------------------------------
95
96cc_prebuilt_test_library_shared {
97 name: "libtest_invalid-rw_load_segment",
98 strip: {
99 none: true,
100 },
101 check_elf_files: false,
102 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
103 arch: {
104 arm: {
105 srcs: ["prebuilt-elf-files/arm/libtest_invalid-rw_load_segment.so"],
106 },
107 arm64: {
108 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so"],
109 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000110 riscv64: {
111 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-rw_load_segment.so"],
112 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400113 x86: {
114 srcs: ["prebuilt-elf-files/x86/libtest_invalid-rw_load_segment.so"],
115 },
116 x86_64: {
117 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so"],
118 },
119 },
120}
121
122cc_prebuilt_test_library_shared {
123 name: "libtest_invalid-unaligned_shdr_offset",
124 strip: {
125 none: true,
126 },
127 check_elf_files: false,
128 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
129 arch: {
130 arm: {
131 srcs: ["prebuilt-elf-files/arm/libtest_invalid-unaligned_shdr_offset.so"],
132 },
133 arm64: {
134 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-unaligned_shdr_offset.so"],
135 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000136 riscv64: {
137 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-unaligned_shdr_offset.so"],
138 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400139 x86: {
140 srcs: ["prebuilt-elf-files/x86/libtest_invalid-unaligned_shdr_offset.so"],
141 },
142 x86_64: {
143 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-unaligned_shdr_offset.so"],
144 },
145 },
146}
147
148cc_prebuilt_test_library_shared {
149 name: "libtest_invalid-zero_shentsize",
150 strip: {
151 none: true,
152 },
153 check_elf_files: false,
154 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
155 arch: {
156 arm: {
157 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shentsize.so"],
158 },
159 arm64: {
160 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shentsize.so"],
161 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000162 riscv64: {
163 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shentsize.so"],
164 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400165 x86: {
166 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shentsize.so"],
167 },
168 x86_64: {
169 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shentsize.so"],
170 },
171 },
172}
173
174cc_prebuilt_test_library_shared {
175 name: "libtest_invalid-zero_shstrndx",
176 strip: {
177 none: true,
178 },
179 check_elf_files: false,
180 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
181 arch: {
182 arm: {
183 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shstrndx.so"],
184 },
185 arm64: {
186 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shstrndx.so"],
187 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000188 riscv64: {
189 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shstrndx.so"],
190 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400191 x86: {
192 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shstrndx.so"],
193 },
194 x86_64: {
195 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shstrndx.so"],
196 },
197 },
198}
199
200cc_prebuilt_test_library_shared {
201 name: "libtest_invalid-empty_shdr_table",
202 strip: {
203 none: true,
204 },
205 check_elf_files: false,
206 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
207 arch: {
208 arm: {
209 srcs: ["prebuilt-elf-files/arm/libtest_invalid-empty_shdr_table.so"],
210 },
211 arm64: {
212 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-empty_shdr_table.so"],
213 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000214 riscv64: {
215 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-empty_shdr_table.so"],
216 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400217 x86: {
218 srcs: ["prebuilt-elf-files/x86/libtest_invalid-empty_shdr_table.so"],
219 },
220 x86_64: {
221 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-empty_shdr_table.so"],
222 },
223 },
224}
225
226cc_prebuilt_test_library_shared {
227 name: "libtest_invalid-zero_shdr_table_offset",
228 strip: {
229 none: true,
230 },
231 check_elf_files: false,
232 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
233 arch: {
234 arm: {
235 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_offset.so"],
236 },
237 arm64: {
238 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_offset.so"],
239 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000240 riscv64: {
241 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shdr_table_offset.so"],
242 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400243 x86: {
244 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_offset.so"],
245 },
246 x86_64: {
247 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_offset.so"],
248 },
249 },
250}
251
252cc_prebuilt_test_library_shared {
253 name: "libtest_invalid-zero_shdr_table_content",
254 strip: {
255 none: true,
256 },
257 check_elf_files: false,
258 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
259 arch: {
260 arm: {
261 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_content.so"],
262 },
263 arm64: {
264 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_content.so"],
265 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000266 riscv64: {
267 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shdr_table_content.so"],
268 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400269 x86: {
270 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_content.so"],
271 },
272 x86_64: {
273 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_content.so"],
274 },
275 },
276}
277
278cc_prebuilt_test_library_shared {
279 name: "libtest_invalid-textrels",
280 strip: {
281 none: true,
282 },
283 check_elf_files: false,
284 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
285 arch: {
286 arm: {
287 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels.so"],
288 },
289 arm64: {
290 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels.so"],
291 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000292 riscv64: {
293 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-textrels.so"],
294 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400295 x86: {
296 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels.so"],
297 },
298 x86_64: {
299 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels.so"],
300 },
301 },
302}
303
304cc_prebuilt_test_library_shared {
305 name: "libtest_invalid-textrels2",
306 strip: {
307 none: true,
308 },
309 check_elf_files: false,
310 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
311 arch: {
312 arm: {
313 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels2.so"],
314 },
315 arm64: {
316 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels2.so"],
317 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000318 riscv64: {
319 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-textrels2.so"],
320 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400321 x86: {
322 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels2.so"],
323 },
324 x86_64: {
325 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels2.so"],
326 },
327 },
328}
329
Ryan Prichard8ea6af52022-03-24 21:14:27 -0700330cc_prebuilt_test_library_shared {
331 name: "libtest_invalid-local-tls",
332 strip: {
333 none: true,
334 },
335 check_elf_files: false,
336 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
337 arch: {
338 arm: {
339 srcs: ["prebuilt-elf-files/arm/libtest_invalid-local-tls.so"],
340 },
341 arm64: {
342 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-local-tls.so"],
343 },
344 x86: {
345 srcs: ["prebuilt-elf-files/x86/libtest_invalid-local-tls.so"],
346 },
347 x86_64: {
348 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-local-tls.so"],
349 },
350 },
351}
352
Chris Parsonscab794c2020-06-15 18:22:10 -0400353// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -0700354// All standard tests.
355// -----------------------------------------------------------------------------
356
George Burgess IVde45dcb2018-03-16 14:15:01 -0700357// Test diagnostics emitted by clang. The library that results is useless; we
358// just want to run '-Xclang -verify', which will fail if the diagnostics don't
359// match up with what the source file says they should be.
360cc_test_library {
361 name: "clang_diagnostic_tests",
362 cflags: [
Alixd2569252022-04-21 02:54:27 +0000363 "-Xclang",
364 "-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",
371 defaults: ["bionic_tests_defaults"],
Chih-Hung Hsieh6fae6142022-12-15 19:30:55 -0800372 tidy_disabled_srcs: [
373 "malloc_test.cpp", // timed out with clang-tidy, and too many warnings
374 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700375 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -0800376 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -0800377 "__cxa_atexit_test.cpp",
Elliott Hughes413817f2020-10-26 15:05:35 -0700378 "__cxa_demangle_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300379 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -0700380 "android_get_device_api_level.cpp",
Christopher Ferrisbbf9cd82022-04-11 16:01:37 -0700381 "android_set_abort_message_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700382 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700383 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -0700384 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700385 "buffer_tests.cpp",
386 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300387 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700388 "complex_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700389 "complex_force_long_double_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700390 "ctype_test.cpp",
391 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -0700392 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800393 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700394 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700395 "error_test.cpp",
396 "eventfd_test.cpp",
397 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700398 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800399 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700400 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800401 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700402 "float_test.cpp",
Elliott Hughes6675ad32020-11-20 16:51:21 -0800403 "fnmatch_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700404 "ftw_test.cpp",
405 "getauxval_test.cpp",
406 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700407 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700408 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800409 "grp_pwd_file_test.cpp",
Peter Collingbourned3060012020-04-01 19:54:48 -0700410 "heap_tagging_level_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700411 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700412 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800413 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700414 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700415 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800416 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700417 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700418 "libgen_basename_test.cpp",
419 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700420 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700421 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700422 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700423 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700424 "malloc_test.cpp",
425 "math_test.cpp",
Elliott Hughes50cda382017-09-14 15:30:08 -0700426 "math_force_long_double_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100427 "membarrier_test.cpp",
Florian Mayerc82d7fc2022-08-31 20:57:03 +0000428 "memtag_stack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700429 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800430 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700431 "netdb_test.cpp",
432 "net_if_test.cpp",
433 "netinet_ether_test.cpp",
434 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700435 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700436 "netinet_udp_test.cpp",
437 "nl_types_test.cpp",
Josh Gao3de19152021-02-22 18:09:48 -0800438 "pidfd_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700439 "poll_test.cpp",
Matthew Maurerde306352020-10-23 09:55:33 -0700440 "prio_ctor_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700441 "pthread_test.cpp",
442 "pty_test.cpp",
443 "regex_test.cpp",
444 "resolv_test.cpp",
445 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800446 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700447 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700448 "search_test.cpp",
449 "semaphore_test.cpp",
450 "setjmp_test.cpp",
451 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700452 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700453 "stack_protector_test.cpp",
454 "stack_protector_test_helper.cpp",
455 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700456 "stdalign_test.cpp",
457 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700458 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700459 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700460 "stdint_test.cpp",
461 "stdio_nofortify_test.cpp",
462 "stdio_test.cpp",
463 "stdio_ext_test.cpp",
464 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700465 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700466 "string_nofortify_test.cpp",
467 "string_test.cpp",
468 "string_posix_strerror_r_test.cpp",
Colin Cross4408b8a2021-07-29 22:45:34 -0700469 "string_posix_strerror_r_wrapper.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700470 "strings_nofortify_test.cpp",
471 "strings_test.cpp",
Peter Collingbourne4edf74a2020-10-02 13:47:03 -0700472 "struct_layout_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700473 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800474 "sys_auxv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700475 "sys_epoll_test.cpp",
476 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700477 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700478 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700479 "sys_personality_test.cpp",
480 "sys_prctl_test.cpp",
481 "sys_procfs_test.cpp",
482 "sys_ptrace_test.cpp",
483 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700484 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700485 "sys_resource_test.cpp",
486 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700487 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700488 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700489 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800490 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700491 "sys_socket_test.cpp",
492 "sys_stat_test.cpp",
493 "sys_statvfs_test.cpp",
494 "sys_syscall_test.cpp",
495 "sys_sysinfo_test.cpp",
496 "sys_sysmacros_test.cpp",
497 "sys_time_test.cpp",
498 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700499 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700500 "sys_types_test.cpp",
501 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700502 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700503 "sys_vfs_test.cpp",
Elliott Hughes7cebf832020-08-12 14:25:41 -0700504 "sys_wait_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700505 "sys_xattr_test.cpp",
Elliott Hughes213d9432023-03-01 22:56:13 +0000506 "syslog_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700507 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000508 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800509 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700510 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700511 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700512 "time_test.cpp",
513 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700514 "unistd_nofortify_test.cpp",
515 "unistd_test.cpp",
Mitch Phillips9634c362022-06-23 11:07:00 -0700516 "utils.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700517 "utmp_test.cpp",
Elliott Hughesdbf5b2e2023-04-03 16:30:39 -0700518 "utmpx_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700519 "wchar_test.cpp",
520 "wctype_test.cpp",
521 ],
522
523 include_dirs: [
524 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700525 ],
526
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700527 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700528 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800529 whole_static_libs: [
530 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700531 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800532 "libsystemproperties",
533 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700534 },
Colin Cross7da20342021-07-28 11:18:11 -0700535 musl: {
536 exclude_srcs: [
537 // musl doesn't have error.h
538 "error_test.cpp",
539
540 // musl doesn't define noreturn for C++
541 "stdnoreturn_test.cpp",
542
543 // unsupported relocation type 37
544 "ifunc_test.cpp",
Colin Cross118202b2023-04-14 09:33:11 -0700545
546 // musl #defines utmp to utmpx, causing a collision with
547 // utmpx_test.cpp
548 "utmp_test.cpp",
Colin Cross7da20342021-07-28 11:18:11 -0700549 ],
550 },
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700551 },
552
Dan Willemsen41567702016-08-31 16:35:01 -0700553 static_libs: [
554 "libtinyxml2",
555 "liblog",
556 "libbase",
557 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700558 shared: {
559 enabled: false,
560 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000561
562 generated_headers: ["generated_android_ids"],
Pirama Arumuga Nainarfef519b2022-02-22 15:01:27 -0800563
564 // Bug: http://b/218788252 IR verifier too strict for ifunc resolver that
565 // accept parameters.
566 lto: {
567 never: true,
568 },
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 ],
580 shared: {
581 enabled: false,
582 },
583 cflags: [
584 "-fno-emulated-tls",
585 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700586 // With fuzzer builds, compiler instrumentation generates a reference to the
587 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
588 // library as an emutls symbol. The -fno-emulated-tls flag above configures
589 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
590 // symbol instead, which isn't defined. Disable the fuzzer for this test
591 // until the platform is switched to ELF TLS.
592 sanitize: {
593 fuzzer: false,
594 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800595}
596
597cc_test_library {
598 name: "libBionicElfTlsLoaderTests",
599 defaults: ["bionic_tests_defaults"],
600 srcs: [
601 "elftls_dl_test.cpp",
602 ],
603 include_dirs: [
604 "bionic/libc",
605 ],
606 static_libs: [
607 "liblog",
608 "libbase",
609 ],
610 shared: {
611 enabled: false,
612 },
613 cflags: [
614 "-fno-emulated-tls",
615 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700616 // With fuzzer builds, compiler instrumentation generates a reference to the
617 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
618 // library as an emutls symbol. The -fno-emulated-tls flag above configures
619 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
620 // symbol instead, which isn't defined. Disable the fuzzer for this test
621 // until the platform is switched to ELF TLS.
622 sanitize: {
623 fuzzer: false,
624 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800625}
626
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800627cc_test_library {
628 name: "libBionicFramePointerTests",
629 defaults: ["bionic_tests_defaults"],
630 srcs: [
631 "android_unsafe_frame_pointer_chase_test.cpp",
632 ],
633 include_dirs: [
634 "bionic/libc",
635 ],
636 cflags: [
637 "-fno-omit-frame-pointer",
638 ],
639}
640
Colin Cross2722ebb2016-07-11 16:20:06 -0700641// -----------------------------------------------------------------------------
642// Fortify tests.
643// -----------------------------------------------------------------------------
644
645cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700646 name: "bionic_clang_fortify_tests_w_flags",
647 cflags: [
648 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700649 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700650 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700651 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700652 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700653 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700654 "-Wno-strncat-size",
655 ],
Elliott Hughes141b9172021-04-09 17:13:09 -0700656 static_libs: [
657 "libbase",
658 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700659}
660
661cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700662 name: "bionic_fortify_tests_defaults",
663 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700664 "-U_FORTIFY_SOURCE",
665 ],
666 srcs: ["fortify_test_main.cpp"],
Elliott Hughes141b9172021-04-09 17:13:09 -0700667 static_libs: [
668 "libbase",
669 ],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800670 tidy: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700671 target: {
Colin Crossa48237b2022-02-03 10:28:12 -0800672 musl: {
673 // Musl doesn't have fortify
674 enabled: false,
675 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700676 },
677}
678
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700679// Ensures that FORTIFY checks aren't run when ASAN is on.
680cc_test {
681 name: "bionic-fortify-runtime-asan-test",
George Burgess IV9a274102019-06-04 15:39:52 -0700682 defaults: [
683 "bionic_clang_fortify_tests_w_flags",
684 ],
George Burgess IVd9551db2017-08-17 18:51:02 -0700685 cflags: [
686 "-Werror",
687 "-D_FORTIFY_SOURCE=2",
George Burgess IVd9551db2017-08-17 18:51:02 -0700688 ],
George Burgess IV8a0cdb12019-10-21 13:27:57 -0700689 sanitize: {
690 address: true,
691 },
692 srcs: ["clang_fortify_asan.cpp"],
George Burgess IVd9551db2017-08-17 18:51:02 -0700693}
694
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700695// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
696// it can confuse these tools pretty easily. If this builds successfully, then
697// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
698// enabled. The library that results from building this is meant to be unused.
699cc_test_library {
700 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700701 defaults: [
702 "bionic_clang_fortify_tests_w_flags",
703 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700704 cflags: [
705 "-Werror",
706 "-D_FORTIFY_SOURCE=2",
707 "-D__clang_analyzer__",
708 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700709 srcs: ["clang_fortify_tests.cpp"],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800710 tidy: false,
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700711}
712
Colin Cross2722ebb2016-07-11 16:20:06 -0700713cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700714 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800715 defaults: [
716 "bionic_fortify_tests_defaults",
717 "bionic_tests_defaults",
718 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700719 cflags: [
720 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800721 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700722 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700723 shared: {
724 enabled: false,
725 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700726}
727
728cc_test_library {
729 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800730 defaults: [
731 "bionic_fortify_tests_defaults",
732 "bionic_tests_defaults",
733 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700734 cflags: [
735 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800736 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700737 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700738 shared: {
739 enabled: false,
740 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700741}
742
George Burgess IV9a274102019-06-04 15:39:52 -0700743cc_defaults {
744 name: "bionic_new_fortify_tests_defaults",
745 defaults: [
746 "bionic_clang_fortify_tests_w_flags",
747 ],
748 cflags: [
749 "-U_FORTIFY_SOURCE",
750 ],
751 srcs: ["clang_fortify_tests.cpp"],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800752 tidy: false,
George Burgess IV9a274102019-06-04 15:39:52 -0700753 target: {
754 host: {
Alixd2569252022-04-21 02:54:27 +0000755 cflags: ["-D__clang__"],
George Burgess IV9a274102019-06-04 15:39:52 -0700756 },
757 },
758}
759
760cc_test_library {
761 name: "libfortify1-new-tests-clang",
762 defaults: [
763 "bionic_new_fortify_tests_defaults",
764 "bionic_tests_defaults",
765 ],
766 cflags: [
767 "-D_FORTIFY_SOURCE=1",
768 "-DTEST_NAME=Fortify1_clang_new",
769 ],
770 shared: {
771 enabled: false,
772 },
773}
774
775cc_test_library {
776 name: "libfortify2-new-tests-clang",
777 defaults: [
778 "bionic_new_fortify_tests_defaults",
779 "bionic_tests_defaults",
780 ],
781 cflags: [
782 "-D_FORTIFY_SOURCE=2",
783 "-DTEST_NAME=Fortify2_clang_new",
784 ],
785 shared: {
786 enabled: false,
787 },
788}
789
Colin Cross2722ebb2016-07-11 16:20:06 -0700790// -----------------------------------------------------------------------------
791// Library of all tests (excluding the dynamic linker tests).
792// -----------------------------------------------------------------------------
793cc_test_library {
794 name: "libBionicTests",
795 defaults: ["bionic_tests_defaults"],
Colin Crossa48237b2022-02-03 10:28:12 -0800796 host_supported: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700797 whole_static_libs: [
798 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800799 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800800 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700801 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700802 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700803 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700804 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700805 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700806 shared: {
807 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700808 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700809}
810
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700811cc_test_library {
812 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800813 defaults: [
814 "bionic_tests_defaults",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800815 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700816 srcs: [
817 "atexit_test.cpp",
818 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700819 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700820 "dlfcn_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +0000821 "execinfo_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700822 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700823 "pthread_dlfcn_test.cpp",
824 ],
825 static_libs: [
826 "libbase",
827 ],
828 include_dirs: [
829 "bionic/libc",
830 ],
831 shared: {
832 enabled: false,
833 },
834 target: {
835 android: {
836 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700837 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700838 "dlext_test.cpp",
839 "libdl_test.cpp",
840 ],
841 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800842 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400843 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700844 "libziparchive",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700845 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800846 },
Jiyong Park02586a22017-05-20 01:01:24 +0900847 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700848}
849
Colin Cross2722ebb2016-07-11 16:20:06 -0700850// -----------------------------------------------------------------------------
851// Library of bionic customized gtest main function, with normal gtest output format,
852// which is needed by bionic cts test.
853// -----------------------------------------------------------------------------
854cc_test_library {
855 name: "libBionicCtsGtestMain",
856 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700857 srcs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700858 "gtest_globals.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700859 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700860 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700861 shared: {
862 enabled: false,
863 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700864 whole_static_libs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700865 "libbase",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700866 "libgtest_isolated",
867 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700868}
869
870// -----------------------------------------------------------------------------
871// Tests for the device using bionic's .so. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +0900872// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
873// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Colin Cross2722ebb2016-07-11 16:20:06 -0700874// -----------------------------------------------------------------------------
875cc_defaults {
876 name: "bionic_unit_tests_defaults",
877 host_supported: false,
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800878 gtest: false,
879
880 defaults: [
881 "bionic_tests_defaults",
882 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700883
884 whole_static_libs: [
885 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700886 "libBionicLoaderTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800887 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700888 ],
889
890 static_libs: [
891 "libtinyxml2",
892 "liblog",
893 "libbase",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800894 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -0700895 ],
896
897 srcs: [
898 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700899 "__cxa_thread_atexit_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700900 "gtest_globals.cpp",
Christopher Ferrisfc26d712019-02-27 18:07:55 -0800901 "gtest_main.cpp",
Mitch Phillips9634c362022-06-23 11:07:00 -0700902 "gwp_asan_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700903 "thread_local_test.cpp",
904 ],
905
906 conlyflags: [
907 "-fexceptions",
908 "-fnon-call-exceptions",
909 ],
910
911 ldflags: ["-Wl,--export-dynamic"],
912
913 include_dirs: ["bionic/libc"],
914
Yabin Cui1f553ea2017-01-13 12:31:59 -0800915 stl: "libc++_static",
916
Colin Cross2722ebb2016-07-11 16:20:06 -0700917 target: {
918 android: {
919 shared_libs: [
dimitry321476a2018-01-29 15:32:37 +0100920 "ld-android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700921 "libdl",
dimitry2d6be9a2019-03-19 13:01:42 +0100922 "libdl_android",
Colin Cross2722ebb2016-07-11 16:20:06 -0700923 "libdl_preempt_test_1",
924 "libdl_preempt_test_2",
925 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800926 "libtest_elftls_shared_var",
927 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -0700928 ],
929 static_libs: [
930 // The order of these libraries matters, do not shuffle them.
Sandeep Patile3f39a02019-01-21 14:22:05 -0800931 "libmeminfo",
Colin Cross2722ebb2016-07-11 16:20:06 -0700932 "libziparchive",
933 "libz",
934 "libutils",
935 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700936 ldflags: [
Colin Crossbadcb382021-09-24 17:49:58 -0700937 "-Wl,--rpath,${ORIGIN}/bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700938 "-Wl,--enable-new-dtags",
939 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700940 },
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800941 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700942
Colin Crossbadcb382021-09-24 17:49:58 -0700943 data_bins: [
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700944 "cfi_test_helper",
945 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800946 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700947 "exec_linker_helper",
948 "exec_linker_helper_lib",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800949 "heap_tagging_async_helper",
950 "heap_tagging_disabled_helper",
951 "heap_tagging_static_async_helper",
952 "heap_tagging_static_disabled_helper",
953 "heap_tagging_static_sync_helper",
954 "heap_tagging_sync_helper",
Florian Mayerc82d7fc2022-08-31 20:57:03 +0000955 "stack_tagging_helper",
956 "stack_tagging_static_helper",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800957 "ld_config_test_helper",
958 "ld_config_test_helper_lib1",
959 "ld_config_test_helper_lib2",
960 "ld_config_test_helper_lib3",
961 "ld_preload_test_helper",
962 "ld_preload_test_helper_lib1",
963 "ld_preload_test_helper_lib2",
Colin Crossbadcb382021-09-24 17:49:58 -0700964 "ns_hidden_child_helper",
965 "preinit_getauxval_test_helper",
966 "preinit_syscall_test_helper",
967 "thread_exit_cb_helper",
968 "tls_properties_helper",
969 ],
970
971 data_libs: [
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700972 "libatest_simple_zip",
973 "libcfi-test",
974 "libcfi-test-bad",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800975 "libdl_preempt_test_1",
976 "libdl_preempt_test_2",
977 "libdl_test_df_1_global",
978 "libdlext_test",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700979 "libdlext_test_different_soname",
980 "libdlext_test_fd",
981 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400982 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700983 "libdlext_test_zip",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700984 "libgnu-hash-table-library",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800985 "libns_hidden_child_app",
986 "libns_hidden_child_global",
987 "libns_hidden_child_internal",
988 "libns_hidden_child_public",
989 "libnstest_dlopened",
990 "libnstest_ns_a_public1",
991 "libnstest_ns_a_public1_internal",
992 "libnstest_ns_b_public2",
993 "libnstest_ns_b_public3",
994 "libnstest_private",
995 "libnstest_private_external",
996 "libnstest_public",
997 "libnstest_public_internal",
998 "libnstest_root",
999 "libnstest_root_not_isolated",
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001000 "librelocations-ANDROID_REL",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001001 "librelocations-ANDROID_RELR",
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001002 "librelocations-RELR",
1003 "librelocations-fat",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001004 "libsegment_gap_inner",
1005 "libsegment_gap_outer",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001006 "libsysv-hash-table-library",
1007 "libtest_atexit",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001008 "libtest_check_order_dlsym",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001009 "libtest_check_order_dlsym_1_left",
1010 "libtest_check_order_dlsym_2_right",
1011 "libtest_check_order_dlsym_3_c",
1012 "libtest_check_order_dlsym_a",
1013 "libtest_check_order_dlsym_b",
1014 "libtest_check_order_dlsym_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001015 "libtest_check_order_reloc_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001016 "libtest_check_order_reloc_root_1",
1017 "libtest_check_order_reloc_root_2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001018 "libtest_check_order_reloc_siblings",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001019 "libtest_check_order_reloc_siblings_1",
1020 "libtest_check_order_reloc_siblings_2",
1021 "libtest_check_order_reloc_siblings_3",
1022 "libtest_check_order_reloc_siblings_a",
1023 "libtest_check_order_reloc_siblings_b",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001024 "libtest_check_order_reloc_siblings_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001025 "libtest_check_order_reloc_siblings_c_1",
1026 "libtest_check_order_reloc_siblings_c_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001027 "libtest_check_order_reloc_siblings_d",
1028 "libtest_check_order_reloc_siblings_e",
1029 "libtest_check_order_reloc_siblings_f",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001030 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -07001031 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001032 "libtest_dlopen_from_ctor",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001033 "libtest_dlopen_from_ctor_main",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001034 "libtest_dlopen_weak_undefined_func",
1035 "libtest_dlsym_df_1_global",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001036 "libtest_dlsym_from_this",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001037 "libtest_dlsym_from_this_child",
1038 "libtest_dlsym_from_this_grandchild",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001039 "libtest_dlsym_weak_func",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001040 "libtest_dt_runpath_a",
1041 "libtest_dt_runpath_b",
1042 "libtest_dt_runpath_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001043 "libtest_dt_runpath_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001044 "libtest_dt_runpath_x",
1045 "libtest_dt_runpath_y",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -08001046 "libtest_elftls_dynamic",
1047 "libtest_elftls_dynamic_filler_1",
1048 "libtest_elftls_dynamic_filler_2",
1049 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001050 "libtest_elftls_shared_var",
1051 "libtest_elftls_shared_var_ie",
1052 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001053 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -07001054 "libtest_ifunc",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001055 "libtest_ifunc_variable",
1056 "libtest_ifunc_variable_impl",
1057 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001058 "libtest_init_fini_order_child",
1059 "libtest_init_fini_order_grand_child",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001060 "libtest_init_fini_order_root",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001061 "libtest_init_fini_order_root2",
1062 "libtest_invalid-empty_shdr_table",
Ryan Prichard8ea6af52022-03-24 21:14:27 -07001063 "libtest_invalid-local-tls",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001064 "libtest_invalid-rw_load_segment",
1065 "libtest_invalid-textrels",
1066 "libtest_invalid-textrels2",
1067 "libtest_invalid-unaligned_shdr_offset",
1068 "libtest_invalid-zero_shdr_table_content",
1069 "libtest_invalid-zero_shdr_table_offset",
1070 "libtest_invalid-zero_shentsize",
1071 "libtest_invalid-zero_shstrndx",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -07001072 "libtest_missing_symbol",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001073 "libtest_missing_symbol_child_private",
1074 "libtest_missing_symbol_child_public",
1075 "libtest_missing_symbol_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001076 "libtest_nodelete_1",
1077 "libtest_nodelete_2",
1078 "libtest_nodelete_dt_flags_1",
1079 "libtest_pthread_atfork",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001080 "libtest_relo_check_dt_needed_order",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001081 "libtest_relo_check_dt_needed_order_1",
1082 "libtest_relo_check_dt_needed_order_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001083 "libtest_simple",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001084 "libtest_thread_local_dtor",
1085 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001086 "libtest_two_parents_child",
1087 "libtest_two_parents_parent1",
1088 "libtest_two_parents_parent2",
1089 "libtest_versioned_lib",
1090 "libtest_versioned_libv1",
1091 "libtest_versioned_libv2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001092 "libtest_versioned_otherlib",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001093 "libtest_versioned_otherlib_empty",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001094 "libtest_versioned_uselibv1",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001095 "libtest_versioned_uselibv2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001096 "libtest_versioned_uselibv2_other",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001097 "libtest_versioned_uselibv3_other",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001098 "libtest_with_dependency",
1099 "libtest_with_dependency_loop",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001100 "libtest_with_dependency_loop_a",
1101 "libtest_with_dependency_loop_b",
1102 "libtest_with_dependency_loop_c",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001103 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001104 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001105}
1106
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001107cc_test {
1108 name: "bionic-unit-tests",
1109 defaults: [
1110 "bionic_unit_tests_defaults",
1111 ],
Colin Cross0cc60af2021-09-30 14:04:39 -07001112 test_suites: ["device-tests"],
Colin Crossbadcb382021-09-24 17:49:58 -07001113 data: [
1114 ":libdlext_test_runpath_zip_zipaligned",
1115 ":libdlext_test_zip_zipaligned",
1116 ],
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001117}
1118
1119cc_test {
Florian Mayerc10d0642023-03-22 16:12:49 -07001120 name: "hwasan_test",
1121 enabled: false,
1122 // This does not use bionic_tests_defaults because it is not supported on
1123 // host.
1124 arch: {
1125 arm64: {
1126 enabled: true,
1127 },
1128 },
1129 sanitize: {
1130 hwaddress: true,
1131 },
1132 srcs: [
1133 "hwasan_test.cpp",
1134 ],
1135 shared_libs: [
1136 "libbase",
1137 ],
1138 data_libs: ["libtest_simple_hwasan", "libtest_simple_hwasan_nohwasan"],
1139 header_libs: ["bionic_libc_platform_headers"],
1140 test_suites: ["device-tests"],
1141}
1142
1143cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001144 name: "bionic-stress-tests",
1145 defaults: [
1146 "bionic_tests_defaults",
1147 ],
1148
1149 // For now, these tests run forever, so do not use the isolation framework.
1150 isolated: false,
Julien Desprez11874f82021-02-05 00:52:14 +00001151 // Running forever, do not consider unit test.
1152 test_options: {
1153 unit_test: false,
1154 },
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001155
1156 srcs: [
1157 "malloc_stress_test.cpp",
1158 ],
1159
1160 shared_libs: [
1161 "libbase",
1162 ],
1163
1164 target: {
1165 android: {
1166 static_libs: [
1167 "libmeminfo",
1168 "libprocinfo",
1169 ],
1170 },
1171 },
1172}
1173
Colin Cross2722ebb2016-07-11 16:20:06 -07001174// -----------------------------------------------------------------------------
1175// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +09001176// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
1177// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -07001178// -----------------------------------------------------------------------------
1179cc_test {
1180 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001181 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001182 defaults: ["bionic_tests_defaults"],
Colin Cross0cc60af2021-09-30 14:04:39 -07001183 test_suites: ["device-tests"],
Colin Cross2722ebb2016-07-11 16:20:06 -07001184 host_supported: false,
1185
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001186 srcs: [
1187 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001188 "gtest_globals.cpp",
1189 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -08001190
1191 // The Bionic allocator has its own C++ API. It isn't packaged into its
1192 // own library, so it can only be tested when it's part of libc.a.
1193 "bionic_allocator_test.cpp",
1194 ],
1195 include_dirs: [
1196 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001197 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001198 whole_static_libs: [
1199 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001200 ],
1201
1202 static_libs: [
1203 "libm",
1204 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -07001205 "libdl",
1206 "libtinyxml2",
1207 "liblog",
1208 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -07001209 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001210 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001211 "libtest_elftls_shared_var",
1212 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001213 ],
1214
1215 static_executable: true,
1216 stl: "libc++_static",
Yi Kongb952a772021-10-21 17:31:35 +08001217 // Clang cannot build ifunc with LTO.
1218 // http://b/203737712
1219 lto: {
1220 never: true,
1221 },
Mitch Phillips9425b162022-02-04 17:13:27 -08001222 data_bins: [
1223 "heap_tagging_async_helper",
1224 "heap_tagging_disabled_helper",
1225 "heap_tagging_static_async_helper",
1226 "heap_tagging_static_disabled_helper",
1227 "heap_tagging_static_sync_helper",
1228 "heap_tagging_sync_helper",
Florian Mayerc82d7fc2022-08-31 20:57:03 +00001229 "stack_tagging_helper",
1230 "stack_tagging_static_helper",
Mitch Phillips9425b162022-02-04 17:13:27 -08001231 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001232}
1233
1234// -----------------------------------------------------------------------------
1235// Tests to run on the host and linked against glibc. Run with:
1236// cd bionic/tests; mm bionic-unit-tests-glibc-run
1237// -----------------------------------------------------------------------------
1238
1239cc_test_host {
1240 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001241 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001242 defaults: ["bionic_tests_defaults"],
1243
1244 srcs: [
1245 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -07001246 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001247 "dlfcn_test.cpp",
1248 "dl_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +00001249 "execinfo_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001250 "gtest_globals.cpp",
1251 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001252 "pthread_dlfcn_test.cpp",
1253 ],
1254
1255 shared_libs: [
1256 "libdl_preempt_test_1",
1257 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -07001258 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001259 "libtest_elftls_shared_var",
1260 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001261 ],
1262
1263 whole_static_libs: [
1264 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001265 "libBionicElfTlsTests",
1266 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001267 "libfortify1-tests-clang",
1268 "libfortify2-tests-clang",
1269 ],
1270
1271 static_libs: [
1272 "libbase",
1273 "liblog",
1274 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001275 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -07001276 ],
1277
1278 host_ldlibs: [
1279 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -07001280 "-lutil",
1281 ],
1282
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001283 include_dirs: [
1284 "bionic/libc",
1285 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001286
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -08001287 ldflags: [
1288 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
1289 "-Wl,--export-dynamic",
1290 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001291
1292 sanitize: {
1293 never: false,
1294 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001295
1296 target: {
1297 linux_bionic: {
1298 enabled: false,
1299 },
Colin Cross7da20342021-07-28 11:18:11 -07001300 musl: {
1301 exclude_static_libs: [
1302 // Musl doesn't have fortify
1303 "libfortify1-tests-clang",
1304 "libfortify2-tests-clang",
1305 ],
1306 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001307 },
Colin Cross2722ebb2016-07-11 16:20:06 -07001308}
1309
Elliott Hughes21b56eb2017-10-20 17:57:17 -07001310subdirs = ["*"]