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 cpp_std: "experimental", 21 target: { 22 darwin: { 23 enabled: false, 24 }, 25 android: { 26 header_libs: ["bionic_libc_platform_headers"], 27 }, 28 linux_bionic: { 29 header_libs: ["bionic_libc_platform_headers"], 30 }, 31 }, 32 cflags: [ 33 "-fstack-protector-all", 34 "-g", 35 "-Wall", 36 "-Wextra", 37 "-Wunused", 38 "-Werror", 39 "-fno-builtin", 40 41 // We want to test deprecated API too. 42 "-Wno-deprecated-declarations", 43 44 // For glibc. 45 "-D__STDC_LIMIT_MACROS", 46 ], 47 // Ensure that the tests exercise shadow call stack support and 48 // the hint space PAC/BTI instructions. 49 arch: { 50 arm64: { 51 cflags: [ 52 "-fsanitize=shadow-call-stack", 53 // Disable this option for now: see b/151372823 54 //"-mbranch-protection=standard", 55 ], 56 }, 57 }, 58 stl: "libc++", 59 sanitize: { 60 address: false, 61 }, 62 63 // Use the bootstrap version of bionic because some tests call private APIs 64 // that aren't exposed by the APEX bionic stubs. 65 bootstrap: true, 66 67 product_variables: { 68 experimental_mte: { 69 cflags: ["-DANDROID_EXPERIMENTAL_MTE"], 70 }, 71 }, 72} 73 74// ----------------------------------------------------------------------------- 75// Prebuilt shared libraries for use in tests. 76// ----------------------------------------------------------------------------- 77 78cc_prebuilt_test_library_shared { 79 name: "libtest_invalid-rw_load_segment", 80 strip: { 81 none: true, 82 }, 83 check_elf_files: false, 84 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 85 arch: { 86 arm: { 87 srcs: ["prebuilt-elf-files/arm/libtest_invalid-rw_load_segment.so"], 88 }, 89 arm64: { 90 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so"], 91 }, 92 x86: { 93 srcs: ["prebuilt-elf-files/x86/libtest_invalid-rw_load_segment.so"], 94 }, 95 x86_64: { 96 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so"], 97 }, 98 }, 99} 100 101cc_prebuilt_test_library_shared { 102 name: "libtest_invalid-unaligned_shdr_offset", 103 strip: { 104 none: true, 105 }, 106 check_elf_files: false, 107 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 108 arch: { 109 arm: { 110 srcs: ["prebuilt-elf-files/arm/libtest_invalid-unaligned_shdr_offset.so"], 111 }, 112 arm64: { 113 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-unaligned_shdr_offset.so"], 114 }, 115 x86: { 116 srcs: ["prebuilt-elf-files/x86/libtest_invalid-unaligned_shdr_offset.so"], 117 }, 118 x86_64: { 119 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-unaligned_shdr_offset.so"], 120 }, 121 }, 122} 123 124cc_prebuilt_test_library_shared { 125 name: "libtest_invalid-zero_shentsize", 126 strip: { 127 none: true, 128 }, 129 check_elf_files: false, 130 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 131 arch: { 132 arm: { 133 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shentsize.so"], 134 }, 135 arm64: { 136 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shentsize.so"], 137 }, 138 x86: { 139 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shentsize.so"], 140 }, 141 x86_64: { 142 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shentsize.so"], 143 }, 144 }, 145} 146 147cc_prebuilt_test_library_shared { 148 name: "libtest_invalid-zero_shstrndx", 149 strip: { 150 none: true, 151 }, 152 check_elf_files: false, 153 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 154 arch: { 155 arm: { 156 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shstrndx.so"], 157 }, 158 arm64: { 159 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shstrndx.so"], 160 }, 161 x86: { 162 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shstrndx.so"], 163 }, 164 x86_64: { 165 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shstrndx.so"], 166 }, 167 }, 168} 169 170cc_prebuilt_test_library_shared { 171 name: "libtest_invalid-empty_shdr_table", 172 strip: { 173 none: true, 174 }, 175 check_elf_files: false, 176 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 177 arch: { 178 arm: { 179 srcs: ["prebuilt-elf-files/arm/libtest_invalid-empty_shdr_table.so"], 180 }, 181 arm64: { 182 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-empty_shdr_table.so"], 183 }, 184 x86: { 185 srcs: ["prebuilt-elf-files/x86/libtest_invalid-empty_shdr_table.so"], 186 }, 187 x86_64: { 188 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-empty_shdr_table.so"], 189 }, 190 }, 191} 192 193cc_prebuilt_test_library_shared { 194 name: "libtest_invalid-zero_shdr_table_offset", 195 strip: { 196 none: true, 197 }, 198 check_elf_files: false, 199 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 200 arch: { 201 arm: { 202 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_offset.so"], 203 }, 204 arm64: { 205 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_offset.so"], 206 }, 207 x86: { 208 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_offset.so"], 209 }, 210 x86_64: { 211 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_offset.so"], 212 }, 213 }, 214} 215 216cc_prebuilt_test_library_shared { 217 name: "libtest_invalid-zero_shdr_table_content", 218 strip: { 219 none: true, 220 }, 221 check_elf_files: false, 222 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 223 arch: { 224 arm: { 225 srcs: ["prebuilt-elf-files/arm/libtest_invalid-zero_shdr_table_content.so"], 226 }, 227 arm64: { 228 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-zero_shdr_table_content.so"], 229 }, 230 x86: { 231 srcs: ["prebuilt-elf-files/x86/libtest_invalid-zero_shdr_table_content.so"], 232 }, 233 x86_64: { 234 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-zero_shdr_table_content.so"], 235 }, 236 }, 237} 238 239cc_prebuilt_test_library_shared { 240 name: "libtest_invalid-textrels", 241 strip: { 242 none: true, 243 }, 244 check_elf_files: false, 245 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 246 arch: { 247 arm: { 248 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels.so"], 249 }, 250 arm64: { 251 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels.so"], 252 }, 253 x86: { 254 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels.so"], 255 }, 256 x86_64: { 257 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels.so"], 258 }, 259 }, 260} 261 262cc_prebuilt_test_library_shared { 263 name: "libtest_invalid-textrels2", 264 strip: { 265 none: true, 266 }, 267 check_elf_files: false, 268 relative_install_path: "bionic-loader-test-libs/prebuilt-elf-files", 269 arch: { 270 arm: { 271 srcs: ["prebuilt-elf-files/arm/libtest_invalid-textrels2.so"], 272 }, 273 arm64: { 274 srcs: ["prebuilt-elf-files/arm64/libtest_invalid-textrels2.so"], 275 }, 276 x86: { 277 srcs: ["prebuilt-elf-files/x86/libtest_invalid-textrels2.so"], 278 }, 279 x86_64: { 280 srcs: ["prebuilt-elf-files/x86_64/libtest_invalid-textrels2.so"], 281 }, 282 }, 283} 284 285// ----------------------------------------------------------------------------- 286// All standard tests. 287// ----------------------------------------------------------------------------- 288 289// Test diagnostics emitted by clang. The library that results is useless; we 290// just want to run '-Xclang -verify', which will fail if the diagnostics don't 291// match up with what the source file says they should be. 292cc_test_library { 293 name: "clang_diagnostic_tests", 294 cflags: [ 295 "-Xclang", 296 "-verify", 297 ], 298 srcs: ["sys_ioctl_diag_test.cpp"], 299} 300 301cc_test_library { 302 name: "libBionicStandardTests", 303 defaults: ["bionic_tests_defaults"], 304 srcs: [ 305 "__aeabi_read_tp_test.cpp", 306 "__cxa_atexit_test.cpp", 307 "alloca_test.cpp", 308 "android_get_device_api_level.cpp", 309 "arpa_inet_test.cpp", 310 "async_safe_test.cpp", 311 "assert_test.cpp", 312 "buffer_tests.cpp", 313 "bug_26110743_test.cpp", 314 "byteswap_test.cpp", 315 "complex_test.cpp", 316 "complex_force_long_double_test.cpp", 317 "ctype_test.cpp", 318 "dirent_test.cpp", 319 "elf_test.cpp", 320 "endian_test.cpp", 321 "errno_test.cpp", 322 "error_test.cpp", 323 "eventfd_test.cpp", 324 "fcntl_test.cpp", 325 "fdsan_test.cpp", 326 "fdtrack_test.cpp", 327 "fenv_test.cpp", 328 "_FILE_OFFSET_BITS_test.cpp", 329 "float_test.cpp", 330 "ftw_test.cpp", 331 "getauxval_test.cpp", 332 "getcwd_test.cpp", 333 "glob_test.cpp", 334 "grp_pwd_test.cpp", 335 "grp_pwd_file_test.cpp", 336 "heap_tagging_level_test.cpp", 337 "iconv_test.cpp", 338 "ifaddrs_test.cpp", 339 "ifunc_test.cpp", 340 "inttypes_test.cpp", 341 "iso646_test.c", 342 "langinfo_test.cpp", 343 "leak_test.cpp", 344 "libgen_basename_test.cpp", 345 "libgen_test.cpp", 346 "limits_test.cpp", 347 "linux_swab_test.cpp", 348 "locale_test.cpp", 349 "malloc_iterate_test.cpp", 350 "malloc_test.cpp", 351 "math_test.cpp", 352 "math_force_long_double_test.cpp", 353 "membarrier_test.cpp", 354 "mntent_test.cpp", 355 "mte_test.cpp", 356 "netdb_test.cpp", 357 "net_if_test.cpp", 358 "netinet_ether_test.cpp", 359 "netinet_in_test.cpp", 360 "netinet_ip_icmp_test.cpp", 361 "netinet_udp_test.cpp", 362 "nl_types_test.cpp", 363 "poll_test.cpp", 364 "pthread_test.cpp", 365 "pty_test.cpp", 366 "regex_test.cpp", 367 "resolv_test.cpp", 368 "sched_test.cpp", 369 "scs_test.cpp", 370 "scsi_sg_test.cpp", 371 "search_test.cpp", 372 "semaphore_test.cpp", 373 "setjmp_test.cpp", 374 "signal_test.cpp", 375 "spawn_test.cpp", 376 "stack_protector_test.cpp", 377 "stack_protector_test_helper.cpp", 378 "stack_unwinding_test.cpp", 379 "stdalign_test.cpp", 380 "stdarg_test.cpp", 381 "stdatomic_test.cpp", 382 "stdbool_test.c", 383 "stdint_test.cpp", 384 "stdio_nofortify_test.cpp", 385 "stdio_test.cpp", 386 "stdio_ext_test.cpp", 387 "stdlib_test.cpp", 388 "stdnoreturn_test.cpp", 389 "string_nofortify_test.cpp", 390 "string_test.cpp", 391 "string_posix_strerror_r_test.cpp", 392 "strings_nofortify_test.cpp", 393 "strings_test.cpp", 394 "sstream_test.cpp", 395 "sys_auxv_test.cpp", 396 "sys_epoll_test.cpp", 397 "sys_mman_test.cpp", 398 "sys_msg_test.cpp", 399 "sys_param_test.cpp", 400 "sys_personality_test.cpp", 401 "sys_prctl_test.cpp", 402 "sys_procfs_test.cpp", 403 "sys_ptrace_test.cpp", 404 "sys_quota_test.cpp", 405 "sys_random_test.cpp", 406 "sys_resource_test.cpp", 407 "sys_select_test.cpp", 408 "sys_sem_test.cpp", 409 "sys_sendfile_test.cpp", 410 "sys_shm_test.cpp", 411 "sys_signalfd_test.cpp", 412 "sys_socket_test.cpp", 413 "sys_stat_test.cpp", 414 "sys_statvfs_test.cpp", 415 "sys_syscall_test.cpp", 416 "sys_sysinfo_test.cpp", 417 "sys_sysmacros_test.cpp", 418 "sys_time_test.cpp", 419 "sys_timex_test.cpp", 420 "sys_ttydefaults_test.cpp", 421 "sys_types_test.cpp", 422 "sys_uio_test.cpp", 423 "sys_un_test.cpp", 424 "sys_vfs_test.cpp", 425 "sys_xattr_test.cpp", 426 "system_properties_test.cpp", 427 "system_properties_test2.cpp", 428 "termios_test.cpp", 429 "tgmath_test.c", 430 "threads_test.cpp", 431 "time_test.cpp", 432 "uchar_test.cpp", 433 "unistd_nofortify_test.cpp", 434 "unistd_test.cpp", 435 "utmp_test.cpp", 436 "wchar_test.cpp", 437 "wctype_test.cpp", 438 ], 439 440 include_dirs: [ 441 "bionic/libc", 442 ], 443 444 target: { 445 bionic: { 446 whole_static_libs: [ 447 "libasync_safe", 448 "libprocinfo", 449 "libsystemproperties", 450 ], 451 }, 452 }, 453 454 static_libs: [ 455 "libtinyxml2", 456 "liblog", 457 "libbase", 458 ], 459 shared: { 460 enabled: false, 461 }, 462 463 generated_headers: ["generated_android_ids"], 464} 465 466cc_test_library { 467 name: "libBionicElfTlsTests", 468 defaults: ["bionic_tests_defaults"], 469 srcs: [ 470 "elftls_test.cpp", 471 ], 472 include_dirs: [ 473 "bionic/libc", 474 ], 475 shared: { 476 enabled: false, 477 }, 478 cflags: [ 479 "-fno-emulated-tls", 480 ], 481 // With fuzzer builds, compiler instrumentation generates a reference to the 482 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer 483 // library as an emutls symbol. The -fno-emulated-tls flag above configures 484 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack 485 // symbol instead, which isn't defined. Disable the fuzzer for this test 486 // until the platform is switched to ELF TLS. 487 sanitize: { 488 fuzzer: false, 489 }, 490} 491 492cc_test_library { 493 name: "libBionicElfTlsLoaderTests", 494 defaults: ["bionic_tests_defaults"], 495 srcs: [ 496 "elftls_dl_test.cpp", 497 ], 498 include_dirs: [ 499 "bionic/libc", 500 ], 501 static_libs: [ 502 "liblog", 503 "libbase", 504 ], 505 shared: { 506 enabled: false, 507 }, 508 cflags: [ 509 "-fno-emulated-tls", 510 ], 511 // With fuzzer builds, compiler instrumentation generates a reference to the 512 // __sancov_lowest_stack variable, which (for now) is defined by the fuzzer 513 // library as an emutls symbol. The -fno-emulated-tls flag above configures 514 // the compiler to reference an ordinary ELF TLS __sancov_lowest_stack 515 // symbol instead, which isn't defined. Disable the fuzzer for this test 516 // until the platform is switched to ELF TLS. 517 sanitize: { 518 fuzzer: false, 519 }, 520} 521 522cc_test_library { 523 name: "libBionicFramePointerTests", 524 defaults: ["bionic_tests_defaults"], 525 srcs: [ 526 "android_unsafe_frame_pointer_chase_test.cpp", 527 ], 528 include_dirs: [ 529 "bionic/libc", 530 ], 531 cflags: [ 532 "-fno-omit-frame-pointer", 533 ], 534} 535 536// ----------------------------------------------------------------------------- 537// Fortify tests. 538// ----------------------------------------------------------------------------- 539 540cc_defaults { 541 name: "bionic_clang_fortify_tests_w_flags", 542 cflags: [ 543 "-Wno-builtin-memcpy-chk-size", 544 "-Wno-format-security", 545 "-Wno-format-zero-length", 546 "-Wno-fortify-source", 547 "-Wno-memset-transposed-args", 548 "-Wno-strlcpy-strlcat-size", 549 "-Wno-strncat-size", 550 ], 551} 552 553cc_defaults { 554 name: "bionic_fortify_tests_defaults", 555 cflags: [ 556 "-U_FORTIFY_SOURCE", 557 ], 558 srcs: ["fortify_test_main.cpp"], 559 target: { 560 host: { 561 clang_cflags: ["-D__clang__"], 562 }, 563 }, 564} 565 566// Ensures that FORTIFY checks aren't run when ASAN is on. 567cc_test { 568 name: "bionic-fortify-runtime-asan-test", 569 defaults: [ 570 "bionic_clang_fortify_tests_w_flags", 571 ], 572 cflags: [ 573 "-Werror", 574 "-D_FORTIFY_SOURCE=2", 575 ], 576 sanitize: { 577 address: true, 578 }, 579 srcs: ["clang_fortify_asan.cpp"], 580} 581 582// Ensure we don't use FORTIFY'ed functions with the static analyzer/clang-tidy: 583// it can confuse these tools pretty easily. If this builds successfully, then 584// __clang_analyzer__ overrode FORTIFY. Otherwise, FORTIFY was incorrectly 585// enabled. The library that results from building this is meant to be unused. 586cc_test_library { 587 name: "fortify_disabled_for_tidy", 588 defaults: [ 589 "bionic_clang_fortify_tests_w_flags", 590 ], 591 cflags: [ 592 "-Werror", 593 "-D_FORTIFY_SOURCE=2", 594 "-D__clang_analyzer__", 595 ], 596 srcs: ["clang_fortify_tests.cpp"], 597} 598 599cc_test_library { 600 name: "libfortify1-tests-clang", 601 defaults: [ 602 "bionic_fortify_tests_defaults", 603 "bionic_tests_defaults", 604 ], 605 cflags: [ 606 "-D_FORTIFY_SOURCE=1", 607 "-DTEST_NAME=Fortify1_clang", 608 ], 609 shared: { 610 enabled: false, 611 }, 612} 613 614cc_test_library { 615 name: "libfortify2-tests-clang", 616 defaults: [ 617 "bionic_fortify_tests_defaults", 618 "bionic_tests_defaults", 619 ], 620 cflags: [ 621 "-D_FORTIFY_SOURCE=2", 622 "-DTEST_NAME=Fortify2_clang", 623 ], 624 shared: { 625 enabled: false, 626 }, 627} 628 629cc_defaults { 630 name: "bionic_new_fortify_tests_defaults", 631 defaults: [ 632 "bionic_clang_fortify_tests_w_flags", 633 ], 634 cflags: [ 635 "-U_FORTIFY_SOURCE", 636 ], 637 srcs: ["clang_fortify_tests.cpp"], 638 target: { 639 host: { 640 clang_cflags: ["-D__clang__"], 641 }, 642 }, 643} 644 645cc_test_library { 646 name: "libfortify1-new-tests-clang", 647 defaults: [ 648 "bionic_new_fortify_tests_defaults", 649 "bionic_tests_defaults", 650 ], 651 cflags: [ 652 "-D_FORTIFY_SOURCE=1", 653 "-DTEST_NAME=Fortify1_clang_new", 654 ], 655 shared: { 656 enabled: false, 657 }, 658} 659 660cc_test_library { 661 name: "libfortify2-new-tests-clang", 662 defaults: [ 663 "bionic_new_fortify_tests_defaults", 664 "bionic_tests_defaults", 665 ], 666 cflags: [ 667 "-D_FORTIFY_SOURCE=2", 668 "-DTEST_NAME=Fortify2_clang_new", 669 ], 670 shared: { 671 enabled: false, 672 }, 673} 674 675 676// ----------------------------------------------------------------------------- 677// Library of all tests (excluding the dynamic linker tests). 678// ----------------------------------------------------------------------------- 679cc_test_library { 680 name: "libBionicTests", 681 defaults: ["bionic_tests_defaults"], 682 whole_static_libs: [ 683 "libBionicStandardTests", 684 "libBionicElfTlsTests", 685 "libBionicFramePointerTests", 686 "libfortify1-tests-clang", 687 "libfortify1-new-tests-clang", 688 "libfortify2-tests-clang", 689 "libfortify2-new-tests-clang", 690 ], 691 shared: { 692 enabled: false, 693 }, 694} 695 696cc_test_library { 697 name: "libBionicLoaderTests", 698 defaults: [ 699 "bionic_tests_defaults", 700 "llvm-defaults", 701 ], 702 srcs: [ 703 "atexit_test.cpp", 704 "dl_test.cpp", 705 "dlfcn_symlink_support.cpp", 706 "dlfcn_test.cpp", 707 "link_test.cpp", 708 "pthread_dlfcn_test.cpp", 709 ], 710 static_libs: [ 711 "libbase", 712 ], 713 include_dirs: [ 714 "bionic/libc", 715 ], 716 shared: { 717 enabled: false, 718 }, 719 target: { 720 android: { 721 srcs: [ 722 "cfi_test.cpp", 723 "dlext_test.cpp", 724 "libdl_test.cpp", 725 ], 726 static_libs: [ 727 "libmeminfo", 728 "libprocinfo", 729 "libziparchive", 730 "libLLVMObject", 731 "libLLVMBitReader", 732 "libLLVMMC", 733 "libLLVMMCParser", 734 "libLLVMCore", 735 "libLLVMSupport", 736 ], 737 }, 738 }, 739} 740 741// ----------------------------------------------------------------------------- 742// Library of bionic customized gtest main function, with normal gtest output format, 743// which is needed by bionic cts test. 744// ----------------------------------------------------------------------------- 745cc_test_library { 746 name: "libBionicCtsGtestMain", 747 defaults: ["bionic_tests_defaults"], 748 srcs: [ 749 "gtest_globals_cts.cpp", 750 "gtest_main.cpp", 751 ], 752 shared: { 753 enabled: false, 754 }, 755 whole_static_libs: [ 756 "libgtest_isolated", 757 ], 758} 759 760// ----------------------------------------------------------------------------- 761// Tests for the device using bionic's .so. Run with: 762// adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests 763// adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests 764// ----------------------------------------------------------------------------- 765cc_defaults { 766 name: "bionic_unit_tests_defaults", 767 host_supported: false, 768 gtest: false, 769 770 defaults: [ 771 "bionic_tests_defaults", 772 ], 773 774 whole_static_libs: [ 775 "libBionicTests", 776 "libBionicLoaderTests", 777 "libBionicElfTlsLoaderTests", 778 ], 779 780 static_libs: [ 781 "libtinyxml2", 782 "liblog", 783 "libbase", 784 "libgtest_isolated", 785 ], 786 787 srcs: [ 788 // TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+) 789 "__cxa_thread_atexit_test.cpp", 790 "gtest_globals.cpp", 791 "gtest_main.cpp", 792 "thread_local_test.cpp", 793 ], 794 795 conlyflags: [ 796 "-fexceptions", 797 "-fnon-call-exceptions", 798 ], 799 800 ldflags: ["-Wl,--export-dynamic"], 801 802 include_dirs: ["bionic/libc"], 803 804 stl: "libc++_static", 805 806 target: { 807 android: { 808 shared_libs: [ 809 "ld-android", 810 "libdl", 811 "libdl_android", 812 "libdl_preempt_test_1", 813 "libdl_preempt_test_2", 814 "libdl_test_df_1_global", 815 "libtest_elftls_shared_var", 816 "libtest_elftls_tprel", 817 ], 818 static_libs: [ 819 // The order of these libraries matters, do not shuffle them. 820 "libbase", 821 "libmeminfo", 822 "libziparchive", 823 "libz", 824 "libutils", 825 "libLLVMObject", 826 "libLLVMBitReader", 827 "libLLVMMC", 828 "libLLVMMCParser", 829 "libLLVMCore", 830 "libLLVMSupport", 831 ], 832 ldflags: [ 833 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs", 834 "-Wl,--enable-new-dtags", 835 ], 836 }, 837 }, 838 839 required: [ 840 "cfi_test_helper", 841 "cfi_test_helper2", 842 "elftls_dlopen_ie_error_helper", 843 "exec_linker_helper", 844 "exec_linker_helper_lib", 845 "libtest_dt_runpath_a", 846 "libtest_dt_runpath_b", 847 "libtest_dt_runpath_c", 848 "libtest_dt_runpath_x", 849 "libtest_dt_runpath_y", 850 "libatest_simple_zip", 851 "libcfi-test", 852 "libcfi-test-bad", 853 "libdlext_test_different_soname", 854 "libdlext_test_fd", 855 "libdlext_test_norelro", 856 "libdlext_test_recursive", 857 "libdlext_test_runpath_zip_zipaligned", 858 "libdlext_test", 859 "libdlext_test_zip", 860 "libdlext_test_zip_zipaligned", 861 "libdl_preempt_test_1", 862 "libdl_preempt_test_2", 863 "libdl_test_df_1_global", 864 "libgnu-hash-table-library", 865 "librelocations-ANDROID_RELR", 866 "librelocations-ANDROID_REL", 867 "librelocations-RELR", 868 "librelocations-fat", 869 "libsysv-hash-table-library", 870 "libtestshared", 871 "libtest_atexit", 872 "libtest_check_order_dlsym_1_left", 873 "libtest_check_order_dlsym_2_right", 874 "libtest_check_order_dlsym_3_c", 875 "libtest_check_order_dlsym_a", 876 "libtest_check_order_dlsym_b", 877 "libtest_check_order_dlsym_d", 878 "libtest_check_order_dlsym", 879 "libtest_check_order_reloc_root_1", 880 "libtest_check_order_reloc_root_2", 881 "libtest_check_order_reloc_root", 882 "libtest_check_order_reloc_siblings_1", 883 "libtest_check_order_reloc_siblings_2", 884 "libtest_check_order_reloc_siblings_3", 885 "libtest_check_order_reloc_siblings_a", 886 "libtest_check_order_reloc_siblings_b", 887 "libtest_check_order_reloc_siblings_c_1", 888 "libtest_check_order_reloc_siblings_c_2", 889 "libtest_check_order_reloc_siblings_c", 890 "libtest_check_order_reloc_siblings_d", 891 "libtest_check_order_reloc_siblings_e", 892 "libtest_check_order_reloc_siblings_f", 893 "libtest_check_order_reloc_siblings", 894 "libtest_check_rtld_next_from_library", 895 "libtest_dlopen_df_1_global", 896 "libtest_dlopen_from_ctor_main", 897 "libtest_dlopen_from_ctor", 898 "libtest_dlopen_weak_undefined_func", 899 "libtest_dlsym_df_1_global", 900 "libtest_dlsym_from_this_child", 901 "libtest_dlsym_from_this_grandchild", 902 "libtest_dlsym_from_this", 903 "libtest_dlsym_weak_func", 904 "libtest_dt_runpath_d", 905 "libtest_elftls_dynamic", 906 "libtest_elftls_dynamic_filler_1", 907 "libtest_elftls_dynamic_filler_2", 908 "libtest_elftls_dynamic_filler_3", 909 "libtest_elftls_shared_var", 910 "libtest_elftls_shared_var_ie", 911 "libtest_elftls_tprel", 912 "libtest_empty", 913 "libtest_ifunc_variable_impl", 914 "libtest_ifunc_variable", 915 "libtest_ifunc", 916 "libtest_init_fini_order_child", 917 "libtest_init_fini_order_grand_child", 918 "libtest_init_fini_order_root2", 919 "libtest_init_fini_order_root", 920 "libtest_missing_symbol_child_public", 921 "libtest_missing_symbol_child_private", 922 "libtest_missing_symbol_root", 923 "libtest_missing_symbol", 924 "libtest_nodelete_1", 925 "libtest_nodelete_2", 926 "libtest_nodelete_dt_flags_1", 927 "libtest_pthread_atfork", 928 "libtest_relo_check_dt_needed_order_1", 929 "libtest_relo_check_dt_needed_order_2", 930 "libtest_relo_check_dt_needed_order", 931 "libtest_simple", 932 "libtest_two_parents_child", 933 "libtest_two_parents_parent1", 934 "libtest_two_parents_parent2", 935 "libtest_versioned_lib", 936 "libtest_versioned_libv1", 937 "libtest_versioned_libv2", 938 "libtest_versioned_otherlib_empty", 939 "libtest_versioned_otherlib", 940 "libtest_versioned_uselibv1", 941 "libtest_versioned_uselibv2_other", 942 "libtest_versioned_uselibv2", 943 "libtest_versioned_uselibv3_other", 944 "libtest_with_dependency_loop_a", 945 "libtest_with_dependency_loop_b", 946 "libtest_with_dependency_loop_c", 947 "libtest_with_dependency_loop", 948 "libtest_with_dependency", 949 "libtest_indirect_thread_local_dtor", 950 "libtest_invalid-empty_shdr_table", 951 "libtest_invalid-rw_load_segment", 952 "libtest_invalid-unaligned_shdr_offset", 953 "libtest_invalid-zero_shdr_table_content", 954 "libtest_invalid-zero_shdr_table_offset", 955 "libtest_invalid-zero_shentsize", 956 "libtest_invalid-zero_shstrndx", 957 "libtest_invalid-textrels", 958 "libtest_invalid-textrels2", 959 "libtest_thread_local_dtor", 960 "libtest_thread_local_dtor2", 961 "preinit_getauxval_test_helper", 962 "preinit_syscall_test_helper", 963 "libnstest_private_external", 964 "libnstest_dlopened", 965 "libnstest_private", 966 "libnstest_root_not_isolated", 967 "libnstest_root", 968 "libnstest_public", 969 "libnstest_public_internal", 970 "libnstest_ns_a_public1", 971 "libnstest_ns_a_public1_internal", 972 "libnstest_ns_b_public2", 973 "libnstest_ns_b_public3", 974 "ns_hidden_child_helper", 975 "libns_hidden_child_global", 976 "libns_hidden_child_internal", 977 "libns_hidden_child_public", 978 "libns_hidden_child_app", 979 "libsegment_gap_inner", 980 "libsegment_gap_outer", 981 "ld_preload_test_helper", 982 "ld_preload_test_helper_lib1", 983 "ld_preload_test_helper_lib2", 984 "ld_config_test_helper", 985 "ld_config_test_helper_lib1", 986 "ld_config_test_helper_lib2", 987 "ld_config_test_helper_lib3", 988 ], 989} 990 991cc_test { 992 name: "bionic-unit-tests", 993 defaults: [ 994 "bionic_unit_tests_defaults", 995 ], 996} 997 998cc_test { 999 name: "bionic-stress-tests", 1000 defaults: [ 1001 "bionic_tests_defaults", 1002 ], 1003 1004 // For now, these tests run forever, so do not use the isolation framework. 1005 isolated: false, 1006 1007 srcs: [ 1008 "malloc_stress_test.cpp", 1009 ], 1010 1011 shared_libs: [ 1012 "libbase", 1013 ], 1014 1015 target: { 1016 android: { 1017 static_libs: [ 1018 "libmeminfo", 1019 "libprocinfo", 1020 ], 1021 }, 1022 }, 1023} 1024 1025// ----------------------------------------------------------------------------- 1026// Tests for the device linked against bionic's static library. Run with: 1027// adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static 1028// adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static 1029// ----------------------------------------------------------------------------- 1030cc_test { 1031 name: "bionic-unit-tests-static", 1032 gtest: false, 1033 defaults: ["bionic_tests_defaults"], 1034 host_supported: false, 1035 1036 srcs: [ 1037 "gtest_preinit_debuggerd.cpp", 1038 "gtest_globals.cpp", 1039 "gtest_main.cpp", 1040 1041 // The Bionic allocator has its own C++ API. It isn't packaged into its 1042 // own library, so it can only be tested when it's part of libc.a. 1043 "bionic_allocator_test.cpp", 1044 ], 1045 include_dirs: [ 1046 "bionic/libc", 1047 ], 1048 whole_static_libs: [ 1049 "libBionicTests", 1050 ], 1051 1052 static_libs: [ 1053 "libm", 1054 "libc", 1055 "libdl", 1056 "libtinyxml2", 1057 "liblog", 1058 "libbase", 1059 "libdebuggerd_handler", 1060 "libgtest_isolated", 1061 "libtest_elftls_shared_var", 1062 "libtest_elftls_tprel", 1063 ], 1064 1065 static_executable: true, 1066 stl: "libc++_static", 1067} 1068 1069// ----------------------------------------------------------------------------- 1070// Tests to run on the host and linked against glibc. Run with: 1071// cd bionic/tests; mm bionic-unit-tests-glibc-run 1072// ----------------------------------------------------------------------------- 1073 1074cc_test_host { 1075 name: "bionic-unit-tests-glibc", 1076 gtest: false, 1077 defaults: ["bionic_tests_defaults"], 1078 1079 srcs: [ 1080 "atexit_test.cpp", 1081 "dlfcn_symlink_support.cpp", 1082 "dlfcn_test.cpp", 1083 "dl_test.cpp", 1084 "gtest_globals.cpp", 1085 "gtest_main.cpp", 1086 "pthread_dlfcn_test.cpp", 1087 ], 1088 1089 shared_libs: [ 1090 "libdl_preempt_test_1", 1091 "libdl_preempt_test_2", 1092 "libdl_test_df_1_global", 1093 "libtest_elftls_shared_var", 1094 "libtest_elftls_tprel", 1095 ], 1096 1097 whole_static_libs: [ 1098 "libBionicStandardTests", 1099 "libBionicElfTlsTests", 1100 "libBionicElfTlsLoaderTests", 1101 "libfortify1-tests-clang", 1102 "libfortify2-tests-clang", 1103 ], 1104 1105 static_libs: [ 1106 "libbase", 1107 "liblog", 1108 "libcutils", 1109 "libgtest_isolated", 1110 ], 1111 1112 host_ldlibs: [ 1113 "-lresolv", 1114 "-lutil", 1115 ], 1116 1117 include_dirs: [ 1118 "bionic/libc", 1119 ], 1120 1121 ldflags: [ 1122 "-Wl,--rpath,${ORIGIN}/../bionic-loader-test-libs", 1123 "-Wl,--export-dynamic", 1124 ], 1125 1126 sanitize: { 1127 never: false, 1128 }, 1129 1130 target: { 1131 linux_bionic: { 1132 enabled: false, 1133 }, 1134 }, 1135} 1136 1137subdirs = ["*"] 1138