blob: ae8d7fc3808332001e4898c1768c4d50cc978524 [file] [log] [blame]
Colin Cross2722ebb2016-07-11 16:20:06 -07001//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "bionic_tests_defaults",
19 host_supported: true,
20 target: {
21 darwin: {
22 enabled: false,
23 },
24 },
25 cflags: [
26 "-fstack-protector-all",
27 "-g",
28 "-Wall",
29 "-Wextra",
30 "-Wunused",
31 "-Werror",
32 "-fno-builtin",
33
34 // We want to test deprecated API too.
35 "-Wno-deprecated-declarations",
36
37 // For glibc.
38 "-D__STDC_LIMIT_MACROS",
39 ],
40 stl: "libc++",
41 sanitize: {
42 never: true,
43 },
44}
45
46// -----------------------------------------------------------------------------
47// All standard tests.
48// -----------------------------------------------------------------------------
49
50cc_test_library {
51 name: "libBionicStandardTests",
52 defaults: ["bionic_tests_defaults"],
53 srcs: [
54 "arpa_inet_test.cpp",
Elliott Hughesf6495c72016-07-25 09:20:57 -070055 "assert_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070056 "buffer_tests.cpp",
57 "bug_26110743_test.cpp",
58 "complex_test.cpp",
59 "ctype_test.cpp",
60 "dirent_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080061 "endian_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070062 "error_test.cpp",
63 "eventfd_test.cpp",
64 "fcntl_test.cpp",
65 "fenv_test.cpp",
66 "ftw_test.cpp",
67 "getauxval_test.cpp",
68 "getcwd_test.cpp",
69 "grp_pwd_test.cpp",
70 "ifaddrs_test.cpp",
71 "inttypes_test.cpp",
Elliott Hughesfc8e6882016-11-18 16:27:29 -080072 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -070073 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070074 "libc_logging_test.cpp",
75 "libgen_basename_test.cpp",
76 "libgen_test.cpp",
77 "locale_test.cpp",
78 "malloc_test.cpp",
79 "math_test.cpp",
80 "mntent_test.cpp",
81 "netdb_test.cpp",
82 "net_if_test.cpp",
83 "netinet_ether_test.cpp",
84 "netinet_in_test.cpp",
85 "netinet_udp_test.cpp",
86 "nl_types_test.cpp",
87 "pthread_test.cpp",
88 "pty_test.cpp",
89 "regex_test.cpp",
90 "resolv_test.cpp",
91 "sched_test.cpp",
92 "search_test.cpp",
93 "semaphore_test.cpp",
94 "setjmp_test.cpp",
95 "signal_test.cpp",
96 "stack_protector_test.cpp",
97 "stack_protector_test_helper.cpp",
98 "stack_unwinding_test.cpp",
99 "stdatomic_test.cpp",
100 "stdint_test.cpp",
101 "stdio_nofortify_test.cpp",
102 "stdio_test.cpp",
103 "stdio_ext_test.cpp",
104 "stdlib_test.cpp",
105 "string_nofortify_test.cpp",
106 "string_test.cpp",
107 "string_posix_strerror_r_test.cpp",
108 "strings_nofortify_test.cpp",
109 "strings_test.cpp",
110 "sstream_test.cpp",
111 "sys_epoll_test.cpp",
112 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700113 "sys_msg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700114 "sys_personality_test.cpp",
115 "sys_prctl_test.cpp",
116 "sys_procfs_test.cpp",
117 "sys_ptrace_test.cpp",
118 "sys_quota_test.cpp",
119 "sys_resource_test.cpp",
120 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700121 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700122 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700123 "sys_shm_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700124 "sys_socket_test.cpp",
125 "sys_stat_test.cpp",
126 "sys_statvfs_test.cpp",
127 "sys_syscall_test.cpp",
128 "sys_sysinfo_test.cpp",
129 "sys_sysmacros_test.cpp",
130 "sys_time_test.cpp",
131 "sys_timex_test.cpp",
132 "sys_types_test.cpp",
133 "sys_uio_test.cpp",
134 "sys_vfs_test.cpp",
135 "sys_xattr_test.cpp",
136 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000137 "system_properties_test2.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700138 "time_test.cpp",
139 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700140 "unistd_nofortify_test.cpp",
141 "unistd_test.cpp",
142 "utmp_test.cpp",
143 "wchar_test.cpp",
144 "wctype_test.cpp",
145 ],
146
147 include_dirs: [
148 "bionic/libc",
149 "external/tinyxml2",
150 ],
151
Dan Willemsen41567702016-08-31 16:35:01 -0700152 static_libs: [
153 "libtinyxml2",
154 "liblog",
155 "libbase",
156 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700157 host_ldlibs: ["-lrt"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700158 shared: {
159 enabled: false,
160 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000161
162 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700163}
164
165// -----------------------------------------------------------------------------
166// Fortify tests.
167// -----------------------------------------------------------------------------
168
169cc_defaults {
170 name: "bionic_fortify_tests_defaults",
171 cflags: [
172 "-Wno-error",
173 "-U_FORTIFY_SOURCE",
174 ],
175 srcs: ["fortify_test_main.cpp"],
176 target: {
177 host: {
178 clang_cflags: ["-D__clang__"],
179 },
180 },
181}
182
183cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700184 name: "libfortify1-tests-clang",
185 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
186 clang: true,
187 cflags: [
188 "-D_FORTIFY_SOURCE=1",
189 "-DTEST_NAME=Fortify1_clang"
190 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700191 shared: {
192 enabled: false,
193 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700194}
195
196cc_test_library {
197 name: "libfortify2-tests-clang",
198 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
199 clang: true,
200 cflags: [
201 "-D_FORTIFY_SOURCE=2",
202 "-DTEST_NAME=Fortify2_clang"
203 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700204 shared: {
205 enabled: false,
206 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700207}
208
209// -----------------------------------------------------------------------------
210// Library of all tests (excluding the dynamic linker tests).
211// -----------------------------------------------------------------------------
212cc_test_library {
213 name: "libBionicTests",
214 defaults: ["bionic_tests_defaults"],
215 whole_static_libs: [
216 "libBionicStandardTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700217 "libfortify1-tests-clang",
218 "libfortify2-tests-clang",
219 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700220 shared: {
221 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700222 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700223}
224
225// -----------------------------------------------------------------------------
226// Library of bionic customized gtest main function, with simplified output format.
227// -----------------------------------------------------------------------------
228cc_test_library {
229 name: "libBionicGtestMain",
230 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700231 srcs: [
232 "gtest_main.cpp",
233 "gtest_globals.cpp",
234 ],
235 static_libs: [
236 "libbase",
237 ],
238 include_dirs: [
239 "bionic/libc",
240 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700241 target: {
242 darwin: {
243 enabled: true,
244 },
245 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700246 shared: {
247 enabled: false,
248 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700249}
250
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700251cc_test_library {
252 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800253 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700254 srcs: [
255 "atexit_test.cpp",
256 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700257 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700258 "dlfcn_test.cpp",
259 "pthread_dlfcn_test.cpp",
260 ],
261 static_libs: [
262 "libbase",
263 ],
264 include_dirs: [
265 "bionic/libc",
266 ],
267 shared: {
268 enabled: false,
269 },
270 target: {
271 android: {
272 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700273 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700274 "dlext_test.cpp",
275 "libdl_test.cpp",
276 ],
277 static_libs: [
278 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800279 "libLLVMObject",
280 "libLLVMBitReader",
281 "libLLVMMC",
282 "libLLVMMCParser",
283 "libLLVMCore",
284 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700285 ],
286 }
287 }
288}
289
Colin Cross2722ebb2016-07-11 16:20:06 -0700290// -----------------------------------------------------------------------------
291// Library of bionic customized gtest main function, with normal gtest output format,
292// which is needed by bionic cts test.
293// -----------------------------------------------------------------------------
294cc_test_library {
295 name: "libBionicCtsGtestMain",
296 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700297 srcs: [
298 "gtest_main.cpp",
299 "gtest_globals_cts.cpp",
300 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700301 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700302 shared: {
303 enabled: false,
304 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700305}
306
307// -----------------------------------------------------------------------------
308// Tests for the device using bionic's .so. Run with:
309// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
310// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
311// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
312// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
313// -----------------------------------------------------------------------------
314cc_defaults {
315 name: "bionic_unit_tests_defaults",
316 host_supported: false,
317
318 whole_static_libs: [
319 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700320 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700321 "libBionicGtestMain",
322 ],
323
324 static_libs: [
325 "libtinyxml2",
326 "liblog",
327 "libbase",
328 ],
329
330 srcs: [
331 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700332 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700333 "thread_local_test.cpp",
334 ],
335
336 conlyflags: [
337 "-fexceptions",
338 "-fnon-call-exceptions",
339 ],
340
341 ldflags: ["-Wl,--export-dynamic"],
342
343 include_dirs: ["bionic/libc"],
344
Yabin Cui1f553ea2017-01-13 12:31:59 -0800345 stl: "libc++_static",
346
Colin Cross2722ebb2016-07-11 16:20:06 -0700347 target: {
348 android: {
349 shared_libs: [
350 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700351 "libdl_preempt_test_1",
352 "libdl_preempt_test_2",
353 "libdl_test_df_1_global",
354 ],
355 static_libs: [
356 // The order of these libraries matters, do not shuffle them.
357 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700358 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700359 "libziparchive",
360 "libz",
361 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800362 "libLLVMObject",
363 "libLLVMBitReader",
364 "libLLVMMC",
365 "libLLVMMCParser",
366 "libLLVMCore",
367 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700368 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700369 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700370 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700371 "-Wl,--enable-new-dtags",
372 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700373 },
374 }
375}
376
377cc_test {
378 name: "bionic-unit-tests",
379 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
380 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800381
382 target: {
383 android: {
384 shared_libs: ["libicuuc"],
385 },
386 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700387
388 required: [
389 "cfi_test_helper",
390 "cfi_test_helper2",
391 "libtest_dt_runpath_a",
392 "libtest_dt_runpath_b",
393 "libtest_dt_runpath_c",
394 "libtest_dt_runpath_x",
395 "libatest_simple_zip",
396 "libcfi-test",
397 "libcfi-test-bad",
398 "libdlext_test_different_soname",
399 "libdlext_test_fd",
400 "libdlext_test_norelro",
401 "libdlext_test_runpath_zip_zipaligned",
402 "libdlext_test",
403 "libdlext_test_zip",
404 "libdlext_test_zip_zipaligned",
405 "libdl_preempt_test_1",
406 "libdl_preempt_test_2",
407 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700408 "libgnu-hash-table-library",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700409 "libsysv-hash-table-library",
410 "libtest_atexit",
411 "libtest_check_order_dlsym_1_left",
412 "libtest_check_order_dlsym_2_right",
413 "libtest_check_order_dlsym_3_c",
414 "libtest_check_order_dlsym_a",
415 "libtest_check_order_dlsym_b",
416 "libtest_check_order_dlsym_d",
417 "libtest_check_order_dlsym",
418 "libtest_check_order_reloc_root_1",
419 "libtest_check_order_reloc_root_2",
420 "libtest_check_order_reloc_root",
421 "libtest_check_order_reloc_siblings_1",
422 "libtest_check_order_reloc_siblings_2",
423 "libtest_check_order_reloc_siblings_3",
424 "libtest_check_order_reloc_siblings_a",
425 "libtest_check_order_reloc_siblings_b",
426 "libtest_check_order_reloc_siblings_c_1",
427 "libtest_check_order_reloc_siblings_c_2",
428 "libtest_check_order_reloc_siblings_c",
429 "libtest_check_order_reloc_siblings_d",
430 "libtest_check_order_reloc_siblings_e",
431 "libtest_check_order_reloc_siblings_f",
432 "libtest_check_order_reloc_siblings",
433 "libtest_check_rtld_next_from_library",
434 "libtest_dlopen_from_ctor_main",
435 "libtest_dlopen_from_ctor",
436 "libtest_dlopen_weak_undefined_func",
437 "libtest_dlsym_df_1_global",
438 "libtest_dlsym_from_this_child",
439 "libtest_dlsym_from_this_grandchild",
440 "libtest_dlsym_from_this",
441 "libtest_dlsym_weak_func",
442 "libtest_dt_runpath_d",
443 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700444 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700445 "libtest_init_fini_order_child",
446 "libtest_init_fini_order_grand_child",
447 "libtest_init_fini_order_root2",
448 "libtest_init_fini_order_root",
449 "libtest_nodelete_1",
450 "libtest_nodelete_2",
451 "libtest_nodelete_dt_flags_1",
452 "libtest_pthread_atfork",
453 "libtest_relo_check_dt_needed_order_1",
454 "libtest_relo_check_dt_needed_order_2",
455 "libtest_relo_check_dt_needed_order",
456 "libtest_simple",
457 "libtest_two_parents_child",
458 "libtest_two_parents_parent1",
459 "libtest_two_parents_parent2",
460 "libtest_versioned_lib",
461 "libtest_versioned_libv1",
462 "libtest_versioned_libv2",
463 "libtest_versioned_otherlib_empty",
464 "libtest_versioned_otherlib",
465 "libtest_versioned_uselibv1",
466 "libtest_versioned_uselibv2_other",
467 "libtest_versioned_uselibv2",
468 "libtest_versioned_uselibv3_other",
469 "libtest_with_dependency_loop_a",
470 "libtest_with_dependency_loop_b",
471 "libtest_with_dependency_loop_c",
472 "libtest_with_dependency_loop",
473 "libtest_with_dependency",
474 "libtest_invalid-empty_shdr_table.so",
475 "libtest_invalid-rw_load_segment.so",
476 "libtest_invalid-unaligned_shdr_offset.so",
477 "libtest_invalid-zero_shdr_table_content.so",
478 "libtest_invalid-zero_shdr_table_offset.so",
479 "libtest_invalid-zero_shentsize.so",
480 "libtest_invalid-zero_shstrndx.so",
481 "libtest_invalid-textrels.so",
482 "libtest_invalid-textrels2.so",
483 "preinit_getauxval_test_helper",
484 "preinit_syscall_test_helper",
485 "libnstest_private_external",
486 "libnstest_dlopened",
487 "libnstest_private",
488 "libnstest_root_not_isolated",
489 "libnstest_root",
490 "libnstest_public",
491 "libnstest_public_internal",
492 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700493}
494
Colin Cross2722ebb2016-07-11 16:20:06 -0700495// -----------------------------------------------------------------------------
496// Tests for the device linked against bionic's static library. Run with:
497// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
498// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
499// -----------------------------------------------------------------------------
500cc_test {
501 name: "bionic-unit-tests-static",
502 defaults: ["bionic_tests_defaults"],
503 host_supported: false,
504
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800505 srcs: [
506 "gtest_preinit_debuggerd.cpp",
507 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700508 whole_static_libs: [
509 "libBionicTests",
510 "libBionicGtestMain",
511 ],
512
513 static_libs: [
514 "libm",
515 "libc",
516 "libc++_static",
517 "libdl",
518 "libtinyxml2",
519 "liblog",
520 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700521 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700522 ],
523
524 static_executable: true,
525 stl: "libc++_static",
526
527 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
528 // still causes issues when linking libc.a and libc++.a, since private isn't
529 // effective until it has been linked. To fix this, just allow multiple symbol
530 // definitions for the static tests.
531 ldflags: ["-Wl,--allow-multiple-definition"],
532}
533
534// -----------------------------------------------------------------------------
535// Tests to run on the host and linked against glibc. Run with:
536// cd bionic/tests; mm bionic-unit-tests-glibc-run
537// -----------------------------------------------------------------------------
538
539cc_test_host {
540 name: "bionic-unit-tests-glibc",
541 defaults: ["bionic_tests_defaults"],
542
543 srcs: [
544 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700545 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700546 "dlfcn_test.cpp",
547 "dl_test.cpp",
548 "pthread_dlfcn_test.cpp",
549 ],
550
551 shared_libs: [
552 "libdl_preempt_test_1",
553 "libdl_preempt_test_2",
554
555 "libdl_test_df_1_global",
556 ],
557
558 whole_static_libs: [
559 "libBionicStandardTests",
560 "libBionicGtestMain",
Colin Cross2722ebb2016-07-11 16:20:06 -0700561 "libfortify1-tests-clang",
562 "libfortify2-tests-clang",
563 ],
564
565 static_libs: [
566 "libbase",
567 "liblog",
568 "libcutils",
569 ],
570
571 host_ldlibs: [
572 "-lresolv",
573 "-lrt",
574 "-ldl",
575 "-lutil",
576 ],
577
578 include_dirs: ["bionic/libc"],
579
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800580 ldflags: [
581 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
582 "-Wl,--export-dynamic",
583 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700584
585 sanitize: {
586 never: false,
587 },
588}
589
590subdirs = ["libs"]