blob: 27cc9542a1ec3331cd0c088a314a577e75d3f852 [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",
Elliott Hughes7c10abb2017-04-21 17:15:41 -0700260 "link_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700261 "pthread_dlfcn_test.cpp",
262 ],
263 static_libs: [
264 "libbase",
265 ],
266 include_dirs: [
267 "bionic/libc",
268 ],
269 shared: {
270 enabled: false,
271 },
272 target: {
273 android: {
274 srcs: [
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -0700275 "cfi_test.cpp",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700276 "dlext_test.cpp",
277 "libdl_test.cpp",
278 ],
279 static_libs: [
280 "libpagemap",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800281 "libLLVMObject",
282 "libLLVMBitReader",
283 "libLLVMMC",
284 "libLLVMMCParser",
285 "libLLVMCore",
286 "libLLVMSupport",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700287 ],
288 }
289 }
290}
291
Colin Cross2722ebb2016-07-11 16:20:06 -0700292// -----------------------------------------------------------------------------
293// Library of bionic customized gtest main function, with normal gtest output format,
294// which is needed by bionic cts test.
295// -----------------------------------------------------------------------------
296cc_test_library {
297 name: "libBionicCtsGtestMain",
298 defaults: ["bionic_tests_defaults"],
Dimitry Ivanov927877c2016-09-21 11:17:13 -0700299 srcs: [
300 "gtest_main.cpp",
301 "gtest_globals_cts.cpp",
302 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700303 cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700304 shared: {
305 enabled: false,
306 },
Colin Cross2722ebb2016-07-11 16:20:06 -0700307}
308
309// -----------------------------------------------------------------------------
310// Tests for the device using bionic's .so. Run with:
311// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
312// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
313// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
314// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
315// -----------------------------------------------------------------------------
316cc_defaults {
317 name: "bionic_unit_tests_defaults",
318 host_supported: false,
319
320 whole_static_libs: [
321 "libBionicTests",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700322 "libBionicLoaderTests",
Colin Cross2722ebb2016-07-11 16:20:06 -0700323 "libBionicGtestMain",
324 ],
325
326 static_libs: [
327 "libtinyxml2",
328 "liblog",
329 "libbase",
330 ],
331
332 srcs: [
333 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
Colin Cross2722ebb2016-07-11 16:20:06 -0700334 "__cxa_thread_atexit_test.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700335 "thread_local_test.cpp",
336 ],
337
338 conlyflags: [
339 "-fexceptions",
340 "-fnon-call-exceptions",
341 ],
342
343 ldflags: ["-Wl,--export-dynamic"],
344
345 include_dirs: ["bionic/libc"],
346
Yabin Cui1f553ea2017-01-13 12:31:59 -0800347 stl: "libc++_static",
348
Colin Cross2722ebb2016-07-11 16:20:06 -0700349 target: {
350 android: {
351 shared_libs: [
352 "libdl",
Colin Cross2722ebb2016-07-11 16:20:06 -0700353 "libdl_preempt_test_1",
354 "libdl_preempt_test_2",
355 "libdl_test_df_1_global",
356 ],
357 static_libs: [
358 // The order of these libraries matters, do not shuffle them.
359 "libbase",
Dimitry Ivanovc462c282016-09-15 16:25:31 -0700360 "libpagemap",
Colin Cross2722ebb2016-07-11 16:20:06 -0700361 "libziparchive",
362 "libz",
363 "libutils",
Dimitry Ivanovac4bd2f2016-11-21 12:50:38 -0800364 "libLLVMObject",
365 "libLLVMBitReader",
366 "libLLVMMC",
367 "libLLVMMCParser",
368 "libLLVMCore",
369 "libLLVMSupport",
Colin Cross2722ebb2016-07-11 16:20:06 -0700370 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700371 ldflags: [
Colin Cross7b294952016-09-29 14:08:13 -0700372 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700373 "-Wl,--enable-new-dtags",
374 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700375 },
376 }
377}
378
379cc_test {
380 name: "bionic-unit-tests",
381 defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
382 clang: true,
Elliott Hughesa57ca0d2016-11-17 18:18:08 -0800383
384 target: {
385 android: {
386 shared_libs: ["libicuuc"],
387 },
388 },
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700389
390 required: [
391 "cfi_test_helper",
392 "cfi_test_helper2",
393 "libtest_dt_runpath_a",
394 "libtest_dt_runpath_b",
395 "libtest_dt_runpath_c",
396 "libtest_dt_runpath_x",
397 "libatest_simple_zip",
398 "libcfi-test",
399 "libcfi-test-bad",
400 "libdlext_test_different_soname",
401 "libdlext_test_fd",
402 "libdlext_test_norelro",
403 "libdlext_test_runpath_zip_zipaligned",
404 "libdlext_test",
405 "libdlext_test_zip",
406 "libdlext_test_zip_zipaligned",
407 "libdl_preempt_test_1",
408 "libdl_preempt_test_2",
409 "libdl_test_df_1_global",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700410 "libgnu-hash-table-library",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700411 "libsysv-hash-table-library",
412 "libtest_atexit",
413 "libtest_check_order_dlsym_1_left",
414 "libtest_check_order_dlsym_2_right",
415 "libtest_check_order_dlsym_3_c",
416 "libtest_check_order_dlsym_a",
417 "libtest_check_order_dlsym_b",
418 "libtest_check_order_dlsym_d",
419 "libtest_check_order_dlsym",
420 "libtest_check_order_reloc_root_1",
421 "libtest_check_order_reloc_root_2",
422 "libtest_check_order_reloc_root",
423 "libtest_check_order_reloc_siblings_1",
424 "libtest_check_order_reloc_siblings_2",
425 "libtest_check_order_reloc_siblings_3",
426 "libtest_check_order_reloc_siblings_a",
427 "libtest_check_order_reloc_siblings_b",
428 "libtest_check_order_reloc_siblings_c_1",
429 "libtest_check_order_reloc_siblings_c_2",
430 "libtest_check_order_reloc_siblings_c",
431 "libtest_check_order_reloc_siblings_d",
432 "libtest_check_order_reloc_siblings_e",
433 "libtest_check_order_reloc_siblings_f",
434 "libtest_check_order_reloc_siblings",
435 "libtest_check_rtld_next_from_library",
436 "libtest_dlopen_from_ctor_main",
437 "libtest_dlopen_from_ctor",
438 "libtest_dlopen_weak_undefined_func",
439 "libtest_dlsym_df_1_global",
440 "libtest_dlsym_from_this_child",
441 "libtest_dlsym_from_this_grandchild",
442 "libtest_dlsym_from_this",
443 "libtest_dlsym_weak_func",
444 "libtest_dt_runpath_d",
445 "libtest_empty",
Dimitry Ivanovf1db8372017-04-19 11:58:52 -0700446 "libtest_ifunc",
Dimitry Ivanov4bd35422017-04-10 16:52:25 -0700447 "libtest_init_fini_order_child",
448 "libtest_init_fini_order_grand_child",
449 "libtest_init_fini_order_root2",
450 "libtest_init_fini_order_root",
451 "libtest_nodelete_1",
452 "libtest_nodelete_2",
453 "libtest_nodelete_dt_flags_1",
454 "libtest_pthread_atfork",
455 "libtest_relo_check_dt_needed_order_1",
456 "libtest_relo_check_dt_needed_order_2",
457 "libtest_relo_check_dt_needed_order",
458 "libtest_simple",
459 "libtest_two_parents_child",
460 "libtest_two_parents_parent1",
461 "libtest_two_parents_parent2",
462 "libtest_versioned_lib",
463 "libtest_versioned_libv1",
464 "libtest_versioned_libv2",
465 "libtest_versioned_otherlib_empty",
466 "libtest_versioned_otherlib",
467 "libtest_versioned_uselibv1",
468 "libtest_versioned_uselibv2_other",
469 "libtest_versioned_uselibv2",
470 "libtest_versioned_uselibv3_other",
471 "libtest_with_dependency_loop_a",
472 "libtest_with_dependency_loop_b",
473 "libtest_with_dependency_loop_c",
474 "libtest_with_dependency_loop",
475 "libtest_with_dependency",
476 "libtest_invalid-empty_shdr_table.so",
477 "libtest_invalid-rw_load_segment.so",
478 "libtest_invalid-unaligned_shdr_offset.so",
479 "libtest_invalid-zero_shdr_table_content.so",
480 "libtest_invalid-zero_shdr_table_offset.so",
481 "libtest_invalid-zero_shentsize.so",
482 "libtest_invalid-zero_shstrndx.so",
483 "libtest_invalid-textrels.so",
484 "libtest_invalid-textrels2.so",
485 "preinit_getauxval_test_helper",
486 "preinit_syscall_test_helper",
487 "libnstest_private_external",
488 "libnstest_dlopened",
489 "libnstest_private",
490 "libnstest_root_not_isolated",
491 "libnstest_root",
492 "libnstest_public",
493 "libnstest_public_internal",
494 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700495}
496
Colin Cross2722ebb2016-07-11 16:20:06 -0700497// -----------------------------------------------------------------------------
498// Tests for the device linked against bionic's static library. Run with:
499// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
500// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
501// -----------------------------------------------------------------------------
502cc_test {
503 name: "bionic-unit-tests-static",
504 defaults: ["bionic_tests_defaults"],
505 host_supported: false,
506
Dimitry Ivanov462ea662017-01-06 14:49:57 -0800507 srcs: [
508 "gtest_preinit_debuggerd.cpp",
509 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700510 whole_static_libs: [
511 "libBionicTests",
512 "libBionicGtestMain",
513 ],
514
515 static_libs: [
516 "libm",
517 "libc",
518 "libc++_static",
519 "libdl",
520 "libtinyxml2",
521 "liblog",
522 "libbase",
Josh Gao2a3b4fa2016-10-26 17:55:49 -0700523 "libdebuggerd_handler",
Colin Cross2722ebb2016-07-11 16:20:06 -0700524 ],
525
526 static_executable: true,
527 stl: "libc++_static",
528
529 // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
530 // still causes issues when linking libc.a and libc++.a, since private isn't
531 // effective until it has been linked. To fix this, just allow multiple symbol
532 // definitions for the static tests.
533 ldflags: ["-Wl,--allow-multiple-definition"],
534}
535
536// -----------------------------------------------------------------------------
537// Tests to run on the host and linked against glibc. Run with:
538// cd bionic/tests; mm bionic-unit-tests-glibc-run
539// -----------------------------------------------------------------------------
540
541cc_test_host {
542 name: "bionic-unit-tests-glibc",
543 defaults: ["bionic_tests_defaults"],
544
545 srcs: [
546 "atexit_test.cpp",
Dimitry Ivanov708589f2016-09-19 10:50:28 -0700547 "dlfcn_symlink_support.cpp",
Colin Cross2722ebb2016-07-11 16:20:06 -0700548 "dlfcn_test.cpp",
549 "dl_test.cpp",
550 "pthread_dlfcn_test.cpp",
551 ],
552
553 shared_libs: [
554 "libdl_preempt_test_1",
555 "libdl_preempt_test_2",
556
557 "libdl_test_df_1_global",
558 ],
559
560 whole_static_libs: [
561 "libBionicStandardTests",
562 "libBionicGtestMain",
Colin Cross2722ebb2016-07-11 16:20:06 -0700563 "libfortify1-tests-clang",
564 "libfortify2-tests-clang",
565 ],
566
567 static_libs: [
568 "libbase",
569 "liblog",
570 "libcutils",
571 ],
572
573 host_ldlibs: [
574 "-lresolv",
575 "-lrt",
576 "-ldl",
577 "-lutil",
578 ],
579
580 include_dirs: ["bionic/libc"],
581
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -0800582 ldflags: [
583 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
584 "-Wl,--export-dynamic",
585 ],
Colin Cross2722ebb2016-07-11 16:20:06 -0700586
587 sanitize: {
588 never: false,
589 },
590}
591
592subdirs = ["libs"]