blob: 3aea968c44d0657455d207a4086f42b799c428de [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",
70 "gwp_asan_headers"
71 ],
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
Mitch Phillips057c8dd2023-08-15 16:22:32 +0200356cc_defaults {
357 name: "memtag_globals_defaults",
358 defaults: [
359 "bionic_testlib_defaults",
360 "bionic_targets_only"
361 ],
362 cflags: [
363 "-Wno-array-bounds",
364 "-Wno-unused-variable",
365 ],
366 header_libs: ["bionic_libc_platform_headers"],
367 sanitize: {
368 hwaddress: false,
369 memtag_heap: true,
370 memtag_globals: true,
371 diag: {
372 memtag_heap: true,
373 }
374 },
375 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files",
376}
377
378/// The following library and binary is to be used for testing the bionic linker
379/// against memtag globals. While we wait for the compiler to be updated, the
380/// files come as prebuilts (built using) the corresponding 'regular'
381/// cc_test_library and cc_test rules below, just with a tip-of-tree version of
382/// LLVM.
383///
384/// Updating the prebuilts can be done by installing a tip-of-tree compiler, and
385/// running:
386/// - m memtag_globals_binary memtag_globals_dso
387/// - cp $ANDROID_PRODUCT_OUT/symbols/data/nativetest64/bionic-loader-test-libs/prebuilt-elf-files/memtag_globals_* \
388/// $ANDROID_BUILD_TOP/bionic/tests/prebuilt-elf-files/arm64/
389///
390// cc_test_library {
391// name: "memtag_globals_dso",
392// defaults: [ "memtag_globals_defaults" ],
393// srcs: ["prebuilt-elf-files/arm64/src/memtag_globals_dso.cpp"],
394// }
395//
396// cc_test {
397// name: "memtag_globals_binary",
398// // Not actually a '.so' file, this is an executable; but the only way to
399// // get soong to be able to produce a properly located and linked prebuilt
400// // variant of this binary was through the cc_prebuilt_test_library_shared
401// // rule, which appends '.so' to the end. Once the prebuilts are removed,
402// // the suffix can be removed.
403// suffix: ".so",
404// defaults: [ "memtag_globals_defaults" ],
405// srcs: ["prebuilt-elf-files/arm64/src/memtag_globals_binary.cpp"],
406// shared_libs: [ "memtag_globals_dso" ],
407// // This binary is used in the bionic-unit-tests as a data dependency, and is
408// // in the same folder as memtag_globals_dso. But, the default cc_test rules
409// // make this binary (when just explicitly built and shoved in
410// // /data/nativetest64/) end up in a subfolder called
411// // 'memtag_globals_binary'. When this happens, the explicit build fails to
412// // find the DSO because the default rpath is just ${ORIGIN}, and because we
413// // want this to be usable both from bionic-unit-tests and explicit builds,
414// // let's just not put it in a subdirectory.
415// no_named_install_directory: true,
416// }
417
418cc_prebuilt_test_library_shared {
419 name: "memtag_globals_dso",
420 defaults: [ "memtag_globals_defaults" ],
421 arch: {
422 arm64: {
423 srcs: ["prebuilt-elf-files/arm64/memtag_globals_dso.so"],
424 },
425 }
426}
427
428cc_prebuilt_test_library_shared {
429 name: "memtag_globals_binary",
430 defaults: [ "memtag_globals_defaults" ],
431 arch: {
432 arm64: {
433 srcs: ["prebuilt-elf-files/arm64/memtag_globals_binary.so"],
434 shared_libs: [ "memtag_globals_dso" ],
435 },
436 }
437}
438
Chris Parsonscab794c2020-06-15 18:22:10 -0400439// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -0700440// All standard tests.
441// -----------------------------------------------------------------------------
442
George Burgess IVde45dcb2018-03-16 14:15:01 -0700443// Test diagnostics emitted by clang. The library that results is useless; we
444// just want to run '-Xclang -verify', which will fail if the diagnostics don't
445// match up with what the source file says they should be.
446cc_test_library {
447 name: "clang_diagnostic_tests",
448 cflags: [
Alixd2569252022-04-21 02:54:27 +0000449 "-Xclang",
450 "-verify",
George Burgess IVde45dcb2018-03-16 14:15:01 -0700451 ],
452 srcs: ["sys_ioctl_diag_test.cpp"],
453}
454
Colin Cross2722ebb2016-07-11 16:20:06 -0700455cc_test_library {
456 name: "libBionicStandardTests",
457 defaults: ["bionic_tests_defaults"],
Chih-Hung Hsieh6fae6142022-12-15 19:30:55 -0800458 tidy_disabled_srcs: [
459 "malloc_test.cpp", // timed out with clang-tidy, and too many warnings
460 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700461 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -0800462 "__aeabi_read_tp_test.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -0800463 "__cxa_atexit_test.cpp",
Elliott Hughes413817f2020-10-26 15:05:35 -0700464 "__cxa_demangle_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300465 "alloca_test.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -0700466 "android_get_device_api_level.cpp",
Christopher Ferrisbbf9cd82022-04-11 16:01:37 -0700467 "android_set_abort_message_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700468 "arpa_inet_test.cpp",
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700469 "async_safe_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -0700470 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700471 "buffer_tests.cpp",
472 "bug_26110743_test.cpp",
Aleksandra Tsvetkova608b4512015-02-27 15:01:59 +0300473 "byteswap_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700474 "complex_test.cpp",
475 "ctype_test.cpp",
476 "dirent_test.cpp",
Elliott Hughesd390df12017-04-30 22:56:10 -0700477 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -0800478 "endian_test.cpp",
Elliott Hughese452cb12017-06-13 14:43:53 -0700479 "errno_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700480 "error_test.cpp",
481 "eventfd_test.cpp",
482 "fcntl_test.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -0700483 "fdsan_test.cpp",
Josh Gao97271922019-11-06 13:15:00 -0800484 "fdtrack_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700485 "fenv_test.cpp",
Elliott Hughes09e77f32020-01-29 19:20:45 -0800486 "_FILE_OFFSET_BITS_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700487 "float_test.cpp",
Elliott Hughes6675ad32020-11-20 16:51:21 -0800488 "fnmatch_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700489 "ftw_test.cpp",
490 "getauxval_test.cpp",
491 "getcwd_test.cpp",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700492 "glob_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700493 "grp_pwd_test.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -0800494 "grp_pwd_file_test.cpp",
Peter Collingbourned3060012020-04-01 19:54:48 -0700495 "heap_tagging_level_test.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -0700496 "iconv_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700497 "ifaddrs_test.cpp",
Peter Collingbourne7a0f04c2019-01-23 17:56:24 -0800498 "ifunc_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700499 "inttypes_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700500 "iso646_test.c",
Elliott Hughesfc8e6882016-11-18 16:27:29 -0800501 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -0700502 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700503 "libgen_basename_test.cpp",
504 "libgen_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700505 "limits_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -0700506 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700507 "locale_test.cpp",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700508 "malloc_iterate_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700509 "malloc_test.cpp",
510 "math_test.cpp",
Orion Hodson6ba66942018-08-30 11:10:23 +0100511 "membarrier_test.cpp",
Florian Mayerc82d7fc2022-08-31 20:57:03 +0000512 "memtag_stack_test.cpp",
Mitch Phillips057c8dd2023-08-15 16:22:32 +0200513 "memtag_globals_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700514 "mntent_test.cpp",
Peter Collingbourne6f1fd682020-01-29 16:27:31 -0800515 "mte_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700516 "netdb_test.cpp",
517 "net_if_test.cpp",
518 "netinet_ether_test.cpp",
519 "netinet_in_test.cpp",
Elliott Hughese5a5eec2018-06-27 12:29:06 -0700520 "netinet_ip_icmp_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700521 "netinet_udp_test.cpp",
522 "nl_types_test.cpp",
Josh Gao3de19152021-02-22 18:09:48 -0800523 "pidfd_test.cpp",
Elliott Hugheseab65722018-08-30 12:15:56 -0700524 "poll_test.cpp",
Matthew Maurerde306352020-10-23 09:55:33 -0700525 "prio_ctor_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700526 "pthread_test.cpp",
527 "pty_test.cpp",
528 "regex_test.cpp",
529 "resolv_test.cpp",
530 "sched_test.cpp",
Peter Collingbourne734beec2018-11-14 12:41:41 -0800531 "scs_test.cpp",
Elliott Hughes50599392017-05-25 17:13:32 -0700532 "scsi_sg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700533 "search_test.cpp",
534 "semaphore_test.cpp",
535 "setjmp_test.cpp",
536 "signal_test.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -0700537 "spawn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700538 "stack_protector_test.cpp",
539 "stack_protector_test_helper.cpp",
540 "stack_unwinding_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700541 "stdalign_test.cpp",
542 "stdarg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700543 "stdatomic_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700544 "stdbool_test.c",
Colin Cross2722ebb2016-07-11 16:20:06 -0700545 "stdint_test.cpp",
546 "stdio_nofortify_test.cpp",
547 "stdio_test.cpp",
548 "stdio_ext_test.cpp",
549 "stdlib_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700550 "stdnoreturn_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700551 "string_nofortify_test.cpp",
552 "string_test.cpp",
553 "string_posix_strerror_r_test.cpp",
Colin Cross4408b8a2021-07-29 22:45:34 -0700554 "string_posix_strerror_r_wrapper.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700555 "strings_nofortify_test.cpp",
556 "strings_test.cpp",
Peter Collingbourne4edf74a2020-10-02 13:47:03 -0700557 "struct_layout_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700558 "sstream_test.cpp",
Elliott Hughesc5d90362020-02-24 09:52:14 -0800559 "sys_auxv_test.cpp",
Elliott Hughes74d97652023-07-12 16:30:55 -0700560 "sys_cachectl_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700561 "sys_epoll_test.cpp",
Elliott Hughesf3d6b442023-07-27 16:53:30 -0700562 "sys_hwprobe_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700563 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700564 "sys_msg_test.cpp",
Nick Kralevichc50b6a22019-03-21 14:04:33 -0700565 "sys_param_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700566 "sys_personality_test.cpp",
567 "sys_prctl_test.cpp",
568 "sys_procfs_test.cpp",
569 "sys_ptrace_test.cpp",
570 "sys_quota_test.cpp",
Elliott Hughes8465e962017-09-27 16:33:35 -0700571 "sys_random_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700572 "sys_resource_test.cpp",
573 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700574 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700575 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700576 "sys_shm_test.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -0800577 "sys_signalfd_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700578 "sys_socket_test.cpp",
579 "sys_stat_test.cpp",
580 "sys_statvfs_test.cpp",
581 "sys_syscall_test.cpp",
582 "sys_sysinfo_test.cpp",
583 "sys_sysmacros_test.cpp",
584 "sys_time_test.cpp",
585 "sys_timex_test.cpp",
Elliott Hughes02fdd052017-07-06 10:33:15 -0700586 "sys_ttydefaults_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700587 "sys_types_test.cpp",
588 "sys_uio_test.cpp",
Elliott Hughese7d185f2018-06-27 13:30:02 -0700589 "sys_un_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700590 "sys_vfs_test.cpp",
Elliott Hughes7cebf832020-08-12 14:25:41 -0700591 "sys_wait_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700592 "sys_xattr_test.cpp",
Elliott Hughes213d9432023-03-01 22:56:13 +0000593 "syslog_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700594 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000595 "system_properties_test2.cpp",
Elliott Hughes5da96462017-12-14 09:43:59 -0800596 "termios_test.cpp",
Elliott Hughes45da3262017-08-29 15:28:33 -0700597 "tgmath_test.c",
Elliott Hughes42067112019-04-18 14:27:24 -0700598 "threads_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700599 "time_test.cpp",
600 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700601 "unistd_nofortify_test.cpp",
602 "unistd_test.cpp",
Mitch Phillips9634c362022-06-23 11:07:00 -0700603 "utils.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700604 "utmp_test.cpp",
Elliott Hughesdbf5b2e2023-04-03 16:30:39 -0700605 "utmpx_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700606 "wchar_test.cpp",
607 "wctype_test.cpp",
608 ],
609
610 include_dirs: [
611 "bionic/libc",
Colin Cross2722ebb2016-07-11 16:20:06 -0700612 ],
613
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700614 target: {
Dan Willemsen268ae362017-09-21 16:56:06 -0700615 bionic: {
Tom Cherrye275d6d2017-12-11 23:31:33 -0800616 whole_static_libs: [
617 "libasync_safe",
Christopher Ferrisbfd3dc42018-10-15 10:02:38 -0700618 "libprocinfo",
Tom Cherrye275d6d2017-12-11 23:31:33 -0800619 "libsystemproperties",
620 ],
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700621 },
Colin Cross7da20342021-07-28 11:18:11 -0700622 musl: {
623 exclude_srcs: [
624 // musl doesn't have error.h
625 "error_test.cpp",
626
627 // musl doesn't define noreturn for C++
628 "stdnoreturn_test.cpp",
629
630 // unsupported relocation type 37
631 "ifunc_test.cpp",
Colin Cross118202b2023-04-14 09:33:11 -0700632
633 // musl #defines utmp to utmpx, causing a collision with
634 // utmpx_test.cpp
635 "utmp_test.cpp",
Colin Cross7da20342021-07-28 11:18:11 -0700636 ],
637 },
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700638 },
639
Dan Willemsen41567702016-08-31 16:35:01 -0700640 static_libs: [
641 "libtinyxml2",
642 "liblog",
643 "libbase",
644 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700645 shared: {
646 enabled: false,
647 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000648
649 generated_headers: ["generated_android_ids"],
Pirama Arumuga Nainarfef519b2022-02-22 15:01:27 -0800650
651 // Bug: http://b/218788252 IR verifier too strict for ifunc resolver that
652 // accept parameters.
653 lto: {
654 never: true,
655 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700656}
657
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800658cc_test_library {
659 name: "libBionicElfTlsTests",
660 defaults: ["bionic_tests_defaults"],
661 srcs: [
662 "elftls_test.cpp",
663 ],
664 include_dirs: [
665 "bionic/libc",
666 ],
667 shared: {
668 enabled: false,
669 },
670 cflags: [
671 "-fno-emulated-tls",
672 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700673 // With fuzzer builds, compiler instrumentation generates a reference to the
674 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
675 // library as an emutls symbol. The -fno-emulated-tls flag above configures
676 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
677 // symbol instead, which isn't defined. Disable the fuzzer for this test
678 // until the platform is switched to ELF TLS.
679 sanitize: {
680 fuzzer: false,
681 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800682}
683
684cc_test_library {
685 name: "libBionicElfTlsLoaderTests",
686 defaults: ["bionic_tests_defaults"],
687 srcs: [
688 "elftls_dl_test.cpp",
689 ],
690 include_dirs: [
691 "bionic/libc",
692 ],
693 static_libs: [
694 "liblog",
695 "libbase",
696 ],
697 shared: {
698 enabled: false,
699 },
700 cflags: [
701 "-fno-emulated-tls",
702 ],
Mitch Phillips2f1bdef2019-05-01 14:26:13 -0700703 // With fuzzer builds, compiler instrumentation generates a reference to the
704 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer
705 // library as an emutls symbol. The -fno-emulated-tls flag above configures
706 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack
707 // symbol instead, which isn't defined. Disable the fuzzer for this test
708 // until the platform is switched to ELF TLS.
709 sanitize: {
710 fuzzer: false,
711 },
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800712}
713
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800714cc_test_library {
715 name: "libBionicFramePointerTests",
716 defaults: ["bionic_tests_defaults"],
717 srcs: [
718 "android_unsafe_frame_pointer_chase_test.cpp",
719 ],
720 include_dirs: [
721 "bionic/libc",
722 ],
723 cflags: [
724 "-fno-omit-frame-pointer",
725 ],
726}
727
Colin Cross2722ebb2016-07-11 16:20:06 -0700728// -----------------------------------------------------------------------------
729// Fortify tests.
730// -----------------------------------------------------------------------------
731
732cc_defaults {
George Burgess IV9a274102019-06-04 15:39:52 -0700733 name: "bionic_clang_fortify_tests_w_flags",
734 cflags: [
735 "-Wno-builtin-memcpy-chk-size",
George Burgess IV26d25a22019-06-06 17:45:05 -0700736 "-Wno-format-security",
George Burgess IV9a274102019-06-04 15:39:52 -0700737 "-Wno-format-zero-length",
Yi Kongbf67ea52019-08-03 18:26:05 -0700738 "-Wno-fortify-source",
George Burgess IV9a274102019-06-04 15:39:52 -0700739 "-Wno-memset-transposed-args",
George Burgess IV77f99aa2019-06-06 14:14:52 -0700740 "-Wno-strlcpy-strlcat-size",
George Burgess IV9a274102019-06-04 15:39:52 -0700741 "-Wno-strncat-size",
742 ],
Elliott Hughes141b9172021-04-09 17:13:09 -0700743 static_libs: [
744 "libbase",
745 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700746}
747
748cc_defaults {
Colin Cross2722ebb2016-07-11 16:20:06 -0700749 name: "bionic_fortify_tests_defaults",
750 cflags: [
Colin Cross2722ebb2016-07-11 16:20:06 -0700751 "-U_FORTIFY_SOURCE",
752 ],
753 srcs: ["fortify_test_main.cpp"],
Elliott Hughes141b9172021-04-09 17:13:09 -0700754 static_libs: [
755 "libbase",
756 ],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800757 tidy: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700758 target: {
Colin Crossa48237b2022-02-03 10:28:12 -0800759 musl: {
760 // Musl doesn't have fortify
761 enabled: false,
762 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700763 },
764}
765
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700766// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
767// it can confuse these tools pretty easily. If this builds successfully, then
768// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
769// enabled. The library that results from building this is meant to be unused.
770cc_test_library {
771 name: "fortify_disabled_for_tidy",
George Burgess IV9a274102019-06-04 15:39:52 -0700772 defaults: [
773 "bionic_clang_fortify_tests_w_flags",
774 ],
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700775 cflags: [
776 "-Werror",
777 "-D_FORTIFY_SOURCE=2",
778 "-D__clang_analyzer__",
779 ],
George Burgess IV9a274102019-06-04 15:39:52 -0700780 srcs: ["clang_fortify_tests.cpp"],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800781 tidy: false,
George Burgess IVe5d66eb2017-10-30 21:41:22 -0700782}
783
Colin Cross2722ebb2016-07-11 16:20:06 -0700784cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700785 name: "libfortify1-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800786 defaults: [
787 "bionic_fortify_tests_defaults",
788 "bionic_tests_defaults",
789 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700790 cflags: [
791 "-D_FORTIFY_SOURCE=1",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800792 "-DTEST_NAME=Fortify1_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700793 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700794 shared: {
795 enabled: false,
796 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700797}
798
799cc_test_library {
800 name: "libfortify2-tests-clang",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800801 defaults: [
802 "bionic_fortify_tests_defaults",
803 "bionic_tests_defaults",
804 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700805 cflags: [
806 "-D_FORTIFY_SOURCE=2",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800807 "-DTEST_NAME=Fortify2_clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700808 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700809 shared: {
810 enabled: false,
811 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700812}
813
George Burgess IV9a274102019-06-04 15:39:52 -0700814cc_defaults {
815 name: "bionic_new_fortify_tests_defaults",
816 defaults: [
817 "bionic_clang_fortify_tests_w_flags",
818 ],
819 cflags: [
820 "-U_FORTIFY_SOURCE",
821 ],
822 srcs: ["clang_fortify_tests.cpp"],
Chih-Hung Hsieh247892e2021-01-27 12:28:20 -0800823 tidy: false,
George Burgess IV9a274102019-06-04 15:39:52 -0700824 target: {
825 host: {
Alixd2569252022-04-21 02:54:27 +0000826 cflags: ["-D__clang__"],
George Burgess IV9a274102019-06-04 15:39:52 -0700827 },
828 },
829}
830
831cc_test_library {
832 name: "libfortify1-new-tests-clang",
833 defaults: [
834 "bionic_new_fortify_tests_defaults",
835 "bionic_tests_defaults",
836 ],
837 cflags: [
838 "-D_FORTIFY_SOURCE=1",
839 "-DTEST_NAME=Fortify1_clang_new",
840 ],
841 shared: {
842 enabled: false,
843 },
844}
845
846cc_test_library {
847 name: "libfortify2-new-tests-clang",
848 defaults: [
849 "bionic_new_fortify_tests_defaults",
850 "bionic_tests_defaults",
851 ],
852 cflags: [
853 "-D_FORTIFY_SOURCE=2",
854 "-DTEST_NAME=Fortify2_clang_new",
855 ],
856 shared: {
857 enabled: false,
858 },
859}
860
Colin Cross2722ebb2016-07-11 16:20:06 -0700861// -----------------------------------------------------------------------------
862// Library of all tests (excluding the dynamic linker tests).
863// -----------------------------------------------------------------------------
864cc_test_library {
865 name: "libBionicTests",
866 defaults: ["bionic_tests_defaults"],
Colin Crossa48237b2022-02-03 10:28:12 -0800867 host_supported: false,
Colin Cross2722ebb2016-07-11 16:20:06 -0700868 whole_static_libs: [
869 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -0800870 "libBionicElfTlsTests",
Peter Collingbourne5f45c182020-01-14 17:59:41 -0800871 "libBionicFramePointerTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700872 "libfortify1-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700873 "libfortify1-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700874 "libfortify2-tests-clang",
George Burgess IV9a274102019-06-04 15:39:52 -0700875 "libfortify2-new-tests-clang",
Colin Cross2722ebb2016-07-11 16:20:06 -0700876 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700877 shared: {
878 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700879 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700880}
881
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700882cc_test_library {
883 name: "libBionicLoaderTests",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800884 defaults: [
885 "bionic_tests_defaults",
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800886 ],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700887 srcs: [
888 "atexit_test.cpp",
889 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700890 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700891 "dlfcn_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +0000892 "execinfo_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700893 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700894 "pthread_dlfcn_test.cpp",
895 ],
896 static_libs: [
897 "libbase",
898 ],
899 include_dirs: [
900 "bionic/libc",
901 ],
902 shared: {
903 enabled: false,
904 },
905 target: {
906 android: {
907 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700908 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700909 "dlext_test.cpp",
910 "libdl_test.cpp",
911 ],
912 static_libs: [
Sandeep Patile3f39a02019-01-21 14:22:05 -0800913 "libmeminfo",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400914 "libprocinfo",
Andreas Gampeb9797fe2017-07-05 22:36:20 -0700915 "libziparchive",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700916 ],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800917 },
Jiyong Park02586a22017-05-20 01:01:24 +0900918 },
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700919}
920
Colin Cross2722ebb2016-07-11 16:20:06 -0700921// -----------------------------------------------------------------------------
922// Library of bionic customized gtest main function, with normal gtest output format,
923// which is needed by bionic cts test.
924// -----------------------------------------------------------------------------
925cc_test_library {
926 name: "libBionicCtsGtestMain",
927 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700928 srcs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700929 "gtest_globals.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700930 "gtest_main.cpp",
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700931 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700932 shared: {
933 enabled: false,
934 },
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700935 whole_static_libs: [
Colin Crossbadcb382021-09-24 17:49:58 -0700936 "libbase",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -0700937 "libgtest_isolated",
938 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700939}
940
Colin Cross2722ebb2016-07-11 16:20:06 -0700941cc_defaults {
Mitch Phillipsf5c9a652023-08-21 13:53:15 +0200942 name: "bionic_unit_tests_data",
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",
Mitch Phillips057c8dd2023-08-15 16:22:32 +0200969 "memtag_globals_binary",
970 "memtag_globals_dso",
Colin Crossbadcb382021-09-24 17:49:58 -0700971 ],
Colin Crossbadcb382021-09-24 17:49:58 -0700972 data_libs: [
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700973 "libatest_simple_zip",
974 "libcfi-test",
975 "libcfi-test-bad",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800976 "libdl_preempt_test_1",
977 "libdl_preempt_test_2",
978 "libdl_test_df_1_global",
979 "libdlext_test",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700980 "libdlext_test_different_soname",
981 "libdlext_test_fd",
982 "libdlext_test_norelro",
Torne (Richard Coles)efbe9a52018-10-17 15:59:38 -0400983 "libdlext_test_recursive",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700984 "libdlext_test_zip",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700985 "libgnu-hash-table-library",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -0800986 "libns_hidden_child_app",
987 "libns_hidden_child_global",
988 "libns_hidden_child_internal",
989 "libns_hidden_child_public",
990 "libnstest_dlopened",
991 "libnstest_ns_a_public1",
992 "libnstest_ns_a_public1_internal",
993 "libnstest_ns_b_public2",
994 "libnstest_ns_b_public3",
995 "libnstest_private",
996 "libnstest_private_external",
997 "libnstest_public",
998 "libnstest_public_internal",
999 "libnstest_root",
1000 "libnstest_root_not_isolated",
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001001 "librelocations-ANDROID_REL",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001002 "librelocations-ANDROID_RELR",
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001003 "librelocations-RELR",
1004 "librelocations-fat",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001005 "libsegment_gap_inner",
1006 "libsegment_gap_outer",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001007 "libsysv-hash-table-library",
1008 "libtest_atexit",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001009 "libtest_check_order_dlsym",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001010 "libtest_check_order_dlsym_1_left",
1011 "libtest_check_order_dlsym_2_right",
1012 "libtest_check_order_dlsym_3_c",
1013 "libtest_check_order_dlsym_a",
1014 "libtest_check_order_dlsym_b",
1015 "libtest_check_order_dlsym_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001016 "libtest_check_order_reloc_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001017 "libtest_check_order_reloc_root_1",
1018 "libtest_check_order_reloc_root_2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001019 "libtest_check_order_reloc_siblings",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001020 "libtest_check_order_reloc_siblings_1",
1021 "libtest_check_order_reloc_siblings_2",
1022 "libtest_check_order_reloc_siblings_3",
1023 "libtest_check_order_reloc_siblings_a",
1024 "libtest_check_order_reloc_siblings_b",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001025 "libtest_check_order_reloc_siblings_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001026 "libtest_check_order_reloc_siblings_c_1",
1027 "libtest_check_order_reloc_siblings_c_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001028 "libtest_check_order_reloc_siblings_d",
1029 "libtest_check_order_reloc_siblings_e",
1030 "libtest_check_order_reloc_siblings_f",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001031 "libtest_check_rtld_next_from_library",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -07001032 "libtest_dlopen_df_1_global",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001033 "libtest_dlopen_from_ctor",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001034 "libtest_dlopen_from_ctor_main",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001035 "libtest_dlopen_weak_undefined_func",
1036 "libtest_dlsym_df_1_global",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001037 "libtest_dlsym_from_this",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001038 "libtest_dlsym_from_this_child",
1039 "libtest_dlsym_from_this_grandchild",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001040 "libtest_dlsym_weak_func",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001041 "libtest_dt_runpath_a",
1042 "libtest_dt_runpath_b",
1043 "libtest_dt_runpath_c",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001044 "libtest_dt_runpath_d",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001045 "libtest_dt_runpath_x",
1046 "libtest_dt_runpath_y",
Ryan Pricharde84ebbb2019-01-23 23:19:19 -08001047 "libtest_elftls_dynamic",
1048 "libtest_elftls_dynamic_filler_1",
1049 "libtest_elftls_dynamic_filler_2",
1050 "libtest_elftls_dynamic_filler_3",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001051 "libtest_elftls_shared_var",
1052 "libtest_elftls_shared_var_ie",
1053 "libtest_elftls_tprel",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001054 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -07001055 "libtest_ifunc",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001056 "libtest_ifunc_variable",
1057 "libtest_ifunc_variable_impl",
1058 "libtest_indirect_thread_local_dtor",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001059 "libtest_init_fini_order_child",
1060 "libtest_init_fini_order_grand_child",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001061 "libtest_init_fini_order_root",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001062 "libtest_init_fini_order_root2",
1063 "libtest_invalid-empty_shdr_table",
Ryan Prichard8ea6af52022-03-24 21:14:27 -07001064 "libtest_invalid-local-tls",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001065 "libtest_invalid-rw_load_segment",
1066 "libtest_invalid-textrels",
1067 "libtest_invalid-textrels2",
1068 "libtest_invalid-unaligned_shdr_offset",
1069 "libtest_invalid-zero_shdr_table_content",
1070 "libtest_invalid-zero_shdr_table_offset",
1071 "libtest_invalid-zero_shentsize",
1072 "libtest_invalid-zero_shstrndx",
Pirama Arumuga Nainarc53e8b82018-03-27 10:32:19 -07001073 "libtest_missing_symbol",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001074 "libtest_missing_symbol_child_private",
1075 "libtest_missing_symbol_child_public",
1076 "libtest_missing_symbol_root",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001077 "libtest_nodelete_1",
1078 "libtest_nodelete_2",
1079 "libtest_nodelete_dt_flags_1",
1080 "libtest_pthread_atfork",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001081 "libtest_relo_check_dt_needed_order",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001082 "libtest_relo_check_dt_needed_order_1",
1083 "libtest_relo_check_dt_needed_order_2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001084 "libtest_simple",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001085 "libtest_thread_local_dtor",
1086 "libtest_thread_local_dtor2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001087 "libtest_two_parents_child",
1088 "libtest_two_parents_parent1",
1089 "libtest_two_parents_parent2",
1090 "libtest_versioned_lib",
1091 "libtest_versioned_libv1",
1092 "libtest_versioned_libv2",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001093 "libtest_versioned_otherlib",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001094 "libtest_versioned_otherlib_empty",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001095 "libtest_versioned_uselibv1",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001096 "libtest_versioned_uselibv2",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001097 "libtest_versioned_uselibv2_other",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001098 "libtest_versioned_uselibv3_other",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001099 "libtest_with_dependency",
1100 "libtest_with_dependency_loop",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001101 "libtest_with_dependency_loop_a",
1102 "libtest_with_dependency_loop_b",
1103 "libtest_with_dependency_loop_c",
Evgenii Stepanovdf6b16e2021-01-12 16:07:50 -08001104 "libtestshared",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -07001105 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001106}
1107
Mitch Phillipsf5c9a652023-08-21 13:53:15 +02001108// -----------------------------------------------------------------------------
1109// Tests for the device using bionic's .so. Run with:
1110// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
1111// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests
1112// -----------------------------------------------------------------------------
1113cc_defaults {
1114 name: "bionic_unit_tests_defaults",
1115 host_supported: false,
1116 gtest: false,
1117
1118 defaults: [
1119 "bionic_tests_defaults",
1120 "bionic_unit_tests_data",
1121 ],
1122
1123 whole_static_libs: [
1124 "libBionicTests",
1125 "libBionicLoaderTests",
1126 "libBionicElfTlsLoaderTests",
1127 ],
1128
1129 static_libs: [
1130 "libtinyxml2",
1131 "liblog",
1132 "libbase",
1133 "libgtest_isolated",
1134 ],
1135
1136 srcs: [
1137 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
1138 "__cxa_thread_atexit_test.cpp",
1139 "gtest_globals.cpp",
1140 "gtest_main.cpp",
1141 "gwp_asan_test.cpp",
1142 "thread_local_test.cpp",
1143 ],
1144
1145 conlyflags: [
1146 "-fexceptions",
1147 "-fnon-call-exceptions",
1148 ],
1149
1150 ldflags: ["-Wl,--export-dynamic"],
1151
1152 include_dirs: ["bionic/libc"],
1153
1154 stl: "libc++_static",
1155
1156 target: {
1157 android: {
1158 shared_libs: [
1159 "ld-android",
1160 "libdl",
1161 "libdl_android",
1162 "libdl_preempt_test_1",
1163 "libdl_preempt_test_2",
1164 "libdl_test_df_1_global",
1165 "libtest_elftls_shared_var",
1166 "libtest_elftls_tprel",
1167 ],
1168 static_libs: [
1169 // The order of these libraries matters, do not shuffle them.
1170 "libmeminfo",
1171 "libziparchive",
1172 "libz",
1173 "libutils",
1174 ],
1175 ldflags: [
1176 "-Wl,--rpath,${ORIGIN}/bionic-loader-test-libs",
1177 "-Wl,--enable-new-dtags",
1178 ],
1179 },
1180 },
1181}
1182
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001183cc_test {
1184 name: "bionic-unit-tests",
1185 defaults: [
1186 "bionic_unit_tests_defaults",
1187 ],
Colin Cross0cc60af2021-09-30 14:04:39 -07001188 test_suites: ["device-tests"],
Colin Crossbadcb382021-09-24 17:49:58 -07001189 data: [
1190 ":libdlext_test_runpath_zip_zipaligned",
1191 ":libdlext_test_zip_zipaligned",
1192 ],
Christopher Ferrisfc26d712019-02-27 18:07:55 -08001193}
1194
1195cc_test {
Florian Mayerc10d0642023-03-22 16:12:49 -07001196 name: "hwasan_test",
1197 enabled: false,
1198 // This does not use bionic_tests_defaults because it is not supported on
1199 // host.
1200 arch: {
1201 arm64: {
1202 enabled: true,
1203 },
1204 },
1205 sanitize: {
1206 hwaddress: true,
1207 },
1208 srcs: [
1209 "hwasan_test.cpp",
1210 ],
1211 shared_libs: [
1212 "libbase",
1213 ],
1214 data_libs: ["libtest_simple_hwasan", "libtest_simple_hwasan_nohwasan"],
1215 header_libs: ["bionic_libc_platform_headers"],
1216 test_suites: ["device-tests"],
1217}
1218
1219cc_test {
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001220 name: "bionic-stress-tests",
1221 defaults: [
1222 "bionic_tests_defaults",
1223 ],
1224
1225 // For now, these tests run forever, so do not use the isolation framework.
1226 isolated: false,
Julien Desprez11874f82021-02-05 00:52:14 +00001227 // Running forever, do not consider unit test.
1228 test_options: {
1229 unit_test: false,
1230 },
Christopher Ferrisee0ce442019-10-21 12:35:05 -07001231
1232 srcs: [
1233 "malloc_stress_test.cpp",
1234 ],
1235
1236 shared_libs: [
1237 "libbase",
1238 ],
1239
1240 target: {
1241 android: {
1242 static_libs: [
1243 "libmeminfo",
1244 "libprocinfo",
1245 ],
1246 },
1247 },
1248}
1249
Colin Cross2722ebb2016-07-11 16:20:06 -07001250// -----------------------------------------------------------------------------
1251// Tests for the device linked against bionic's static library. Run with:
Bernie Innocentib6647242018-06-18 14:14:43 +09001252// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
1253// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Colin Cross2722ebb2016-07-11 16:20:06 -07001254// -----------------------------------------------------------------------------
1255cc_test {
1256 name: "bionic-unit-tests-static",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001257 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001258 defaults: ["bionic_tests_defaults"],
Colin Cross0cc60af2021-09-30 14:04:39 -07001259 test_suites: ["device-tests"],
Colin Cross2722ebb2016-07-11 16:20:06 -07001260 host_supported: false,
1261
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001262 srcs: [
1263 "gtest_preinit_debuggerd.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001264 "gtest_globals.cpp",
1265 "gtest_main.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -08001266
1267 // The Bionic allocator has its own C++ API. It isn't packaged into its
1268 // own library, so it can only be tested when it's part of libc.a.
1269 "bionic_allocator_test.cpp",
1270 ],
1271 include_dirs: [
1272 "bionic/libc",
Dimitry Ivanov462ea662017-01-06 14:49:57 -08001273 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001274 whole_static_libs: [
1275 "libBionicTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001276 ],
1277
1278 static_libs: [
1279 "libm",
1280 "libc",
Colin Cross2722ebb2016-07-11 16:20:06 -07001281 "libdl",
1282 "libtinyxml2",
1283 "liblog",
1284 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -07001285 "libdebuggerd_handler",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001286 "libgtest_isolated",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001287 "libtest_elftls_shared_var",
1288 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001289 ],
1290
1291 static_executable: true,
1292 stl: "libc++_static",
Yi Kongb952a772021-10-21 17:31:35 +08001293 // Clang cannot build ifunc with LTO.
1294 // http://b/203737712
1295 lto: {
1296 never: true,
1297 },
Mitch Phillips9425b162022-02-04 17:13:27 -08001298 data_bins: [
1299 "heap_tagging_async_helper",
1300 "heap_tagging_disabled_helper",
1301 "heap_tagging_static_async_helper",
1302 "heap_tagging_static_disabled_helper",
1303 "heap_tagging_static_sync_helper",
1304 "heap_tagging_sync_helper",
Florian Mayerc82d7fc2022-08-31 20:57:03 +00001305 "stack_tagging_helper",
1306 "stack_tagging_static_helper",
Mitch Phillips9425b162022-02-04 17:13:27 -08001307 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001308}
1309
1310// -----------------------------------------------------------------------------
1311// Tests to run on the host and linked against glibc. Run with:
1312// cd bionic/tests; mm bionic-unit-tests-glibc-run
1313// -----------------------------------------------------------------------------
1314
1315cc_test_host {
1316 name: "bionic-unit-tests-glibc",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001317 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -07001318 defaults: ["bionic_tests_defaults"],
1319
1320 srcs: [
1321 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -07001322 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001323 "dlfcn_test.cpp",
1324 "dl_test.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +00001325 "execinfo_test.cpp",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001326 "gtest_globals.cpp",
1327 "gtest_main.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -07001328 "pthread_dlfcn_test.cpp",
1329 ],
1330
1331 shared_libs: [
1332 "libdl_preempt_test_1",
1333 "libdl_preempt_test_2",
Colin Cross2722ebb2016-07-11 16:20:06 -07001334 "libdl_test_df_1_global",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001335 "libtest_elftls_shared_var",
1336 "libtest_elftls_tprel",
Colin Cross2722ebb2016-07-11 16:20:06 -07001337 ],
1338
1339 whole_static_libs: [
1340 "libBionicStandardTests",
Ryan Prichard5cf02f62019-01-15 20:35:00 -08001341 "libBionicElfTlsTests",
1342 "libBionicElfTlsLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -07001343 "libfortify1-tests-clang",
1344 "libfortify2-tests-clang",
1345 ],
1346
1347 static_libs: [
1348 "libbase",
1349 "liblog",
1350 "libcutils",
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001351 "libgtest_isolated",
Colin Cross2722ebb2016-07-11 16:20:06 -07001352 ],
1353
1354 host_ldlibs: [
1355 "-lresolv",
Colin Cross2722ebb2016-07-11 16:20:06 -07001356 "-lutil",
1357 ],
1358
Christopher Ferris6d2c0bd2018-08-21 18:13:10 -07001359 include_dirs: [
1360 "bionic/libc",
1361 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001362
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -08001363 ldflags: [
1364 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
1365 "-Wl,--export-dynamic",
1366 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001367
1368 sanitize: {
1369 never: false,
1370 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001371
1372 target: {
1373 linux_bionic: {
1374 enabled: false,
1375 },
Colin Cross7da20342021-07-28 11:18:11 -07001376 musl: {
1377 exclude_static_libs: [
1378 // Musl doesn't have fortify
1379 "libfortify1-tests-clang",
1380 "libfortify2-tests-clang",
1381 ],
1382 },
Dan Willemsen268ae362017-09-21 16:56:06 -07001383 },
Colin Cross2722ebb2016-07-11 16:20:06 -07001384}
1385
Elliott Hughes21b56eb2017-10-20 17:57:17 -07001386subdirs = ["*"]