blob: 960131bf663a1479283b16953130c6a390693990 [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
Christopher Ferris1de7a482023-09-12 11:06:29 -070062 // This warning does not provide any benefit to the tests.
63 "-Wno-reorder-init-list",
64
Colin Cross2722ebb2016-07-11 16:20:06 -070065 // For glibc.
66 "-D__STDC_LIMIT_MACROS",
67 ],
Mitch Phillipse6997d52020-11-30 15:04:14 -080068 header_libs: [
69 "libcutils_headers",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +000070 "gwp_asan_headers",
Mitch Phillipse6997d52020-11-30 15:04:14 -080071 ],
Elliott Hughes9a7155d2023-02-10 02:00:03 +000072 stl: "libc++",
73
74 // Ensure that the tests exercise shadow call stack support.
75 // We don't use `scs: true` here because that would give us a second
76 // variant of this library where we actually just want to say "this
77 // library should always be built this way".
Peter Collingbourne7b70e272018-11-12 20:09:14 -080078 arch: {
79 arm64: {
Elliott Hughes9a7155d2023-02-10 02:00:03 +000080 cflags: ["-fsanitize=shadow-call-stack"],
81 },
82 riscv64: {
83 cflags: ["-fsanitize=shadow-call-stack"],
Peter Collingbourne7b70e272018-11-12 20:09:14 -080084 },
85 },
Colin Cross2722ebb2016-07-11 16:20:06 -070086 sanitize: {
Evgenii Stepanov7cc67062019-02-05 18:43:34 -080087 address: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070088 },
Ryan Prichard3c5dff42020-03-31 17:34:03 -070089
90 // Use the bootstrap version of bionic because some tests call private APIs
91 // that aren't exposed by the APEX bionic stubs.
Jiyong Parkc45fe9f2018-12-13 18:26:48 +090092 bootstrap: true,
Colin Cross2722ebb2016-07-11 16:20:06 -070093}
94
95// -----------------------------------------------------------------------------
Chris Parsonscab794c2020-06-15 18:22:10 -040096// Prebuilt shared libraries for use in tests.
97// -----------------------------------------------------------------------------
98
99cc_prebuilt_test_library_shared {
100 name: "libtest_invalid-rw_load_segment",
101 strip: {
102 none: true,
103 },
104 check_elf_files: false,
105 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
106 arch: {
107 arm: {
108 srcs: ["prebuilt-elf-files/arm/libtest_invalid-rw_load_segment.so"],
109 },
110 arm64: {
111 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so"],
112 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000113 riscv64: {
114 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-rw_load_segment.so"],
115 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400116 x86: {
117 srcs: ["prebuilt-elf-files/x86/libtest_invalid-rw_load_segment.so"],
118 },
119 x86_64: {
120 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so"],
121 },
122 },
123}
124
125cc_prebuilt_test_library_shared {
126 name: "libtest_invalid-unaligned_shdr_offset",
127 strip: {
128 none: true,
129 },
130 check_elf_files: false,
131 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
132 arch: {
133 arm: {
134 srcs: ["prebuilt-elf-files/arm/libtest_invalid-unaligned_shdr_offset.so"],
135 },
136 arm64: {
137 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-unaligned_shdr_offset.so"],
138 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000139 riscv64: {
140 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-unaligned_shdr_offset.so"],
141 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400142 x86: {
143 srcs: ["prebuilt-elf-files/x86/libtest_invalid-unaligned_shdr_offset.so"],
144 },
145 x86_64: {
146 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-unaligned_shdr_offset.so"],
147 },
148 },
149}
150
151cc_prebuilt_test_library_shared {
152 name: "libtest_invalid-zero_shentsize",
153 strip: {
154 none: true,
155 },
156 check_elf_files: false,
157 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
158 arch: {
159 arm: {
160 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shentsize.so"],
161 },
162 arm64: {
163 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shentsize.so"],
164 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000165 riscv64: {
166 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shentsize.so"],
167 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400168 x86: {
169 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shentsize.so"],
170 },
171 x86_64: {
172 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shentsize.so"],
173 },
174 },
175}
176
177cc_prebuilt_test_library_shared {
178 name: "libtest_invalid-zero_shstrndx",
179 strip: {
180 none: true,
181 },
182 check_elf_files: false,
183 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
184 arch: {
185 arm: {
186 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shstrndx.so"],
187 },
188 arm64: {
189 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shstrndx.so"],
190 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000191 riscv64: {
192 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shstrndx.so"],
193 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400194 x86: {
195 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shstrndx.so"],
196 },
197 x86_64: {
198 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shstrndx.so"],
199 },
200 },
201}
202
203cc_prebuilt_test_library_shared {
204 name: "libtest_invalid-empty_shdr_table",
205 strip: {
206 none: true,
207 },
208 check_elf_files: false,
209 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
210 arch: {
211 arm: {
212 srcs: ["prebuilt-elf-files/arm/libtest_invalid-empty_shdr_table.so"],
213 },
214 arm64: {
215 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-empty_shdr_table.so"],
216 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000217 riscv64: {
218 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-empty_shdr_table.so"],
219 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400220 x86: {
221 srcs: ["prebuilt-elf-files/x86/libtest_invalid-empty_shdr_table.so"],
222 },
223 x86_64: {
224 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-empty_shdr_table.so"],
225 },
226 },
227}
228
229cc_prebuilt_test_library_shared {
230 name: "libtest_invalid-zero_shdr_table_offset",
231 strip: {
232 none: true,
233 },
234 check_elf_files: false,
235 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
236 arch: {
237 arm: {
238 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_offset.so"],
239 },
240 arm64: {
241 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_offset.so"],
242 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000243 riscv64: {
244 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shdr_table_offset.so"],
245 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400246 x86: {
247 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_offset.so"],
248 },
249 x86_64: {
250 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_offset.so"],
251 },
252 },
253}
254
255cc_prebuilt_test_library_shared {
256 name: "libtest_invalid-zero_shdr_table_content",
257 strip: {
258 none: true,
259 },
260 check_elf_files: false,
261 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
262 arch: {
263 arm: {
264 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_content.so"],
265 },
266 arm64: {
267 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_content.so"],
268 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000269 riscv64: {
270 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-zero_shdr_table_content.so"],
271 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400272 x86: {
273 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_content.so"],
274 },
275 x86_64: {
276 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_content.so"],
277 },
278 },
279}
280
281cc_prebuilt_test_library_shared {
282 name: "libtest_invalid-textrels",
283 strip: {
284 none: true,
285 },
286 check_elf_files: false,
287 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
288 arch: {
289 arm: {
290 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels.so"],
291 },
292 arm64: {
293 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels.so"],
294 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000295 riscv64: {
296 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-textrels.so"],
297 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400298 x86: {
299 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels.so"],
300 },
301 x86_64: {
302 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels.so"],
303 },
304 },
305}
306
307cc_prebuilt_test_library_shared {
308 name: "libtest_invalid-textrels2",
309 strip: {
310 none: true,
311 },
312 check_elf_files: false,
313 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
314 arch: {
315 arm: {
316 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels2.so"],
317 },
318 arm64: {
319 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels2.so"],
320 },
Elliott Hughesec9f0232022-11-16 00:23:21 +0000321 riscv64: {
322 srcs: ["prebuilt-elf-files/riscv64/libtest_invalid-textrels2.so"],
323 },
Chris Parsonscab794c2020-06-15 18:22:10 -0400324 x86: {
325 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels2.so"],
326 },
327 x86_64: {
328 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels2.so"],
329 },
330 },
331}
332
Ryan Prichard8ea6af52022-03-24 21:14:27 -0700333cc_prebuilt_test_library_shared {
334 name: "libtest_invalid-local-tls",
335 strip: {
336 none: true,
337 },
338 check_elf_files: false,
339 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
340 arch: {
341 arm: {
342 srcs: ["prebuilt-elf-files/arm/libtest_invalid-local-tls.so"],
343 },
344 arm64: {
345 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-local-tls.so"],
346 },
347 x86: {
348 srcs: ["prebuilt-elf-files/x86/libtest_invalid-local-tls.so"],
349 },
350 x86_64: {
351 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-local-tls.so"],
352 },
353 },
354}
355
Chris Parsonscab794c2020-06-15 18:22:10 -0400356// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -0700357// All standard tests.
358// -----------------------------------------------------------------------------
359
George Burgess IVde45dcb2018-03-16 14:15:01 -0700360// Test diagnostics emitted by clang. The library that results is useless; we
361// just want to run '-Xclang -verify', which will fail if the diagnostics don't
362// match up with what the source file says they should be.
363cc_test_library {
364 name: "clang_diagnostic_tests",
365 cflags: [
Alixd2569252022-04-21 02:54:27 +0000366 "-Xclang",
367 "-verify",
George Burgess IVde45dcb2018-03-16 14:15:01 -0700368 ],
369 srcs: ["sys_ioctl_diag_test.cpp"],
370}
371
Colin Cross2722ebb2016-07-11 16:20:06 -0700372cc_test_library {
373 name: "libBionicStandardTests",
374 defaults: ["bionic_tests_defaults"],
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",
Colin Cross2722ebb2016-07-11 16:20:06 -0700406 "ftw_test.cpp",
407 "getauxval_test.cpp",
408 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700409 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700410 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800411 "grp_pwd_file_test.cpp",
Peter Collingbourned3060012020-04-01 19:54:48 -0700412 "heap_tagging_level_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700413 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700414 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800415 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700416 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700417 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800418 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700419 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700420 "libgen_basename_test.cpp",
421 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700422 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700423 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700424 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700425 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700426 "malloc_test.cpp",
427 "math_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100428 "membarrier_test.cpp",
Florian Mayerc82d7fc2022-08-31 20:57:03 +0000429 "memtag_stack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700430 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800431 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700432 "netdb_test.cpp",
433 "net_if_test.cpp",
434 "netinet_ether_test.cpp",
435 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700436 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700437 "netinet_udp_test.cpp",
438 "nl_types_test.cpp",
Josh Gao3de19152021-02-22 18:09:48 -0800439 "pidfd_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700440 "poll_test.cpp",
Matthew Maurerde306352020-10-23 09:55:33 -0700441 "prio_ctor_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700442 "pthread_test.cpp",
443 "pty_test.cpp",
444 "regex_test.cpp",
445 "resolv_test.cpp",
446 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800447 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700448 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700449 "search_test.cpp",
450 "semaphore_test.cpp",
451 "setjmp_test.cpp",
452 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700453 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700454 "stack_protector_test.cpp",
455 "stack_protector_test_helper.cpp",
456 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700457 "stdalign_test.cpp",
458 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700459 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700460 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700461 "stdint_test.cpp",
462 "stdio_nofortify_test.cpp",
463 "stdio_test.cpp",
464 "stdio_ext_test.cpp",
465 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700466 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700467 "string_nofortify_test.cpp",
468 "string_test.cpp",
469 "string_posix_strerror_r_test.cpp",
Colin Cross4408b8a2021-07-29 22:45:34 -0700470 "string_posix_strerror_r_wrapper.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700471 "strings_nofortify_test.cpp",
472 "strings_test.cpp",
Peter Collingbourne4edf74a2020-10-02 13:47:03 -0700473 "struct_layout_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700474 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800475 "sys_auxv_test.cpp",
Elliott Hughes74d97652023-07-12 16:30:55 -0700476 "sys_cachectl_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700477 "sys_epoll_test.cpp",
Elliott Hughesf3d6b442023-07-27 16:53:30 -0700478 "sys_hwprobe_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700479 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700480 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700481 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700482 "sys_personality_test.cpp",
483 "sys_prctl_test.cpp",
484 "sys_procfs_test.cpp",
485 "sys_ptrace_test.cpp",
486 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700487 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700488 "sys_resource_test.cpp",
489 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700490 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700491 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700492 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800493 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700494 "sys_socket_test.cpp",
495 "sys_stat_test.cpp",
496 "sys_statvfs_test.cpp",
497 "sys_syscall_test.cpp",
498 "sys_sysinfo_test.cpp",
499 "sys_sysmacros_test.cpp",
500 "sys_time_test.cpp",
501 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700502 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700503 "sys_types_test.cpp",
504 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700505 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700506 "sys_vfs_test.cpp",
Elliott Hughes7cebf832020-08-12 14:25:41 -0700507 "sys_wait_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700508 "sys_xattr_test.cpp",
Elliott Hughes213d9432023-03-01 22:56:13 +0000509 "syslog_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700510 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000511 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800512 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700513 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700514 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700515 "time_test.cpp",
516 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700517 "unistd_nofortify_test.cpp",
518 "unistd_test.cpp",
Mitch Phillips9634c362022-06-23 11:07:00 -0700519 "utils.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700520 "utmp_test.cpp",
Elliott Hughesdbf5b2e2023-04-03 16:30:39 -0700521 "utmpx_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700522 "wchar_test.cpp",
523 "wctype_test.cpp",
524 ],
525
526 include_dirs: [
527 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700528 ],
529
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700530 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700531 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800532 whole_static_libs: [
533 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700534 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800535 "libsystemproperties",
536 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700537 },
Colin Cross7da20342021-07-28 11:18:11 -0700538 musl: {
539 exclude_srcs: [
540 // musl doesn't have error.h
541 "error_test.cpp",
542
543 // musl doesn't define noreturn for C++
544 "stdnoreturn_test.cpp",
545
546 // unsupported relocation type 37
547 "ifunc_test.cpp",
Colin Cross118202b2023-04-14 09:33:11 -0700548
549 // musl #defines utmp to utmpx, causing a collision with
550 // utmpx_test.cpp
551 "utmp_test.cpp",
Colin Cross7da20342021-07-28 11:18:11 -0700552 ],
553 },
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700554 },
555
Dan Willemsen41567702016-08-31 16:35:01 -0700556 static_libs: [
557 "libtinyxml2",
558 "liblog",
559 "libbase",
560 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700561 shared: {
562 enabled: false,
563 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000564
565 generated_headers: ["generated_android_ids"],
Pirama Arumuga Nainarfef519b2022-02-22 15:01:27 -0800566
567 // Bug: http://b/218788252 IR verifier too strict for ifunc resolver that
568 // accept parameters.
569 lto: {
570 never: true,
571 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700572}
573
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800574cc_test_library {
575 name: "libBionicElfTlsTests",
576 defaults: ["bionic_tests_defaults"],
577 srcs: [
578 "elftls_test.cpp",
579 ],
580 include_dirs: [
581 "bionic/libc",
582 ],
583 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 target: {
717 host: {
Alixd2569252022-04-21 02:54:27 +0000718 cflags: ["-D__clang__"],
George Burgess IV9a274102019-06-04 15:39:52 -0700719 },
720 },
721}
722
723cc_test_library {
724 name: "libfortify1-new-tests-clang",
725 defaults: [
726 "bionic_new_fortify_tests_defaults",
727 "bionic_tests_defaults",
728 ],
729 cflags: [
730 "-D_FORTIFY_SOURCE=1",
731 "-DTEST_NAME=Fortify1_clang_new",
732 ],
733 shared: {
734 enabled: false,
735 },
736}
737
738cc_test_library {
739 name: "libfortify2-new-tests-clang",
740 defaults: [
741 "bionic_new_fortify_tests_defaults",
742 "bionic_tests_defaults",
743 ],
744 cflags: [
745 "-D_FORTIFY_SOURCE=2",
746 "-DTEST_NAME=Fortify2_clang_new",
747 ],
748 shared: {
749 enabled: false,
750 },
751}
752
Colin Cross2722ebb2016-07-11 16:20:06 -0700753// -----------------------------------------------------------------------------
754// Library of all tests (excluding the dynamic linker tests).
755// -----------------------------------------------------------------------------
756cc_test_library {
757 name: "libBionicTests",
758 defaults: ["bionic_tests_defaults"],
Colin Crossa48237b2022-02-03 10:28:12 -0800759 host_supported: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700760 whole_static_libs: [
761 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800762 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800763 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700764 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700765 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700766 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700767 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700768 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700769 shared: {
770 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700771 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700772}
773
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700774cc_test_library {
775 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800776 defaults: [
777 "bionic_tests_defaults",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800778 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700779 srcs: [
780 "atexit_test.cpp",
781 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700782 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700783 "dlfcn_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +0000784 "execinfo_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700785 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700786 "pthread_dlfcn_test.cpp",
787 ],
788 static_libs: [
789 "libbase",
790 ],
791 include_dirs: [
792 "bionic/libc",
793 ],
794 shared: {
795 enabled: false,
796 },
797 target: {
798 android: {
799 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700800 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700801 "dlext_test.cpp",
802 "libdl_test.cpp",
803 ],
804 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800805 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400806 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700807 "libziparchive",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700808 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800809 },
Jiyong Park02586a22017-05-20 01:01:24 +0900810 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700811}
812
Colin Cross2722ebb2016-07-11 16:20:06 -0700813// -----------------------------------------------------------------------------
814// Library of bionic customized gtest main function, with normal gtest output format,
815// which is needed by bionic cts test.
816// -----------------------------------------------------------------------------
817cc_test_library {
818 name: "libBionicCtsGtestMain",
819 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700820 srcs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700821 "gtest_globals.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700822 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700823 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700824 shared: {
825 enabled: false,
826 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700827 whole_static_libs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700828 "libbase",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700829 "libgtest_isolated",
830 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700831}
832
Colin Cross2722ebb2016-07-11 16:20:06 -0700833cc_defaults {
Mitch Phillipsf5c9a652023-08-21 13:53:15 +0200834 name: "bionic_unit_tests_data",
Colin Crossbadcb382021-09-24 17:49:58 -0700835 data_bins: [
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700836 "cfi_test_helper",
837 "cfi_test_helper2",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800838 "elftls_dlopen_ie_error_helper",
Ryan Prichard8f639a42018-10-01 23:10:05 -0700839 "exec_linker_helper",
840 "exec_linker_helper_lib",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800841 "heap_tagging_async_helper",
842 "heap_tagging_disabled_helper",
843 "heap_tagging_static_async_helper",
844 "heap_tagging_static_disabled_helper",
845 "heap_tagging_static_sync_helper",
846 "heap_tagging_sync_helper",
Florian Mayerc82d7fc2022-08-31 20:57:03 +0000847 "stack_tagging_helper",
848 "stack_tagging_static_helper",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800849 "ld_config_test_helper",
850 "ld_config_test_helper_lib1",
851 "ld_config_test_helper_lib2",
852 "ld_config_test_helper_lib3",
853 "ld_preload_test_helper",
854 "ld_preload_test_helper_lib1",
855 "ld_preload_test_helper_lib2",
Colin Crossbadcb382021-09-24 17:49:58 -0700856 "ns_hidden_child_helper",
857 "preinit_getauxval_test_helper",
858 "preinit_syscall_test_helper",
859 "thread_exit_cb_helper",
860 "tls_properties_helper",
861 ],
Colin Crossbadcb382021-09-24 17:49:58 -0700862 data_libs: [
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700863 "libatest_simple_zip",
864 "libcfi-test",
865 "libcfi-test-bad",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800866 "libdl_preempt_test_1",
867 "libdl_preempt_test_2",
868 "libdl_test_df_1_global",
869 "libdlext_test",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700870 "libdlext_test_different_soname",
871 "libdlext_test_fd",
872 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400873 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700874 "libdlext_test_zip",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700875 "libgnu-hash-table-library",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800876 "libns_hidden_child_app",
877 "libns_hidden_child_global",
878 "libns_hidden_child_internal",
879 "libns_hidden_child_public",
880 "libnstest_dlopened",
881 "libnstest_ns_a_public1",
882 "libnstest_ns_a_public1_internal",
883 "libnstest_ns_b_public2",
884 "libnstest_ns_b_public3",
885 "libnstest_private",
886 "libnstest_private_external",
887 "libnstest_public",
888 "libnstest_public_internal",
889 "libnstest_root",
890 "libnstest_root_not_isolated",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800891 "librelocations-ANDROID_REL",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800892 "librelocations-ANDROID_RELR",
Elliott Hughes6dd1f582020-01-28 12:18:35 -0800893 "librelocations-RELR",
894 "librelocations-fat",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800895 "libsegment_gap_inner",
896 "libsegment_gap_outer",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700897 "libsysv-hash-table-library",
898 "libtest_atexit",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800899 "libtest_check_order_dlsym",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700900 "libtest_check_order_dlsym_1_left",
901 "libtest_check_order_dlsym_2_right",
902 "libtest_check_order_dlsym_3_c",
903 "libtest_check_order_dlsym_a",
904 "libtest_check_order_dlsym_b",
905 "libtest_check_order_dlsym_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800906 "libtest_check_order_reloc_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700907 "libtest_check_order_reloc_root_1",
908 "libtest_check_order_reloc_root_2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800909 "libtest_check_order_reloc_siblings",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700910 "libtest_check_order_reloc_siblings_1",
911 "libtest_check_order_reloc_siblings_2",
912 "libtest_check_order_reloc_siblings_3",
913 "libtest_check_order_reloc_siblings_a",
914 "libtest_check_order_reloc_siblings_b",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800915 "libtest_check_order_reloc_siblings_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700916 "libtest_check_order_reloc_siblings_c_1",
917 "libtest_check_order_reloc_siblings_c_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700918 "libtest_check_order_reloc_siblings_d",
919 "libtest_check_order_reloc_siblings_e",
920 "libtest_check_order_reloc_siblings_f",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700921 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700922 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700923 "libtest_dlopen_from_ctor",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800924 "libtest_dlopen_from_ctor_main",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700925 "libtest_dlopen_weak_undefined_func",
926 "libtest_dlsym_df_1_global",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800927 "libtest_dlsym_from_this",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700928 "libtest_dlsym_from_this_child",
929 "libtest_dlsym_from_this_grandchild",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700930 "libtest_dlsym_weak_func",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800931 "libtest_dt_runpath_a",
932 "libtest_dt_runpath_b",
933 "libtest_dt_runpath_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700934 "libtest_dt_runpath_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800935 "libtest_dt_runpath_x",
936 "libtest_dt_runpath_y",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -0800937 "libtest_elftls_dynamic",
938 "libtest_elftls_dynamic_filler_1",
939 "libtest_elftls_dynamic_filler_2",
940 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800941 "libtest_elftls_shared_var",
942 "libtest_elftls_shared_var_ie",
943 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700944 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700945 "libtest_ifunc",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800946 "libtest_ifunc_variable",
947 "libtest_ifunc_variable_impl",
948 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700949 "libtest_init_fini_order_child",
950 "libtest_init_fini_order_grand_child",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700951 "libtest_init_fini_order_root",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800952 "libtest_init_fini_order_root2",
953 "libtest_invalid-empty_shdr_table",
Ryan Prichard8ea6af52022-03-24 21:14:27 -0700954 "libtest_invalid-local-tls",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800955 "libtest_invalid-rw_load_segment",
956 "libtest_invalid-textrels",
957 "libtest_invalid-textrels2",
958 "libtest_invalid-unaligned_shdr_offset",
959 "libtest_invalid-zero_shdr_table_content",
960 "libtest_invalid-zero_shdr_table_offset",
961 "libtest_invalid-zero_shentsize",
962 "libtest_invalid-zero_shstrndx",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -0700963 "libtest_missing_symbol",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800964 "libtest_missing_symbol_child_private",
965 "libtest_missing_symbol_child_public",
966 "libtest_missing_symbol_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700967 "libtest_nodelete_1",
968 "libtest_nodelete_2",
969 "libtest_nodelete_dt_flags_1",
970 "libtest_pthread_atfork",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800971 "libtest_relo_check_dt_needed_order",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700972 "libtest_relo_check_dt_needed_order_1",
973 "libtest_relo_check_dt_needed_order_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700974 "libtest_simple",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800975 "libtest_thread_local_dtor",
976 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700977 "libtest_two_parents_child",
978 "libtest_two_parents_parent1",
979 "libtest_two_parents_parent2",
980 "libtest_versioned_lib",
981 "libtest_versioned_libv1",
982 "libtest_versioned_libv2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700983 "libtest_versioned_otherlib",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800984 "libtest_versioned_otherlib_empty",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700985 "libtest_versioned_uselibv1",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700986 "libtest_versioned_uselibv2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800987 "libtest_versioned_uselibv2_other",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700988 "libtest_versioned_uselibv3_other",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800989 "libtest_with_dependency",
990 "libtest_with_dependency_loop",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700991 "libtest_with_dependency_loop_a",
992 "libtest_with_dependency_loop_b",
993 "libtest_with_dependency_loop_c",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800994 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700995 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700996}
997
Mitch Phillipsf5c9a652023-08-21 13:53:15 +0200998// -----------------------------------------------------------------------------
999// Tests for the device using bionic's .so. Run with:
1000// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
1001// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
1002// -----------------------------------------------------------------------------
1003cc_defaults {
1004 name: "bionic_unit_tests_defaults",
1005 host_supported: false,
1006 gtest: false,
1007
1008 defaults: [
1009 "bionic_tests_defaults",
1010 "bionic_unit_tests_data",
1011 ],
1012
1013 whole_static_libs: [
1014 "libBionicTests",
1015 "libBionicLoaderTests",
1016 "libBionicElfTlsLoaderTests",
1017 ],
1018
1019 static_libs: [
1020 "libtinyxml2",
1021 "liblog",
1022 "libbase",
1023 "libgtest_isolated",
1024 ],
1025
1026 srcs: [
1027 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
1028 "__cxa_thread_atexit_test.cpp",
1029 "gtest_globals.cpp",
1030 "gtest_main.cpp",
1031 "gwp_asan_test.cpp",
1032 "thread_local_test.cpp",
1033 ],
1034
1035 conlyflags: [
1036 "-fexceptions",
1037 "-fnon-call-exceptions",
1038 ],
1039
1040 ldflags: ["-Wl,--export-dynamic"],
1041
1042 include_dirs: ["bionic/libc"],
1043
1044 stl: "libc++_static",
1045
1046 target: {
1047 android: {
1048 shared_libs: [
1049 "ld-android",
1050 "libdl",
1051 "libdl_android",
1052 "libdl_preempt_test_1",
1053 "libdl_preempt_test_2",
1054 "libdl_test_df_1_global",
1055 "libtest_elftls_shared_var",
1056 "libtest_elftls_tprel",
1057 ],
1058 static_libs: [
1059 // The order of these libraries matters, do not shuffle them.
1060 "libmeminfo",
1061 "libziparchive",
1062 "libz",
1063 "libutils",
1064 ],
1065 ldflags: [
1066 "-Wl,--rpath,${ORIGIN}/bionic-loader-test-libs",
1067 "-Wl,--enable-new-dtags",
1068 ],
1069 },
1070 },
1071}
1072
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001073cc_test {
1074 name: "bionic-unit-tests",
1075 defaults: [
1076 "bionic_unit_tests_defaults",
1077 ],
Colin Cross0cc60af2021-09-30 14:04:39 -07001078 test_suites: ["device-tests"],
Colin Crossbadcb382021-09-24 17:49:58 -07001079 data: [
1080 ":libdlext_test_runpath_zip_zipaligned",
1081 ":libdlext_test_zip_zipaligned",
1082 ],
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001083}
1084
1085cc_test {
Florian Mayerc10d0642023-03-22 16:12:49 -07001086 name: "hwasan_test",
1087 enabled: false,
1088 // This does not use bionic_tests_defaults because it is not supported on
1089 // host.
1090 arch: {
1091 arm64: {
1092 enabled: true,
1093 },
1094 },
1095 sanitize: {
1096 hwaddress: true,
1097 },
1098 srcs: [
1099 "hwasan_test.cpp",
1100 ],
1101 shared_libs: [
1102 "libbase",
1103 ],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001104 data_libs: [
1105 "libtest_simple_hwasan",
1106 "libtest_simple_hwasan_nohwasan",
1107 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001108 header_libs: ["bionic_libc_platform_headers"],
1109 test_suites: ["device-tests"],
1110}
1111
1112cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001113 name: "bionic-stress-tests",
1114 defaults: [
1115 "bionic_tests_defaults",
1116 ],
1117
1118 // For now, these tests run forever, so do not use the isolation framework.
1119 isolated: false,
Julien Desprez11874f82021-02-05 00:52:14 +00001120 // Running forever, do not consider unit test.
1121 test_options: {
1122 unit_test: false,
1123 },
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001124
1125 srcs: [
1126 "malloc_stress_test.cpp",
1127 ],
1128
1129 shared_libs: [
1130 "libbase",
1131 ],
1132
1133 target: {
1134 android: {
1135 static_libs: [
1136 "libmeminfo",
1137 "libprocinfo",
1138 ],
1139 },
1140 },
1141}
1142
Colin Cross2722ebb2016-07-11 16:20:06 -07001143// -----------------------------------------------------------------------------
1144// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +09001145// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
1146// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -07001147// -----------------------------------------------------------------------------
1148cc_test {
1149 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001150 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001151 defaults: ["bionic_tests_defaults"],
Colin Cross0cc60af2021-09-30 14:04:39 -07001152 test_suites: ["device-tests"],
Colin Cross2722ebb2016-07-11 16:20:06 -07001153 host_supported: false,
1154
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001155 srcs: [
1156 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001157 "gtest_globals.cpp",
1158 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -08001159
1160 // The Bionic allocator has its own C++ API. It isn't packaged into its
1161 // own library, so it can only be tested when it's part of libc.a.
1162 "bionic_allocator_test.cpp",
1163 ],
1164 include_dirs: [
1165 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001166 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001167 whole_static_libs: [
1168 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001169 ],
1170
1171 static_libs: [
1172 "libm",
1173 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -07001174 "libdl",
1175 "libtinyxml2",
1176 "liblog",
1177 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -07001178 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001179 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001180 "libtest_elftls_shared_var",
1181 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001182 ],
1183
1184 static_executable: true,
1185 stl: "libc++_static",
Yi Kongb952a772021-10-21 17:31:35 +08001186 // Clang cannot build ifunc with LTO.
1187 // http://b/203737712
1188 lto: {
1189 never: true,
1190 },
Mitch Phillips9425b162022-02-04 17:13:27 -08001191 data_bins: [
1192 "heap_tagging_async_helper",
1193 "heap_tagging_disabled_helper",
1194 "heap_tagging_static_async_helper",
1195 "heap_tagging_static_disabled_helper",
1196 "heap_tagging_static_sync_helper",
1197 "heap_tagging_sync_helper",
Florian Mayerc82d7fc2022-08-31 20:57:03 +00001198 "stack_tagging_helper",
1199 "stack_tagging_static_helper",
Mitch Phillips9425b162022-02-04 17:13:27 -08001200 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001201}
1202
1203// -----------------------------------------------------------------------------
1204// Tests to run on the host and linked against glibc. Run with:
1205// cd bionic/tests; mm bionic-unit-tests-glibc-run
1206// -----------------------------------------------------------------------------
1207
1208cc_test_host {
1209 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001210 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001211 defaults: ["bionic_tests_defaults"],
1212
1213 srcs: [
1214 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -07001215 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001216 "dlfcn_test.cpp",
1217 "dl_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +00001218 "execinfo_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001219 "gtest_globals.cpp",
1220 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001221 "pthread_dlfcn_test.cpp",
1222 ],
1223
1224 shared_libs: [
1225 "libdl_preempt_test_1",
1226 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -07001227 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001228 "libtest_elftls_shared_var",
1229 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001230 ],
1231
1232 whole_static_libs: [
1233 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001234 "libBionicElfTlsTests",
1235 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001236 "libfortify1-tests-clang",
1237 "libfortify2-tests-clang",
1238 ],
1239
1240 static_libs: [
1241 "libbase",
1242 "liblog",
1243 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001244 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -07001245 ],
1246
1247 host_ldlibs: [
1248 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -07001249 "-lutil",
1250 ],
1251
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001252 include_dirs: [
1253 "bionic/libc",
1254 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001255
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -08001256 ldflags: [
1257 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
1258 "-Wl,--export-dynamic",
1259 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001260
1261 sanitize: {
1262 never: false,
1263 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001264
1265 target: {
1266 linux_bionic: {
1267 enabled: false,
1268 },
Colin Cross7da20342021-07-28 11:18:11 -07001269 musl: {
1270 exclude_static_libs: [
1271 // Musl doesn't have fortify
1272 "libfortify1-tests-clang",
1273 "libfortify2-tests-clang",
1274 ],
1275 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001276 },
Colin Cross2722ebb2016-07-11 16:20:06 -07001277}
1278
Elliott Hughes21b56eb2017-10-20 17:57:17 -07001279subdirs = ["*"]