blob: a22b0ba7fbcd465b26e9d25c91cc46ba5197da0e [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",
Christopher Ferrisee1e0a32017-04-20 13:38:49 -070077 "linux_swab_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -070078 "locale_test.cpp",
79 "malloc_test.cpp",
80 "math_test.cpp",
81 "mntent_test.cpp",
82 "netdb_test.cpp",
83 "net_if_test.cpp",
84 "netinet_ether_test.cpp",
85 "netinet_in_test.cpp",
86 "netinet_udp_test.cpp",
87 "nl_types_test.cpp",
88 "pthread_test.cpp",
89 "pty_test.cpp",
90 "regex_test.cpp",
91 "resolv_test.cpp",
92 "sched_test.cpp",
93 "search_test.cpp",
94 "semaphore_test.cpp",
95 "setjmp_test.cpp",
96 "signal_test.cpp",
97 "stack_protector_test.cpp",
98 "stack_protector_test_helper.cpp",
99 "stack_unwinding_test.cpp",
100 "stdatomic_test.cpp",
101 "stdint_test.cpp",
102 "stdio_nofortify_test.cpp",
103 "stdio_test.cpp",
104 "stdio_ext_test.cpp",
105 "stdlib_test.cpp",
106 "string_nofortify_test.cpp",
107 "string_test.cpp",
108 "string_posix_strerror_r_test.cpp",
109 "strings_nofortify_test.cpp",
110 "strings_test.cpp",
111 "sstream_test.cpp",
112 "sys_epoll_test.cpp",
113 "sys_mman_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700114 "sys_msg_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700115 "sys_personality_test.cpp",
116 "sys_prctl_test.cpp",
117 "sys_procfs_test.cpp",
118 "sys_ptrace_test.cpp",
119 "sys_quota_test.cpp",
120 "sys_resource_test.cpp",
121 "sys_select_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700122 "sys_sem_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700123 "sys_sendfile_test.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -0700124 "sys_shm_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700125 "sys_socket_test.cpp",
126 "sys_stat_test.cpp",
127 "sys_statvfs_test.cpp",
128 "sys_syscall_test.cpp",
129 "sys_sysinfo_test.cpp",
130 "sys_sysmacros_test.cpp",
131 "sys_time_test.cpp",
132 "sys_timex_test.cpp",
133 "sys_types_test.cpp",
134 "sys_uio_test.cpp",
135 "sys_vfs_test.cpp",
136 "sys_xattr_test.cpp",
137 "system_properties_test.cpp",
Dimitry Ivanov16b2a4d2017-01-24 20:43:29 +0000138 "system_properties_test2.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700139 "time_test.cpp",
140 "uchar_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700141 "unistd_nofortify_test.cpp",
142 "unistd_test.cpp",
143 "utmp_test.cpp",
144 "wchar_test.cpp",
145 "wctype_test.cpp",
146 ],
147
148 include_dirs: [
149 "bionic/libc",
150 "external/tinyxml2",
151 ],
152
Dan Willemsen41567702016-08-31 16:35:01 -0700153 static_libs: [
154 "libtinyxml2",
155 "liblog",
156 "libbase",
157 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700158 host_ldlibs: ["-lrt"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700159 shared: {
160 enabled: false,
161 },
Elliott Hughes3f6eee92016-12-13 23:47:25 +0000162
163 generated_headers: ["generated_android_ids"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700164}
165
166// -----------------------------------------------------------------------------
167// Fortify tests.
168// -----------------------------------------------------------------------------
169
170cc_defaults {
171 name: "bionic_fortify_tests_defaults",
172 cflags: [
173 "-Wno-error",
174 "-U_FORTIFY_SOURCE",
175 ],
176 srcs: ["fortify_test_main.cpp"],
177 target: {
178 host: {
179 clang_cflags: ["-D__clang__"],
180 },
181 },
182}
183
184cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700185 name: "libfortify1-tests-clang",
186 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
187 clang: true,
188 cflags: [
189 "-D_FORTIFY_SOURCE=1",
190 "-DTEST_NAME=Fortify1_clang"
191 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700192 shared: {
193 enabled: false,
194 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700195}
196
197cc_test_library {
198 name: "libfortify2-tests-clang",
199 defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
200 clang: true,
201 cflags: [
202 "-D_FORTIFY_SOURCE=2",
203 "-DTEST_NAME=Fortify2_clang"
204 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700205 shared: {
206 enabled: false,
207 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700208}
209
210// -----------------------------------------------------------------------------
211// Library of all tests (excluding the dynamic linker tests).
212// -----------------------------------------------------------------------------
213cc_test_library {
214 name: "libBionicTests",
215 defaults: ["bionic_tests_defaults"],
216 whole_static_libs: [
217 "libBionicStandardTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700218 "libfortify1-tests-clang",
219 "libfortify2-tests-clang",
220 ],
Dan Willemsen41567702016-08-31 16:35:01 -0700221 shared: {
222 enabled: false,
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700223 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700224}
225
226// -----------------------------------------------------------------------------
227// Library of bionic customized gtest main function, with simplified output format.
228// -----------------------------------------------------------------------------
229cc_test_library {
230 name: "libBionicGtestMain",
231 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700232 srcs: [
233 "gtest_main.cpp",
234 "gtest_globals.cpp",
235 ],
236 static_libs: [
237 "libbase",
238 ],
239 include_dirs: [
240 "bionic/libc",
241 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700242 target: {
243 darwin: {
244 enabled: true,
245 },
246 },
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700247 shared: {
248 enabled: false,
249 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700250}
251
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700252cc_test_library {
253 name: "libBionicLoaderTests",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800254 defaults: ["bionic_tests_defaults", "llvm-defaults"],
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700255 srcs: [
256 "atexit_test.cpp",
257 "dl_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700258 "dlfcn_symlink_support.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700259 "dlfcn_test.cpp",
260 "pthread_dlfcn_test.cpp",
261 ],
262 static_libs: [
263 "libbase",
264 ],
265 include_dirs: [
266 "bionic/libc",
267 ],
268 shared: {
269 enabled: false,
270 },
271 target: {
272 android: {
273 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700274 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700275 "dlext_test.cpp",
276 "libdl_test.cpp",
277 ],
278 static_libs: [
279 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800280 "libLLVMObject",
281 "libLLVMBitReader",
282 "libLLVMMC",
283 "libLLVMMCParser",
284 "libLLVMCore",
285 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700286 ],
287 }
288 }
289}
290
Colin Cross2722ebb2016-07-11 16:20:06 -0700291// -----------------------------------------------------------------------------
292// Library of bionic customized gtest main function, with normal gtest output format,
293// which is needed by bionic cts test.
294// -----------------------------------------------------------------------------
295cc_test_library {
296 name: "libBionicCtsGtestMain",
297 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700298 srcs: [
299 "gtest_main.cpp",
300 "gtest_globals_cts.cpp",
301 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700302 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700303 shared: {
304 enabled: false,
305 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700306}
307
308// -----------------------------------------------------------------------------
309// Tests for the device using bionic's .so. Run with:
310// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
311// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
312// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
313// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
314// -----------------------------------------------------------------------------
315cc_defaults {
316 name: "bionic_unit_tests_defaults",
317 host_supported: false,
318
319 whole_static_libs: [
320 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700321 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700322 "libBionicGtestMain",
323 ],
324
325 static_libs: [
326 "libtinyxml2",
327 "liblog",
328 "libbase",
329 ],
330
331 srcs: [
332 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700333 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700334 "thread_local_test.cpp",
335 ],
336
337 conlyflags: [
338 "-fexceptions",
339 "-fnon-call-exceptions",
340 ],
341
342 ldflags: ["-Wl,--export-dynamic"],
343
344 include_dirs: ["bionic/libc"],
345
Yabin Cui1f553ea2017-01-13 12:31:59 -0800346 stl: "libc++_static",
347
Colin Cross2722ebb2016-07-11 16:20:06 -0700348 target: {
349 android: {
350 shared_libs: [
351 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700352 "libdl_preempt_test_1",
353 "libdl_preempt_test_2",
354 "libdl_test_df_1_global",
355 ],
356 static_libs: [
357 // The order of these libraries matters, do not shuffle them.
358 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700359 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700360 "libziparchive",
361 "libz",
362 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800363 "libLLVMObject",
364 "libLLVMBitReader",
365 "libLLVMMC",
366 "libLLVMMCParser",
367 "libLLVMCore",
368 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700369 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700370 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700371 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700372 "-Wl,--enable-new-dtags",
373 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700374 },
375 }
376}
377
378cc_test {
379 name: "bionic-unit-tests",
380 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
381 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800382
383 target: {
384 android: {
385 shared_libs: ["libicuuc"],
386 },
387 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700388
389 required: [
390 "cfi_test_helper",
391 "cfi_test_helper2",
392 "libtest_dt_runpath_a",
393 "libtest_dt_runpath_b",
394 "libtest_dt_runpath_c",
395 "libtest_dt_runpath_x",
396 "libatest_simple_zip",
397 "libcfi-test",
398 "libcfi-test-bad",
399 "libdlext_test_different_soname",
400 "libdlext_test_fd",
401 "libdlext_test_norelro",
402 "libdlext_test_runpath_zip_zipaligned",
403 "libdlext_test",
404 "libdlext_test_zip",
405 "libdlext_test_zip_zipaligned",
406 "libdl_preempt_test_1",
407 "libdl_preempt_test_2",
408 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700409 "libgnu-hash-table-library",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700410 "libsysv-hash-table-library",
411 "libtest_atexit",
412 "libtest_check_order_dlsym_1_left",
413 "libtest_check_order_dlsym_2_right",
414 "libtest_check_order_dlsym_3_c",
415 "libtest_check_order_dlsym_a",
416 "libtest_check_order_dlsym_b",
417 "libtest_check_order_dlsym_d",
418 "libtest_check_order_dlsym",
419 "libtest_check_order_reloc_root_1",
420 "libtest_check_order_reloc_root_2",
421 "libtest_check_order_reloc_root",
422 "libtest_check_order_reloc_siblings_1",
423 "libtest_check_order_reloc_siblings_2",
424 "libtest_check_order_reloc_siblings_3",
425 "libtest_check_order_reloc_siblings_a",
426 "libtest_check_order_reloc_siblings_b",
427 "libtest_check_order_reloc_siblings_c_1",
428 "libtest_check_order_reloc_siblings_c_2",
429 "libtest_check_order_reloc_siblings_c",
430 "libtest_check_order_reloc_siblings_d",
431 "libtest_check_order_reloc_siblings_e",
432 "libtest_check_order_reloc_siblings_f",
433 "libtest_check_order_reloc_siblings",
434 "libtest_check_rtld_next_from_library",
435 "libtest_dlopen_from_ctor_main",
436 "libtest_dlopen_from_ctor",
437 "libtest_dlopen_weak_undefined_func",
438 "libtest_dlsym_df_1_global",
439 "libtest_dlsym_from_this_child",
440 "libtest_dlsym_from_this_grandchild",
441 "libtest_dlsym_from_this",
442 "libtest_dlsym_weak_func",
443 "libtest_dt_runpath_d",
444 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700445 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700446 "libtest_init_fini_order_child",
447 "libtest_init_fini_order_grand_child",
448 "libtest_init_fini_order_root2",
449 "libtest_init_fini_order_root",
450 "libtest_nodelete_1",
451 "libtest_nodelete_2",
452 "libtest_nodelete_dt_flags_1",
453 "libtest_pthread_atfork",
454 "libtest_relo_check_dt_needed_order_1",
455 "libtest_relo_check_dt_needed_order_2",
456 "libtest_relo_check_dt_needed_order",
457 "libtest_simple",
458 "libtest_two_parents_child",
459 "libtest_two_parents_parent1",
460 "libtest_two_parents_parent2",
461 "libtest_versioned_lib",
462 "libtest_versioned_libv1",
463 "libtest_versioned_libv2",
464 "libtest_versioned_otherlib_empty",
465 "libtest_versioned_otherlib",
466 "libtest_versioned_uselibv1",
467 "libtest_versioned_uselibv2_other",
468 "libtest_versioned_uselibv2",
469 "libtest_versioned_uselibv3_other",
470 "libtest_with_dependency_loop_a",
471 "libtest_with_dependency_loop_b",
472 "libtest_with_dependency_loop_c",
473 "libtest_with_dependency_loop",
474 "libtest_with_dependency",
475 "libtest_invalid-empty_shdr_table.so",
476 "libtest_invalid-rw_load_segment.so",
477 "libtest_invalid-unaligned_shdr_offset.so",
478 "libtest_invalid-zero_shdr_table_content.so",
479 "libtest_invalid-zero_shdr_table_offset.so",
480 "libtest_invalid-zero_shentsize.so",
481 "libtest_invalid-zero_shstrndx.so",
482 "libtest_invalid-textrels.so",
483 "libtest_invalid-textrels2.so",
484 "preinit_getauxval_test_helper",
485 "preinit_syscall_test_helper",
486 "libnstest_private_external",
487 "libnstest_dlopened",
488 "libnstest_private",
489 "libnstest_root_not_isolated",
490 "libnstest_root",
491 "libnstest_public",
492 "libnstest_public_internal",
493 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700494}
495
Colin Cross2722ebb2016-07-11 16:20:06 -0700496// -----------------------------------------------------------------------------
497// Tests for the device linked against bionic's static library. Run with:
498// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
499// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
500// -----------------------------------------------------------------------------
501cc_test {
502 name: "bionic-unit-tests-static",
503 defaults: ["bionic_tests_defaults"],
504 host_supported: false,
505
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800506 srcs: [
507 "gtest_preinit_debuggerd.cpp",
508 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700509 whole_static_libs: [
510 "libBionicTests",
511 "libBionicGtestMain",
512 ],
513
514 static_libs: [
515 "libm",
516 "libc",
517 "libc++_static",
518 "libdl",
519 "libtinyxml2",
520 "liblog",
521 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700522 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700523 ],
524
525 static_executable: true,
526 stl: "libc++_static",
527
528 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
529 // still causes issues when linking libc.a and libc++.a, since private isn't
530 // effective until it has been linked. To fix this, just allow multiple symbol
531 // definitions for the static tests.
532 ldflags: ["-Wl,--allow-multiple-definition"],
533}
534
535// -----------------------------------------------------------------------------
536// Tests to run on the host and linked against glibc. Run with:
537// cd bionic/tests; mm bionic-unit-tests-glibc-run
538// -----------------------------------------------------------------------------
539
540cc_test_host {
541 name: "bionic-unit-tests-glibc",
542 defaults: ["bionic_tests_defaults"],
543
544 srcs: [
545 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700546 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700547 "dlfcn_test.cpp",
548 "dl_test.cpp",
549 "pthread_dlfcn_test.cpp",
550 ],
551
552 shared_libs: [
553 "libdl_preempt_test_1",
554 "libdl_preempt_test_2",
555
556 "libdl_test_df_1_global",
557 ],
558
559 whole_static_libs: [
560 "libBionicStandardTests",
561 "libBionicGtestMain",
Colin Cross2722ebb2016-07-11 16:20:06 -0700562 "libfortify1-tests-clang",
563 "libfortify2-tests-clang",
564 ],
565
566 static_libs: [
567 "libbase",
568 "liblog",
569 "libcutils",
570 ],
571
572 host_ldlibs: [
573 "-lresolv",
574 "-lrt",
575 "-ldl",
576 "-lutil",
577 ],
578
579 include_dirs: ["bionic/libc"],
580
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800581 ldflags: [
582 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
583 "-Wl,--export-dynamic",
584 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700585
586 sanitize: {
587 never: false,
588 },
589}
590
591subdirs = ["libs"]