Home | History | Annotate | Download | only in tests
      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 
     17 cc_defaults {
     18     name: "bionic_tests_defaults",
     19     host_supported: true,
     20     cpp_std: "experimental",
     21     target: {
     22         darwin: {
     23             enabled: false,
     24         },
     25     },
     26     cflags: [
     27         "-fstack-protector-all",
     28         "-g",
     29         "-Wall",
     30         "-Wextra",
     31         "-Wunused",
     32         "-Werror",
     33         "-fno-builtin",
     34 
     35         // We want to test deprecated API too.
     36         "-Wno-deprecated-declarations",
     37 
     38         // For glibc.
     39         "-D__STDC_LIMIT_MACROS",
     40     ],
     41     stl: "libc++",
     42     sanitize: {
     43         never: true,
     44     },
     45 }
     46 
     47 // -----------------------------------------------------------------------------
     48 // All standard tests.
     49 // -----------------------------------------------------------------------------
     50 
     51 cc_test_library {
     52     name: "libBionicStandardTests",
     53     defaults: ["bionic_tests_defaults"],
     54     srcs: [
     55         "alloca_test.cpp",
     56         "arpa_inet_test.cpp",
     57         "async_safe_test.cpp",
     58         "assert_test.cpp",
     59         "buffer_tests.cpp",
     60         "bug_26110743_test.cpp",
     61         "byteswap_test.cpp",
     62         "complex_test.cpp",
     63         "complex_force_long_double_test.cpp",
     64         "ctype_test.cpp",
     65         "dirent_test.cpp",
     66         "elf_test.cpp",
     67         "endian_test.cpp",
     68         "errno_test.cpp",
     69         "error_test.cpp",
     70         "eventfd_test.cpp",
     71         "fcntl_test.cpp",
     72         "fenv_test.cpp",
     73         "float_test.cpp",
     74         "ftw_test.cpp",
     75         "getauxval_test.cpp",
     76         "getcwd_test.cpp",
     77         "glob_test.cpp",
     78         "grp_pwd_test.cpp",
     79         "grp_pwd_file_test.cpp",
     80         "iconv_test.cpp",
     81         "ifaddrs_test.cpp",
     82         "inttypes_test.cpp",
     83         "iso646_test.c",
     84         "langinfo_test.cpp",
     85         "leak_test.cpp",
     86         "libgen_basename_test.cpp",
     87         "libgen_test.cpp",
     88         "limits_test.cpp",
     89         "linux_swab_test.cpp",
     90         "locale_test.cpp",
     91         "malloc_test.cpp",
     92         "math_test.cpp",
     93         "math_force_long_double_test.cpp",
     94         "mntent_test.cpp",
     95         "netdb_test.cpp",
     96         "net_if_test.cpp",
     97         "netinet_ether_test.cpp",
     98         "netinet_in_test.cpp",
     99         "netinet_udp_test.cpp",
    100         "nl_types_test.cpp",
    101         "pthread_test.cpp",
    102         "pty_test.cpp",
    103         "regex_test.cpp",
    104         "resolv_test.cpp",
    105         "sched_test.cpp",
    106         "scsi_sg_test.cpp",
    107         "search_test.cpp",
    108         "semaphore_test.cpp",
    109         "setjmp_test.cpp",
    110         "signal_test.cpp",
    111         "spawn_test.cpp",
    112         "stack_protector_test.cpp",
    113         "stack_protector_test_helper.cpp",
    114         "stack_unwinding_test.cpp",
    115         "stdalign_test.cpp",
    116         "stdarg_test.cpp",
    117         "stdatomic_test.cpp",
    118         "stdbool_test.c",
    119         "stdint_test.cpp",
    120         "stdio_nofortify_test.cpp",
    121         "stdio_test.cpp",
    122         "stdio_ext_test.cpp",
    123         "stdlib_test.cpp",
    124         "stdnoreturn_test.cpp",
    125         "string_nofortify_test.cpp",
    126         "string_test.cpp",
    127         "string_posix_strerror_r_test.cpp",
    128         "strings_nofortify_test.cpp",
    129         "strings_test.cpp",
    130         "sstream_test.cpp",
    131         "sys_epoll_test.cpp",
    132         "sys_mman_test.cpp",
    133         "sys_msg_test.cpp",
    134         "sys_personality_test.cpp",
    135         "sys_prctl_test.cpp",
    136         "sys_procfs_test.cpp",
    137         "sys_ptrace_test.cpp",
    138         "sys_quota_test.cpp",
    139         "sys_random_test.cpp",
    140         "sys_resource_test.cpp",
    141         "sys_select_test.cpp",
    142         "sys_sem_test.cpp",
    143         "sys_sendfile_test.cpp",
    144         "sys_shm_test.cpp",
    145         "sys_signalfd_test.cpp",
    146         "sys_socket_test.cpp",
    147         "sys_stat_test.cpp",
    148         "sys_statvfs_test.cpp",
    149         "sys_syscall_test.cpp",
    150         "sys_sysinfo_test.cpp",
    151         "sys_sysmacros_test.cpp",
    152         "sys_time_test.cpp",
    153         "sys_timex_test.cpp",
    154         "sys_ttydefaults_test.cpp",
    155         "sys_types_test.cpp",
    156         "sys_uio_test.cpp",
    157         "sys_vfs_test.cpp",
    158         "sys_xattr_test.cpp",
    159         "system_properties_test.cpp",
    160         "system_properties_test2.cpp",
    161         "termios_test.cpp",
    162         "tgmath_test.c",
    163         "time_test.cpp",
    164         "uchar_test.cpp",
    165         "unistd_nofortify_test.cpp",
    166         "unistd_test.cpp",
    167         "utmp_test.cpp",
    168         "wchar_test.cpp",
    169         "wctype_test.cpp",
    170     ],
    171 
    172     include_dirs: [
    173         "bionic/libc",
    174         "external/tinyxml2",
    175     ],
    176 
    177     target: {
    178         bionic: {
    179             whole_static_libs: [
    180                 "libasync_safe",
    181                 "libsystemproperties",
    182             ],
    183         },
    184     },
    185 
    186     static_libs: [
    187         "libtinyxml2",
    188         "liblog",
    189         "libbase",
    190     ],
    191     shared: {
    192         enabled: false,
    193     },
    194 
    195     generated_headers: ["generated_android_ids"],
    196 }
    197 
    198 // -----------------------------------------------------------------------------
    199 // Fortify tests.
    200 // -----------------------------------------------------------------------------
    201 
    202 cc_defaults {
    203     name: "bionic_fortify_tests_defaults",
    204     cflags: [
    205         "-U_FORTIFY_SOURCE",
    206     ],
    207     srcs: ["fortify_test_main.cpp"],
    208     target: {
    209         host: {
    210             clang_cflags: ["-D__clang__"],
    211         },
    212     },
    213 }
    214 
    215 // If building this fails, then we have both FORTIFY and ASAN enabled, which
    216 // isn't desirable. (Ideally, we'd emit FORTIFY diagnostics even with ASAN
    217 // enabled, but that's not a reality today.) This is meant to be otherwise
    218 // unused.
    219 cc_test_library {
    220     name: "fortify_disabled_for_asan",
    221     cflags: [
    222         "-Werror",
    223         "-D_FORTIFY_SOURCE=2",
    224         // "sanitize: address" doesn't work on platforms where libasan isn't
    225         // enabled. Since the intent is just to build this, we can get away with
    226         // passing this flag on its own.
    227         "-fsanitize=address",
    228     ],
    229     // Ignore that we don't have ASAN symbols linked in.
    230     allow_undefined_symbols: true,
    231     srcs: ["fortify_filecheck_diagnostics_test.cpp"],
    232 }
    233 
    234 // Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy:
    235 // it can confuse these tools pretty easily. If this builds successfully, then
    236 // __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly
    237 // enabled. The library that results from building this is meant to be unused.
    238 cc_test_library {
    239     name: "fortify_disabled_for_tidy",
    240     cflags: [
    241         "-Werror",
    242         "-D_FORTIFY_SOURCE=2",
    243         "-D__clang_analyzer__",
    244     ],
    245     srcs: ["fortify_filecheck_diagnostics_test.cpp"],
    246 }
    247 
    248 cc_test_library {
    249     name: "libfortify1-tests-clang",
    250     defaults: [
    251         "bionic_fortify_tests_defaults",
    252         "bionic_tests_defaults",
    253     ],
    254     cflags: [
    255         "-D_FORTIFY_SOURCE=1",
    256         "-DTEST_NAME=Fortify1_clang",
    257     ],
    258     shared: {
    259         enabled: false,
    260     },
    261 }
    262 
    263 cc_test_library {
    264     name: "libfortify2-tests-clang",
    265     defaults: [
    266         "bionic_fortify_tests_defaults",
    267         "bionic_tests_defaults",
    268     ],
    269     cflags: [
    270         "-D_FORTIFY_SOURCE=2",
    271         "-DTEST_NAME=Fortify2_clang",
    272     ],
    273     shared: {
    274         enabled: false,
    275     },
    276 }
    277 
    278 // -----------------------------------------------------------------------------
    279 // Library of all tests (excluding the dynamic linker tests).
    280 // -----------------------------------------------------------------------------
    281 cc_test_library {
    282     name: "libBionicTests",
    283     defaults: ["bionic_tests_defaults"],
    284     whole_static_libs: [
    285         "libBionicStandardTests",
    286         "libfortify1-tests-clang",
    287         "libfortify2-tests-clang",
    288     ],
    289     shared: {
    290         enabled: false,
    291     },
    292 }
    293 
    294 // -----------------------------------------------------------------------------
    295 // Library of bionic customized gtest main function, with simplified output format.
    296 // -----------------------------------------------------------------------------
    297 cc_test_library {
    298     name: "libBionicGtestMain",
    299     defaults: ["bionic_tests_defaults"],
    300     srcs: [
    301         "gtest_main.cpp",
    302         "gtest_globals.cpp",
    303     ],
    304     whole_static_libs: [
    305         "libbase",
    306         "liblog",
    307     ],
    308     include_dirs: [
    309         "bionic/libc",
    310     ],
    311     target: {
    312         darwin: {
    313             enabled: true,
    314         },
    315     },
    316     shared: {
    317         enabled: false,
    318     },
    319 }
    320 
    321 cc_test_library {
    322     name: "libBionicLoaderTests",
    323     defaults: [
    324         "bionic_tests_defaults",
    325         "llvm-defaults",
    326     ],
    327     srcs: [
    328         "atexit_test.cpp",
    329         "dl_test.cpp",
    330         "dlfcn_symlink_support.cpp",
    331         "dlfcn_test.cpp",
    332         "link_test.cpp",
    333         "pthread_dlfcn_test.cpp",
    334     ],
    335     static_libs: [
    336         "libbase",
    337     ],
    338     include_dirs: [
    339         "bionic/libc",
    340     ],
    341     shared: {
    342         enabled: false,
    343     },
    344     target: {
    345         android: {
    346             srcs: [
    347                 "cfi_test.cpp",
    348                 "dlext_test.cpp",
    349                 "libdl_test.cpp",
    350             ],
    351             static_libs: [
    352                 "libpagemap",
    353                 "libziparchive",
    354                 "libLLVMObject",
    355                 "libLLVMBitReader",
    356                 "libLLVMMC",
    357                 "libLLVMMCParser",
    358                 "libLLVMCore",
    359                 "libLLVMSupport",
    360             ],
    361         },
    362     },
    363 }
    364 
    365 // -----------------------------------------------------------------------------
    366 // Library of bionic customized gtest main function, with normal gtest output format,
    367 // which is needed by bionic cts test.
    368 // -----------------------------------------------------------------------------
    369 cc_test_library {
    370     name: "libBionicCtsGtestMain",
    371     defaults: ["bionic_tests_defaults"],
    372     srcs: [
    373         "gtest_main.cpp",
    374         "gtest_globals_cts.cpp",
    375     ],
    376     static_libs: [
    377         "libbase",
    378     ],
    379     cppflags: ["-DUSING_GTEST_OUTPUT_FORMAT"],
    380     shared: {
    381         enabled: false,
    382     },
    383 }
    384 
    385 // -----------------------------------------------------------------------------
    386 // Tests for the device using bionic's .so. Run with:
    387 //   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
    388 //   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
    389 //   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
    390 //   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
    391 // -----------------------------------------------------------------------------
    392 cc_defaults {
    393     name: "bionic_unit_tests_defaults",
    394     host_supported: false,
    395 
    396     whole_static_libs: [
    397         "libBionicTests",
    398         "libBionicLoaderTests",
    399         "libBionicGtestMain",
    400     ],
    401 
    402     static_libs: [
    403         "libtinyxml2",
    404         "liblog",
    405         "libbase",
    406     ],
    407 
    408     srcs: [
    409         // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
    410         "__cxa_thread_atexit_test.cpp",
    411         "thread_local_test.cpp",
    412     ],
    413 
    414     conlyflags: [
    415         "-fexceptions",
    416         "-fnon-call-exceptions",
    417     ],
    418 
    419     ldflags: ["-Wl,--export-dynamic"],
    420 
    421     include_dirs: ["bionic/libc"],
    422 
    423     stl: "libc++_static",
    424 
    425     target: {
    426         android: {
    427             shared_libs: [
    428                 "ld-android",
    429                 "libdl",
    430                 "libdl_preempt_test_1",
    431                 "libdl_preempt_test_2",
    432                 "libdl_test_df_1_global",
    433             ],
    434             static_libs: [
    435                 // The order of these libraries matters, do not shuffle them.
    436                 "libbase",
    437                 "libpagemap",
    438                 "libziparchive",
    439                 "libz",
    440                 "libutils",
    441                 "libLLVMObject",
    442                 "libLLVMBitReader",
    443                 "libLLVMMC",
    444                 "libLLVMMCParser",
    445                 "libLLVMCore",
    446                 "libLLVMSupport",
    447             ],
    448             ldflags: [
    449                 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
    450                 "-Wl,--enable-new-dtags",
    451             ],
    452         },
    453     },
    454 }
    455 
    456 cc_test {
    457     name: "bionic-unit-tests",
    458     defaults: [
    459         "bionic_unit_tests_defaults",
    460         "bionic_tests_defaults",
    461     ],
    462 
    463     target: {
    464         android: {
    465             shared_libs: ["libicuuc"],
    466         },
    467     },
    468 
    469     required: [
    470         "cfi_test_helper",
    471         "cfi_test_helper2",
    472         "libtest_dt_runpath_a",
    473         "libtest_dt_runpath_b",
    474         "libtest_dt_runpath_c",
    475         "libtest_dt_runpath_x",
    476         "libatest_simple_zip",
    477         "libcfi-test",
    478         "libcfi-test-bad",
    479         "libdlext_test_different_soname",
    480         "libdlext_test_fd",
    481         "libdlext_test_norelro",
    482         "libdlext_test_runpath_zip_zipaligned",
    483         "libdlext_test",
    484         "libdlext_test_zip",
    485         "libdlext_test_zip_zipaligned",
    486         "libdl_preempt_test_1",
    487         "libdl_preempt_test_2",
    488         "libdl_test_df_1_global",
    489         "libelf-tls-library",
    490         "libgnu-hash-table-library",
    491         "libsysv-hash-table-library",
    492         "libtestshared",
    493         "libtest_atexit",
    494         "libtest_check_order_dlsym_1_left",
    495         "libtest_check_order_dlsym_2_right",
    496         "libtest_check_order_dlsym_3_c",
    497         "libtest_check_order_dlsym_a",
    498         "libtest_check_order_dlsym_b",
    499         "libtest_check_order_dlsym_d",
    500         "libtest_check_order_dlsym",
    501         "libtest_check_order_reloc_root_1",
    502         "libtest_check_order_reloc_root_2",
    503         "libtest_check_order_reloc_root",
    504         "libtest_check_order_reloc_siblings_1",
    505         "libtest_check_order_reloc_siblings_2",
    506         "libtest_check_order_reloc_siblings_3",
    507         "libtest_check_order_reloc_siblings_a",
    508         "libtest_check_order_reloc_siblings_b",
    509         "libtest_check_order_reloc_siblings_c_1",
    510         "libtest_check_order_reloc_siblings_c_2",
    511         "libtest_check_order_reloc_siblings_c",
    512         "libtest_check_order_reloc_siblings_d",
    513         "libtest_check_order_reloc_siblings_e",
    514         "libtest_check_order_reloc_siblings_f",
    515         "libtest_check_order_reloc_siblings",
    516         "libtest_check_rtld_next_from_library",
    517         "libtest_dlopen_df_1_global",
    518         "libtest_dlopen_from_ctor_main",
    519         "libtest_dlopen_from_ctor",
    520         "libtest_dlopen_weak_undefined_func",
    521         "libtest_dlsym_df_1_global",
    522         "libtest_dlsym_from_this_child",
    523         "libtest_dlsym_from_this_grandchild",
    524         "libtest_dlsym_from_this",
    525         "libtest_dlsym_weak_func",
    526         "libtest_dt_runpath_d",
    527         "libtest_empty",
    528         "libtest_ifunc_variable_impl",
    529         "libtest_ifunc_variable",
    530         "libtest_ifunc",
    531         "libtest_init_fini_order_child",
    532         "libtest_init_fini_order_grand_child",
    533         "libtest_init_fini_order_root2",
    534         "libtest_init_fini_order_root",
    535         "libtest_missing_symbol_child_public",
    536         "libtest_missing_symbol_child_private",
    537         "libtest_missing_symbol_root",
    538         "libtest_missing_symbol",
    539         "libtest_nodelete_1",
    540         "libtest_nodelete_2",
    541         "libtest_nodelete_dt_flags_1",
    542         "libtest_pthread_atfork",
    543         "libtest_relo_check_dt_needed_order_1",
    544         "libtest_relo_check_dt_needed_order_2",
    545         "libtest_relo_check_dt_needed_order",
    546         "libtest_simple",
    547         "libtest_two_parents_child",
    548         "libtest_two_parents_parent1",
    549         "libtest_two_parents_parent2",
    550         "libtest_versioned_lib",
    551         "libtest_versioned_libv1",
    552         "libtest_versioned_libv2",
    553         "libtest_versioned_otherlib_empty",
    554         "libtest_versioned_otherlib",
    555         "libtest_versioned_uselibv1",
    556         "libtest_versioned_uselibv2_other",
    557         "libtest_versioned_uselibv2",
    558         "libtest_versioned_uselibv3_other",
    559         "libtest_with_dependency_loop_a",
    560         "libtest_with_dependency_loop_b",
    561         "libtest_with_dependency_loop_c",
    562         "libtest_with_dependency_loop",
    563         "libtest_with_dependency",
    564         "libtest_invalid-empty_shdr_table.so",
    565         "libtest_invalid-rw_load_segment.so",
    566         "libtest_invalid-unaligned_shdr_offset.so",
    567         "libtest_invalid-zero_shdr_table_content.so",
    568         "libtest_invalid-zero_shdr_table_offset.so",
    569         "libtest_invalid-zero_shentsize.so",
    570         "libtest_invalid-zero_shstrndx.so",
    571         "libtest_invalid-textrels.so",
    572         "libtest_invalid-textrels2.so",
    573         "libtest_thread_local_dtor",
    574         "preinit_getauxval_test_helper",
    575         "preinit_syscall_test_helper",
    576         "libnstest_private_external",
    577         "libnstest_dlopened",
    578         "libnstest_private",
    579         "libnstest_root_not_isolated",
    580         "libnstest_root",
    581         "libnstest_public",
    582         "libnstest_public_internal",
    583         "libnstest_ns_a_public1",
    584         "libnstest_ns_a_public1_internal",
    585         "libnstest_ns_b_public2",
    586         "libnstest_ns_b_public3",
    587         "ld_preload_test_helper",
    588         "ld_preload_test_helper_lib1",
    589         "ld_preload_test_helper_lib2",
    590         "ld_config_test_helper",
    591         "ld_config_test_helper_lib1",
    592         "ld_config_test_helper_lib2",
    593         "ld_config_test_helper_lib3",
    594     ],
    595 }
    596 
    597 // -----------------------------------------------------------------------------
    598 // Tests for the device linked against bionic's static library. Run with:
    599 //   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
    600 //   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
    601 // -----------------------------------------------------------------------------
    602 cc_test {
    603     name: "bionic-unit-tests-static",
    604     defaults: ["bionic_tests_defaults"],
    605     host_supported: false,
    606 
    607     srcs: [
    608         "gtest_preinit_debuggerd.cpp",
    609     ],
    610     whole_static_libs: [
    611         "libBionicTests",
    612         "libBionicGtestMain",
    613     ],
    614 
    615     static_libs: [
    616         "libm",
    617         "libc",
    618         "libdl",
    619         "libtinyxml2",
    620         "liblog",
    621         "libbase",
    622         "libdebuggerd_handler",
    623     ],
    624 
    625     static_executable: true,
    626     stl: "libc++_static",
    627 }
    628 
    629 // -----------------------------------------------------------------------------
    630 // Tests to run on the host and linked against glibc. Run with:
    631 //   cd bionic/tests; mm bionic-unit-tests-glibc-run
    632 // -----------------------------------------------------------------------------
    633 
    634 cc_test_host {
    635     name: "bionic-unit-tests-glibc",
    636     defaults: ["bionic_tests_defaults"],
    637 
    638     srcs: [
    639         "atexit_test.cpp",
    640         "dlfcn_symlink_support.cpp",
    641         "dlfcn_test.cpp",
    642         "dl_test.cpp",
    643         "pthread_dlfcn_test.cpp",
    644     ],
    645 
    646     shared_libs: [
    647         "libdl_preempt_test_1",
    648         "libdl_preempt_test_2",
    649 
    650         "libdl_test_df_1_global",
    651     ],
    652 
    653     whole_static_libs: [
    654         "libBionicStandardTests",
    655         "libBionicGtestMain",
    656         "libfortify1-tests-clang",
    657         "libfortify2-tests-clang",
    658     ],
    659 
    660     static_libs: [
    661         "libbase",
    662         "liblog",
    663         "libcutils",
    664     ],
    665 
    666     host_ldlibs: [
    667         "-lresolv",
    668         "-lutil",
    669     ],
    670 
    671     include_dirs: ["bionic/libc"],
    672 
    673     ldflags: [
    674         "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs",
    675         "-Wl,--export-dynamic",
    676     ],
    677 
    678     sanitize: {
    679         never: false,
    680     },
    681 
    682     target: {
    683         linux_bionic: {
    684             enabled: false,
    685         },
    686     },
    687 }
    688 
    689 subdirs = ["*"]
    690