• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
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",
55        "async_safe_test.cpp",
56        "assert_test.cpp",
57        "buffer_tests.cpp",
58        "bug_26110743_test.cpp",
59        "complex_test.cpp",
60        "ctype_test.cpp",
61        "dirent_test.cpp",
62        "elf_test.cpp",
63        "endian_test.cpp",
64        "errno_test.cpp",
65        "error_test.cpp",
66        "eventfd_test.cpp",
67        "fcntl_test.cpp",
68        "fenv_test.cpp",
69        "ftw_test.cpp",
70        "getauxval_test.cpp",
71        "getcwd_test.cpp",
72        "grp_pwd_test.cpp",
73        "ifaddrs_test.cpp",
74        "inttypes_test.cpp",
75        "langinfo_test.cpp",
76        "leak_test.cpp",
77        "libgen_basename_test.cpp",
78        "libgen_test.cpp",
79        "linux_swab_test.cpp",
80        "locale_test.cpp",
81        "malloc_test.cpp",
82        "math_test.cpp",
83        "mntent_test.cpp",
84        "netdb_test.cpp",
85        "net_if_test.cpp",
86        "netinet_ether_test.cpp",
87        "netinet_in_test.cpp",
88        "netinet_udp_test.cpp",
89        "nl_types_test.cpp",
90        "pthread_test.cpp",
91        "pty_test.cpp",
92        "qsort_test.cpp",
93        "regex_test.cpp",
94        "resolv_test.cpp",
95        "sched_test.cpp",
96        "scsi_sg_test.cpp",
97        "search_test.cpp",
98        "semaphore_test.cpp",
99        "setjmp_test.cpp",
100        "signal_test.cpp",
101        "stack_protector_test.cpp",
102        "stack_protector_test_helper.cpp",
103        "stack_unwinding_test.cpp",
104        "stdatomic_test.cpp",
105        "stdint_test.cpp",
106        "stdio_nofortify_test.cpp",
107        "stdio_test.cpp",
108        "stdio_ext_test.cpp",
109        "stdlib_test.cpp",
110        "string_nofortify_test.cpp",
111        "string_test.cpp",
112        "string_posix_strerror_r_test.cpp",
113        "strings_nofortify_test.cpp",
114        "strings_test.cpp",
115        "sstream_test.cpp",
116        "sys_epoll_test.cpp",
117        "sys_mman_test.cpp",
118        "sys_msg_test.cpp",
119        "sys_personality_test.cpp",
120        "sys_prctl_test.cpp",
121        "sys_procfs_test.cpp",
122        "sys_ptrace_test.cpp",
123        "sys_quota_test.cpp",
124        "sys_resource_test.cpp",
125        "sys_select_test.cpp",
126        "sys_sem_test.cpp",
127        "sys_sendfile_test.cpp",
128        "sys_shm_test.cpp",
129        "sys_socket_test.cpp",
130        "sys_stat_test.cpp",
131        "sys_statvfs_test.cpp",
132        "sys_syscall_test.cpp",
133        "sys_sysinfo_test.cpp",
134        "sys_sysmacros_test.cpp",
135        "sys_time_test.cpp",
136        "sys_timex_test.cpp",
137        "sys_ttydefaults_test.cpp",
138        "sys_types_test.cpp",
139        "sys_uio_test.cpp",
140        "sys_vfs_test.cpp",
141        "sys_xattr_test.cpp",
142        "system_properties_test.cpp",
143        "system_properties_test2.cpp",
144        "time_test.cpp",
145        "uchar_test.cpp",
146        "unistd_nofortify_test.cpp",
147        "unistd_test.cpp",
148        "utmp_test.cpp",
149        "wchar_test.cpp",
150        "wctype_test.cpp",
151    ],
152
153    include_dirs: [
154        "bionic/libc",
155        "external/tinyxml2",
156    ],
157
158    target: {
159        android: {
160            whole_static_libs: ["libasync_safe"],
161        },
162    },
163
164    static_libs: [
165        "libtinyxml2",
166        "liblog",
167        "libbase",
168    ],
169    host_ldlibs: ["-lrt"],
170    shared: {
171        enabled: false,
172    },
173
174    generated_headers: ["generated_android_ids"],
175}
176
177// -----------------------------------------------------------------------------
178// Fortify tests.
179// -----------------------------------------------------------------------------
180
181cc_defaults {
182    name: "bionic_fortify_tests_defaults",
183    cflags: [
184        "-Wno-error",
185        "-U_FORTIFY_SOURCE",
186    ],
187    srcs: ["fortify_test_main.cpp"],
188    target: {
189        host: {
190            clang_cflags: ["-D__clang__"],
191        },
192    },
193}
194
195cc_test_library {
196    name: "libfortify1-tests-clang",
197    defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
198    clang: true,
199    cflags: [
200        "-D_FORTIFY_SOURCE=1",
201        "-DTEST_NAME=Fortify1_clang"
202    ],
203    shared: {
204        enabled: false,
205    },
206}
207
208cc_test_library {
209    name: "libfortify2-tests-clang",
210    defaults: ["bionic_fortify_tests_defaults", "bionic_tests_defaults"],
211    clang: true,
212    cflags: [
213        "-D_FORTIFY_SOURCE=2",
214        "-DTEST_NAME=Fortify2_clang"
215    ],
216    shared: {
217        enabled: false,
218    },
219}
220
221// -----------------------------------------------------------------------------
222// Library of all tests (excluding the dynamic linker tests).
223// -----------------------------------------------------------------------------
224cc_test_library {
225    name: "libBionicTests",
226    defaults: ["bionic_tests_defaults"],
227    whole_static_libs: [
228        "libBionicStandardTests",
229        "libfortify1-tests-clang",
230        "libfortify2-tests-clang",
231    ],
232    shared: {
233        enabled: false,
234    },
235}
236
237// -----------------------------------------------------------------------------
238// Library of bionic customized gtest main function, with simplified output format.
239// -----------------------------------------------------------------------------
240cc_test_library {
241    name: "libBionicGtestMain",
242    defaults: ["bionic_tests_defaults"],
243    srcs: [
244        "gtest_main.cpp",
245        "gtest_globals.cpp",
246    ],
247    static_libs: [
248        "libbase",
249    ],
250    include_dirs: [
251        "bionic/libc",
252    ],
253    target: {
254        darwin: {
255            enabled: true,
256        },
257    },
258    shared: {
259        enabled: false,
260    },
261}
262
263cc_test_library {
264    name: "libBionicLoaderTests",
265    defaults: ["bionic_tests_defaults", "llvm-defaults"],
266    srcs: [
267        "atexit_test.cpp",
268        "dl_test.cpp",
269        "dlfcn_symlink_support.cpp",
270        "dlfcn_test.cpp",
271        "link_test.cpp",
272        "pthread_dlfcn_test.cpp",
273    ],
274    static_libs: [
275        "libbase",
276    ],
277    include_dirs: [
278        "bionic/libc",
279    ],
280    shared: {
281        enabled: false,
282    },
283    target: {
284        android: {
285            srcs: [
286                "cfi_test.cpp",
287                "dlext_test.cpp",
288                "libdl_test.cpp",
289            ],
290            static_libs: [
291                "libpagemap",
292                "libziparchive",
293                "libLLVMObject",
294                "libLLVMBitReader",
295                "libLLVMMC",
296                "libLLVMMCParser",
297                "libLLVMCore",
298                "libLLVMSupport",
299            ],
300        }
301    },
302}
303
304// -----------------------------------------------------------------------------
305// Library of bionic customized gtest main function, with normal gtest output format,
306// which is needed by bionic cts test.
307// -----------------------------------------------------------------------------
308cc_test_library {
309    name: "libBionicCtsGtestMain",
310    defaults: ["bionic_tests_defaults"],
311    srcs: [
312        "gtest_main.cpp",
313        "gtest_globals_cts.cpp",
314    ],
315    cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
316    shared: {
317        enabled: false,
318    },
319}
320
321// -----------------------------------------------------------------------------
322// Tests for the device using bionic's .so. Run with:
323//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
324//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
325//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
326//   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
327// -----------------------------------------------------------------------------
328cc_defaults {
329    name: "bionic_unit_tests_defaults",
330    host_supported: false,
331
332    whole_static_libs: [
333        "libBionicTests",
334        "libBionicLoaderTests",
335        "libBionicGtestMain",
336    ],
337
338    static_libs: [
339        "libtinyxml2",
340        "liblog",
341        "libbase",
342    ],
343
344    srcs: [
345        // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
346        "__cxa_thread_atexit_test.cpp",
347        "thread_local_test.cpp",
348    ],
349
350    conlyflags: [
351        "-fexceptions",
352        "-fnon-call-exceptions",
353    ],
354
355    ldflags: ["-Wl,--export-dynamic"],
356
357    include_dirs: ["bionic/libc"],
358
359    stl: "libc++_static",
360
361    target: {
362        android: {
363            shared_libs: [
364                "libdl",
365                "libdl_preempt_test_1",
366                "libdl_preempt_test_2",
367                "libdl_test_df_1_global",
368            ],
369            static_libs: [
370                // The order of these libraries matters, do not shuffle them.
371                "libbase",
372                "libpagemap",
373                "libziparchive",
374                "libz",
375                "libutils",
376                "libLLVMObject",
377                "libLLVMBitReader",
378                "libLLVMMC",
379                "libLLVMMCParser",
380                "libLLVMCore",
381                "libLLVMSupport",
382            ],
383            ldflags: [
384                "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
385                "-Wl,--enable-new-dtags",
386            ],
387        },
388    }
389}
390
391cc_test {
392    name: "bionic-unit-tests",
393    defaults: ["bionic_unit_tests_defaults", "bionic_tests_defaults"],
394    clang: true,
395
396    target: {
397        android: {
398            shared_libs: ["libicuuc"],
399        },
400    },
401
402    required: [
403        "cfi_test_helper",
404        "cfi_test_helper2",
405        "libtest_dt_runpath_a",
406        "libtest_dt_runpath_b",
407        "libtest_dt_runpath_c",
408        "libtest_dt_runpath_x",
409        "libatest_simple_zip",
410        "libcfi-test",
411        "libcfi-test-bad",
412        "libdlext_test_different_soname",
413        "libdlext_test_fd",
414        "libdlext_test_norelro",
415        "libdlext_test_runpath_zip_zipaligned",
416        "libdlext_test",
417        "libdlext_test_zip",
418        "libdlext_test_zip_zipaligned",
419        "libdl_preempt_test_1",
420        "libdl_preempt_test_2",
421        "libdl_test_df_1_global",
422        "libgnu-hash-table-library",
423        "libsysv-hash-table-library",
424        "libtest_atexit",
425        "libtest_check_order_dlsym_1_left",
426        "libtest_check_order_dlsym_2_right",
427        "libtest_check_order_dlsym_3_c",
428        "libtest_check_order_dlsym_a",
429        "libtest_check_order_dlsym_b",
430        "libtest_check_order_dlsym_d",
431        "libtest_check_order_dlsym",
432        "libtest_check_order_reloc_root_1",
433        "libtest_check_order_reloc_root_2",
434        "libtest_check_order_reloc_root",
435        "libtest_check_order_reloc_siblings_1",
436        "libtest_check_order_reloc_siblings_2",
437        "libtest_check_order_reloc_siblings_3",
438        "libtest_check_order_reloc_siblings_a",
439        "libtest_check_order_reloc_siblings_b",
440        "libtest_check_order_reloc_siblings_c_1",
441        "libtest_check_order_reloc_siblings_c_2",
442        "libtest_check_order_reloc_siblings_c",
443        "libtest_check_order_reloc_siblings_d",
444        "libtest_check_order_reloc_siblings_e",
445        "libtest_check_order_reloc_siblings_f",
446        "libtest_check_order_reloc_siblings",
447        "libtest_check_rtld_next_from_library",
448        "libtest_dlopen_from_ctor_main",
449        "libtest_dlopen_from_ctor",
450        "libtest_dlopen_weak_undefined_func",
451        "libtest_dlsym_df_1_global",
452        "libtest_dlsym_from_this_child",
453        "libtest_dlsym_from_this_grandchild",
454        "libtest_dlsym_from_this",
455        "libtest_dlsym_weak_func",
456        "libtest_dt_runpath_d",
457        "libtest_empty",
458        "libtest_ifunc",
459        "libtest_init_fini_order_child",
460        "libtest_init_fini_order_grand_child",
461        "libtest_init_fini_order_root2",
462        "libtest_init_fini_order_root",
463        "libtest_nodelete_1",
464        "libtest_nodelete_2",
465        "libtest_nodelete_dt_flags_1",
466        "libtest_pthread_atfork",
467        "libtest_relo_check_dt_needed_order_1",
468        "libtest_relo_check_dt_needed_order_2",
469        "libtest_relo_check_dt_needed_order",
470        "libtest_simple",
471        "libtest_two_parents_child",
472        "libtest_two_parents_parent1",
473        "libtest_two_parents_parent2",
474        "libtest_versioned_lib",
475        "libtest_versioned_libv1",
476        "libtest_versioned_libv2",
477        "libtest_versioned_otherlib_empty",
478        "libtest_versioned_otherlib",
479        "libtest_versioned_uselibv1",
480        "libtest_versioned_uselibv2_other",
481        "libtest_versioned_uselibv2",
482        "libtest_versioned_uselibv3_other",
483        "libtest_with_dependency_loop_a",
484        "libtest_with_dependency_loop_b",
485        "libtest_with_dependency_loop_c",
486        "libtest_with_dependency_loop",
487        "libtest_with_dependency",
488        "libtest_invalid-empty_shdr_table.so",
489        "libtest_invalid-rw_load_segment.so",
490        "libtest_invalid-unaligned_shdr_offset.so",
491        "libtest_invalid-zero_shdr_table_content.so",
492        "libtest_invalid-zero_shdr_table_offset.so",
493        "libtest_invalid-zero_shentsize.so",
494        "libtest_invalid-zero_shstrndx.so",
495        "libtest_invalid-textrels.so",
496        "libtest_invalid-textrels2.so",
497        "preinit_getauxval_test_helper",
498        "preinit_syscall_test_helper",
499        "libnstest_private_external",
500        "libnstest_dlopened",
501        "libnstest_private",
502        "libnstest_root_not_isolated",
503        "libnstest_root",
504        "libnstest_public",
505        "libnstest_public_internal",
506    ],
507}
508
509// -----------------------------------------------------------------------------
510// Tests for the device linked against bionic's static library. Run with:
511//   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
512//   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
513// -----------------------------------------------------------------------------
514cc_test {
515    name: "bionic-unit-tests-static",
516    defaults: ["bionic_tests_defaults"],
517    host_supported: false,
518
519    srcs: [
520        "gtest_preinit_debuggerd.cpp",
521    ],
522    whole_static_libs: [
523        "libBionicTests",
524        "libBionicGtestMain",
525    ],
526
527    static_libs: [
528        "libm",
529        "libc",
530        "libc++_static",
531        "libdl",
532        "libtinyxml2",
533        "liblog",
534        "libbase",
535        "libdebuggerd_handler",
536    ],
537
538    static_executable: true,
539    stl: "libc++_static",
540
541    // libc and libc++ both define std::nothrow. libc's is a private symbol, but this
542    // still causes issues when linking libc.a and libc++.a, since private isn't
543    // effective until it has been linked. To fix this, just allow multiple symbol
544    // definitions for the static tests.
545    ldflags: ["-Wl,--allow-multiple-definition"],
546}
547
548// -----------------------------------------------------------------------------
549// Tests to run on the host and linked against glibc. Run with:
550//   cd bionic/tests; mm bionic-unit-tests-glibc-run
551// -----------------------------------------------------------------------------
552
553cc_test_host {
554    name: "bionic-unit-tests-glibc",
555    defaults: ["bionic_tests_defaults"],
556
557    srcs: [
558        "atexit_test.cpp",
559        "dlfcn_symlink_support.cpp",
560        "dlfcn_test.cpp",
561        "dl_test.cpp",
562        "pthread_dlfcn_test.cpp",
563    ],
564
565    shared_libs: [
566        "libdl_preempt_test_1",
567        "libdl_preempt_test_2",
568
569        "libdl_test_df_1_global",
570    ],
571
572    whole_static_libs: [
573        "libBionicStandardTests",
574        "libBionicGtestMain",
575        "libfortify1-tests-clang",
576        "libfortify2-tests-clang",
577    ],
578
579    static_libs: [
580        "libbase",
581        "liblog",
582        "libcutils",
583    ],
584
585    host_ldlibs: [
586        "-lresolv",
587        "-lrt",
588        "-ldl",
589        "-lutil",
590    ],
591
592    include_dirs: ["bionic/libc"],
593
594    ldflags: [
595        "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
596        "-Wl,--export-dynamic",
597    ],
598
599    sanitize: {
600        never: false,
601    },
602}
603
604subdirs = ["libs"]
605