blob: d4e3800fd89e93f10271c28c8aaec446ffb870e6 [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 Hughesd390df12017-04-30 22:56:10 -070061 "elf_test.cpp",
Elliott Hughesba267f42017-02-24 16:19:53 -080062 "endian_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070063 "error_test.cpp",
64 "eventfd_test.cpp",
65 "fcntl_test.cpp",
66 "fenv_test.cpp",
67 "ftw_test.cpp",
68 "getauxval_test.cpp",
69 "getcwd_test.cpp",
70 "grp_pwd_test.cpp",
71 "ifaddrs_test.cpp",
72 "inttypes_test.cpp",
Elliott Hughesfc8e6882016-11-18 16:27:29 -080073 "langinfo_test.cpp",
Josh Gao7d15dc32017-03-13 17:10:46 -070074 "leak_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070075 "libc_logging_test.cpp",
76 "libgen_basename_test.cpp",
77 "libgen_test.cpp",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -070078 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070079 "locale_test.cpp",
80 "malloc_test.cpp",
81 "math_test.cpp",
82 "mntent_test.cpp",
83 "netdb_test.cpp",
84 "net_if_test.cpp",
85 "netinet_ether_test.cpp",
86 "netinet_in_test.cpp",
87 "netinet_udp_test.cpp",
88 "nl_types_test.cpp",
89 "pthread_test.cpp",
90 "pty_test.cpp",
91 "regex_test.cpp",
92 "resolv_test.cpp",
93 "sched_test.cpp",
94 "search_test.cpp",
95 "semaphore_test.cpp",
96 "setjmp_test.cpp",
97 "signal_test.cpp",
98 "stack_protector_test.cpp",
99 "stack_protector_test_helper.cpp",
100 "stack_unwinding_test.cpp",
101 "stdatomic_test.cpp",
102 "stdint_test.cpp",
103 "stdio_nofortify_test.cpp",
104 "stdio_test.cpp",
105 "stdio_ext_test.cpp",
106 "stdlib_test.cpp",
107 "string_nofortify_test.cpp",
108 "string_test.cpp",
109 "string_posix_strerror_r_test.cpp",
110 "strings_nofortify_test.cpp",
111 "strings_test.cpp",
112 "sstream_test.cpp",
113 "sys_epoll_test.cpp",
114 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700115 "sys_msg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700116 "sys_personality_test.cpp",
117 "sys_prctl_test.cpp",
118 "sys_procfs_test.cpp",
119 "sys_ptrace_test.cpp",
120 "sys_quota_test.cpp",
121 "sys_resource_test.cpp",
122 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700123 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700124 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700125 "sys_shm_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700126 "sys_socket_test.cpp",
127 "sys_stat_test.cpp",
128 "sys_statvfs_test.cpp",
129 "sys_syscall_test.cpp",
130 "sys_sysinfo_test.cpp",
131 "sys_sysmacros_test.cpp",
132 "sys_time_test.cpp",
133 "sys_timex_test.cpp",
134 "sys_types_test.cpp",
135 "sys_uio_test.cpp",
136 "sys_vfs_test.cpp",
137 "sys_xattr_test.cpp",
138 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000139 "system_properties_test2.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700140 "time_test.cpp",
141 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700142 "unistd_nofortify_test.cpp",
143 "unistd_test.cpp",
144 "utmp_test.cpp",
145 "wchar_test.cpp",
146 "wctype_test.cpp",
147 ],
148
149 include_dirs: [
150 "bionic/libc",
151 "external/tinyxml2",
152 ],
153
Dan Willemsen41567702016-08-31 16:35:01 -0700154 static_libs: [
155 "libtinyxml2",
156 "liblog",
157 "libbase",
158 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700159 host_ldlibs: ["-lrt"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700160 shared: {
161 enabled: false,
162 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000163
164 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700165}
166
167// -----------------------------------------------------------------------------
168// Fortify tests.
169// -----------------------------------------------------------------------------
170
171cc_defaults {
172 name: "bionic_fortify_tests_defaults",
173 cflags: [
174 "-Wno-error",
175 "-U_FORTIFY_SOURCE",
176 ],
177 srcs: ["fortify_test_main.cpp"],
178 target: {
179 host: {
180 clang_cflags: ["-D__clang__"],
181 },
182 },
183}
184
185cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700186 name: "libfortify1-tests-clang",
187 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
188 clang: true,
189 cflags: [
190 "-D_FORTIFY_SOURCE=1",
191 "-DTEST_NAME=Fortify1_clang"
192 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700193 shared: {
194 enabled: false,
195 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700196}
197
198cc_test_library {
199 name: "libfortify2-tests-clang",
200 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
201 clang: true,
202 cflags: [
203 "-D_FORTIFY_SOURCE=2",
204 "-DTEST_NAME=Fortify2_clang"
205 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700206 shared: {
207 enabled: false,
208 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700209}
210
211// -----------------------------------------------------------------------------
212// Library of all tests (excluding the dynamic linker tests).
213// -----------------------------------------------------------------------------
214cc_test_library {
215 name: "libBionicTests",
216 defaults: ["bionic_tests_defaults"],
217 whole_static_libs: [
218 "libBionicStandardTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700219 "libfortify1-tests-clang",
220 "libfortify2-tests-clang",
221 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700222 shared: {
223 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700224 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700225}
226
227// -----------------------------------------------------------------------------
228// Library of bionic customized gtest main function, with simplified output format.
229// -----------------------------------------------------------------------------
230cc_test_library {
231 name: "libBionicGtestMain",
232 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700233 srcs: [
234 "gtest_main.cpp",
235 "gtest_globals.cpp",
236 ],
237 static_libs: [
238 "libbase",
239 ],
240 include_dirs: [
241 "bionic/libc",
242 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700243 target: {
244 darwin: {
245 enabled: true,
246 },
247 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700248 shared: {
249 enabled: false,
250 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700251}
252
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700253cc_test_library {
254 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800255 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700256 srcs: [
257 "atexit_test.cpp",
258 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700259 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700260 "dlfcn_test.cpp",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700261 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700262 "pthread_dlfcn_test.cpp",
263 ],
264 static_libs: [
265 "libbase",
266 ],
267 include_dirs: [
268 "bionic/libc",
269 ],
270 shared: {
271 enabled: false,
272 },
273 target: {
274 android: {
275 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700276 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700277 "dlext_test.cpp",
278 "libdl_test.cpp",
279 ],
280 static_libs: [
281 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800282 "libLLVMObject",
283 "libLLVMBitReader",
284 "libLLVMMC",
285 "libLLVMMCParser",
286 "libLLVMCore",
287 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700288 ],
289 }
290 }
291}
292
Colin Cross2722ebb2016-07-11 16:20:06 -0700293// -----------------------------------------------------------------------------
294// Library of bionic customized gtest main function, with normal gtest output format,
295// which is needed by bionic cts test.
296// -----------------------------------------------------------------------------
297cc_test_library {
298 name: "libBionicCtsGtestMain",
299 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700300 srcs: [
301 "gtest_main.cpp",
302 "gtest_globals_cts.cpp",
303 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700304 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700305 shared: {
306 enabled: false,
307 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700308}
309
310// -----------------------------------------------------------------------------
311// Tests for the device using bionic's .so. Run with:
312// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
313// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
314// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
315// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
316// -----------------------------------------------------------------------------
317cc_defaults {
318 name: "bionic_unit_tests_defaults",
319 host_supported: false,
320
321 whole_static_libs: [
322 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700323 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700324 "libBionicGtestMain",
325 ],
326
327 static_libs: [
328 "libtinyxml2",
329 "liblog",
330 "libbase",
331 ],
332
333 srcs: [
334 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700335 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700336 "thread_local_test.cpp",
337 ],
338
339 conlyflags: [
340 "-fexceptions",
341 "-fnon-call-exceptions",
342 ],
343
344 ldflags: ["-Wl,--export-dynamic"],
345
346 include_dirs: ["bionic/libc"],
347
Yabin Cui1f553ea2017-01-13 12:31:59 -0800348 stl: "libc++_static",
349
Colin Cross2722ebb2016-07-11 16:20:06 -0700350 target: {
351 android: {
352 shared_libs: [
353 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700354 "libdl_preempt_test_1",
355 "libdl_preempt_test_2",
356 "libdl_test_df_1_global",
357 ],
358 static_libs: [
359 // The order of these libraries matters, do not shuffle them.
360 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700361 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700362 "libziparchive",
363 "libz",
364 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800365 "libLLVMObject",
366 "libLLVMBitReader",
367 "libLLVMMC",
368 "libLLVMMCParser",
369 "libLLVMCore",
370 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700371 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700372 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700373 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700374 "-Wl,--enable-new-dtags",
375 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700376 },
377 }
378}
379
380cc_test {
381 name: "bionic-unit-tests",
382 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
383 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800384
385 target: {
386 android: {
387 shared_libs: ["libicuuc"],
388 },
389 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700390
391 required: [
392 "cfi_test_helper",
393 "cfi_test_helper2",
394 "libtest_dt_runpath_a",
395 "libtest_dt_runpath_b",
396 "libtest_dt_runpath_c",
397 "libtest_dt_runpath_x",
398 "libatest_simple_zip",
399 "libcfi-test",
400 "libcfi-test-bad",
401 "libdlext_test_different_soname",
402 "libdlext_test_fd",
403 "libdlext_test_norelro",
404 "libdlext_test_runpath_zip_zipaligned",
405 "libdlext_test",
406 "libdlext_test_zip",
407 "libdlext_test_zip_zipaligned",
408 "libdl_preempt_test_1",
409 "libdl_preempt_test_2",
410 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700411 "libgnu-hash-table-library",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700412 "libsysv-hash-table-library",
413 "libtest_atexit",
414 "libtest_check_order_dlsym_1_left",
415 "libtest_check_order_dlsym_2_right",
416 "libtest_check_order_dlsym_3_c",
417 "libtest_check_order_dlsym_a",
418 "libtest_check_order_dlsym_b",
419 "libtest_check_order_dlsym_d",
420 "libtest_check_order_dlsym",
421 "libtest_check_order_reloc_root_1",
422 "libtest_check_order_reloc_root_2",
423 "libtest_check_order_reloc_root",
424 "libtest_check_order_reloc_siblings_1",
425 "libtest_check_order_reloc_siblings_2",
426 "libtest_check_order_reloc_siblings_3",
427 "libtest_check_order_reloc_siblings_a",
428 "libtest_check_order_reloc_siblings_b",
429 "libtest_check_order_reloc_siblings_c_1",
430 "libtest_check_order_reloc_siblings_c_2",
431 "libtest_check_order_reloc_siblings_c",
432 "libtest_check_order_reloc_siblings_d",
433 "libtest_check_order_reloc_siblings_e",
434 "libtest_check_order_reloc_siblings_f",
435 "libtest_check_order_reloc_siblings",
436 "libtest_check_rtld_next_from_library",
437 "libtest_dlopen_from_ctor_main",
438 "libtest_dlopen_from_ctor",
439 "libtest_dlopen_weak_undefined_func",
440 "libtest_dlsym_df_1_global",
441 "libtest_dlsym_from_this_child",
442 "libtest_dlsym_from_this_grandchild",
443 "libtest_dlsym_from_this",
444 "libtest_dlsym_weak_func",
445 "libtest_dt_runpath_d",
446 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700447 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700448 "libtest_init_fini_order_child",
449 "libtest_init_fini_order_grand_child",
450 "libtest_init_fini_order_root2",
451 "libtest_init_fini_order_root",
452 "libtest_nodelete_1",
453 "libtest_nodelete_2",
454 "libtest_nodelete_dt_flags_1",
455 "libtest_pthread_atfork",
456 "libtest_relo_check_dt_needed_order_1",
457 "libtest_relo_check_dt_needed_order_2",
458 "libtest_relo_check_dt_needed_order",
459 "libtest_simple",
460 "libtest_two_parents_child",
461 "libtest_two_parents_parent1",
462 "libtest_two_parents_parent2",
463 "libtest_versioned_lib",
464 "libtest_versioned_libv1",
465 "libtest_versioned_libv2",
466 "libtest_versioned_otherlib_empty",
467 "libtest_versioned_otherlib",
468 "libtest_versioned_uselibv1",
469 "libtest_versioned_uselibv2_other",
470 "libtest_versioned_uselibv2",
471 "libtest_versioned_uselibv3_other",
472 "libtest_with_dependency_loop_a",
473 "libtest_with_dependency_loop_b",
474 "libtest_with_dependency_loop_c",
475 "libtest_with_dependency_loop",
476 "libtest_with_dependency",
477 "libtest_invalid-empty_shdr_table.so",
478 "libtest_invalid-rw_load_segment.so",
479 "libtest_invalid-unaligned_shdr_offset.so",
480 "libtest_invalid-zero_shdr_table_content.so",
481 "libtest_invalid-zero_shdr_table_offset.so",
482 "libtest_invalid-zero_shentsize.so",
483 "libtest_invalid-zero_shstrndx.so",
484 "libtest_invalid-textrels.so",
485 "libtest_invalid-textrels2.so",
486 "preinit_getauxval_test_helper",
487 "preinit_syscall_test_helper",
488 "libnstest_private_external",
489 "libnstest_dlopened",
490 "libnstest_private",
491 "libnstest_root_not_isolated",
492 "libnstest_root",
493 "libnstest_public",
494 "libnstest_public_internal",
495 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700496}
497
Colin Cross2722ebb2016-07-11 16:20:06 -0700498// -----------------------------------------------------------------------------
499// Tests for the device linked against bionic's static library. Run with:
500// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
501// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
502// -----------------------------------------------------------------------------
503cc_test {
504 name: "bionic-unit-tests-static",
505 defaults: ["bionic_tests_defaults"],
506 host_supported: false,
507
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800508 srcs: [
509 "gtest_preinit_debuggerd.cpp",
510 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700511 whole_static_libs: [
512 "libBionicTests",
513 "libBionicGtestMain",
514 ],
515
516 static_libs: [
517 "libm",
518 "libc",
519 "libc++_static",
520 "libdl",
521 "libtinyxml2",
522 "liblog",
523 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700524 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700525 ],
526
527 static_executable: true,
528 stl: "libc++_static",
529
530 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
531 // still causes issues when linking libc.a and libc++.a, since private isn't
532 // effective until it has been linked. To fix this, just allow multiple symbol
533 // definitions for the static tests.
534 ldflags: ["-Wl,--allow-multiple-definition"],
535}
536
537// -----------------------------------------------------------------------------
538// Tests to run on the host and linked against glibc. Run with:
539// cd bionic/tests; mm bionic-unit-tests-glibc-run
540// -----------------------------------------------------------------------------
541
542cc_test_host {
543 name: "bionic-unit-tests-glibc",
544 defaults: ["bionic_tests_defaults"],
545
546 srcs: [
547 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700548 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700549 "dlfcn_test.cpp",
550 "dl_test.cpp",
551 "pthread_dlfcn_test.cpp",
552 ],
553
554 shared_libs: [
555 "libdl_preempt_test_1",
556 "libdl_preempt_test_2",
557
558 "libdl_test_df_1_global",
559 ],
560
561 whole_static_libs: [
562 "libBionicStandardTests",
563 "libBionicGtestMain",
Colin Cross2722ebb2016-07-11 16:20:06 -0700564 "libfortify1-tests-clang",
565 "libfortify2-tests-clang",
566 ],
567
568 static_libs: [
569 "libbase",
570 "liblog",
571 "libcutils",
572 ],
573
574 host_ldlibs: [
575 "-lresolv",
576 "-lrt",
577 "-ldl",
578 "-lutil",
579 ],
580
581 include_dirs: ["bionic/libc"],
582
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800583 ldflags: [
584 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
585 "-Wl,--export-dynamic",
586 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700587
588 sanitize: {
589 never: false,
590 },
591}
592
593subdirs = ["libs"]