1// 2// Copyright (C) 2014 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 17package { 18 // See: http://go/android-license-faq 19 // A large-scale-change added 'default_applicable_licenses' to import 20 // all of the 'license_kinds' from "frameworks_native_license" 21 // to get the below license kinds: 22 // SPDX-license-identifier-Apache-2.0 23 default_applicable_licenses: ["frameworks_native_license"], 24} 25 26cc_defaults { 27 name: "binder_test_defaults", 28 cmake_snapshot_supported: true, 29 cflags: [ 30 "-Wall", 31 "-Werror", 32 "-Wformat", 33 "-Wpessimizing-move", 34 "-Wsign-compare", 35 "-Wunused-result", 36 "-Wzero-as-null-pointer-constant", 37 ], 38} 39 40cc_test { 41 name: "binderDriverInterfaceTest", 42 defaults: ["binder_test_defaults"], 43 header_libs: ["libbinder_headers"], 44 srcs: ["binderDriverInterfaceTest.cpp"], 45 shared_libs: [ 46 "libbinder", 47 ], 48 test_suites: [ 49 "general-tests", 50 "vts", 51 ], 52} 53 54cc_test { 55 name: "binderCacheUnitTest", 56 target: { 57 darwin: { 58 enabled: false, 59 }, 60 }, 61 srcs: [ 62 "binderCacheUnitTest.cpp", 63 ], 64 shared_libs: [ 65 "liblog", 66 "libbinder", 67 "libcutils", 68 "libutils", 69 ], 70 static_libs: [ 71 "libfakeservicemanager", 72 ], 73 defaults: [ 74 "libbinder_client_cache_flag", 75 "libbinder_addservice_cache_flag", 76 "libbinder_remove_cache_static_list_flag", 77 ], 78 test_suites: ["general-tests"], 79 require_root: true, 80} 81 82// unit test only, which can run on host and doesn't use /dev/binder 83cc_test { 84 name: "binderUnitTest", 85 host_supported: true, 86 target: { 87 darwin: { 88 enabled: false, 89 }, 90 }, 91 srcs: [ 92 "binderParcelUnitTest.cpp", 93 "binderBinderUnitTest.cpp", 94 "binderStatusUnitTest.cpp", 95 "binderMemoryHeapBaseUnitTest.cpp", 96 "binderRecordedTransactionTest.cpp", 97 "binderPersistableBundleTest.cpp", 98 ], 99 shared_libs: [ 100 "libbinder", 101 "libcutils", 102 "libutils", 103 ], 104 test_suites: ["general-tests"], 105} 106 107cc_test { 108 name: "binderRecordReplayTest", 109 srcs: ["binderRecordReplayTest.cpp"], 110 cflags: [ 111 "-DBINDER_WITH_KERNEL_IPC", 112 ], 113 shared_libs: [ 114 "libbinder", 115 "libcutils", 116 "libutils", 117 "liblog", 118 ], 119 static_libs: [ 120 "binderRecordReplayTestIface-cpp", 121 "binderReadParcelIface-cpp", 122 "libbinder_random_parcel_seeds", 123 "libbinder_random_parcel", 124 ], 125 test_suites: ["general-tests"], 126 require_root: true, 127} 128 129aidl_interface { 130 name: "binderRecordReplayTestIface", 131 unstable: true, 132 srcs: [ 133 "IBinderRecordReplayTest.aidl", 134 ], 135 imports: ["binderReadParcelIface"], 136 backend: { 137 java: { 138 enabled: true, 139 platform_apis: true, 140 }, 141 142 // TODO: switch from FileDescriptor to ParcelFileDescriptor 143 ndk: { 144 enabled: false, 145 }, 146 rust: { 147 enabled: false, 148 }, 149 }, 150} 151 152cc_test { 153 name: "binderLibTest", 154 defaults: ["binder_test_defaults"], 155 156 srcs: ["binderLibTest.cpp"], 157 shared_libs: [ 158 "libbase", 159 "libbinder", 160 "liblog", 161 "libprocessgroup", 162 "libutils", 163 ], 164 static_libs: [ 165 "libgmock", 166 ], 167 test_suites: [ 168 "general-tests", 169 "vts", 170 ], 171 require_root: true, 172} 173 174aidl_interface { 175 name: "binderRpcTestIface", 176 vendor_available: true, 177 host_supported: true, 178 cmake_snapshot_supported: true, 179 unstable: true, 180 srcs: [ 181 "BinderRpcTestClientInfo.aidl", 182 "BinderRpcTestServerConfig.aidl", 183 "BinderRpcTestServerInfo.aidl", 184 "IBinderRpcCallback.aidl", 185 "IBinderRpcSession.aidl", 186 "IBinderRpcTest.aidl", 187 "ParcelableCertificateData.aidl", 188 ], 189 flags: [ 190 "-Werror", 191 "-Wno-mixed-oneway", 192 ], 193 backend: { 194 java: { 195 enabled: false, 196 }, 197 }, 198} 199 200cc_library_static { 201 name: "libbinder_tls_test_utils", 202 host_supported: true, 203 vendor_available: true, 204 target: { 205 darwin: { 206 enabled: false, 207 }, 208 }, 209 defaults: [ 210 "binder_test_defaults", 211 "libbinder_tls_shared_deps", 212 ], 213 shared_libs: [ 214 "libbase", 215 "liblog", 216 ], 217 static_libs: [ 218 "libbinder_tls_static", 219 ], 220 srcs: [ 221 "RpcTlsTestUtils.cpp", 222 ], 223 export_include_dirs: [ 224 "include_tls_test_utils", 225 ], 226 visibility: [ 227 ":__subpackages__", 228 ], 229} 230 231cc_library_static { 232 name: "libbinder_test_utils", 233 host_supported: true, 234 vendor_available: true, 235 target: { 236 darwin: { 237 enabled: false, 238 }, 239 }, 240 defaults: [ 241 "binder_test_defaults", 242 ], 243 header_libs: [ 244 "libbinder_headers_base", 245 ], 246 shared_libs: [ 247 "libbase", 248 ], 249 srcs: [ 250 "FileUtils.cpp", 251 ], 252 visibility: [ 253 ":__subpackages__", 254 ], 255} 256 257cc_defaults { 258 name: "binderRpcTest_common_defaults", 259 host_supported: true, 260 cmake_snapshot_supported: true, 261 target: { 262 darwin: { 263 enabled: false, 264 }, 265 }, 266 defaults: [ 267 "binder_test_defaults", 268 ], 269 270 compile_multilib: "both", 271 multilib: { 272 lib32: { 273 suffix: "32", 274 }, 275 lib64: { 276 suffix: "64", 277 }, 278 }, 279 280 static_libs: [ 281 "libbinder_test_utils", 282 "libbinder_tls_static", 283 "libbinder_tls_test_utils", 284 "binderRpcTestIface-cpp", 285 "binderRpcTestIface-ndk", 286 ], 287} 288 289cc_defaults { 290 name: "binderRpcTest_service_defaults", 291 defaults: [ 292 "binderRpcTest_common_defaults", 293 ], 294 gtest: false, 295 auto_gen_config: false, 296 srcs: [ 297 "binderRpcTestCommon.cpp", 298 "binderRpcTestService.cpp", 299 ], 300} 301 302cc_defaults { 303 name: "binderRpcTest_defaults", 304 target: { 305 android: { 306 test_suites: ["vts"], 307 }, 308 }, 309 defaults: [ 310 "binderRpcTest_common_defaults", 311 ], 312 313 srcs: [ 314 "binderRpcTest.cpp", 315 "binderRpcTestCommon.cpp", 316 "binderRpcUniversalTests.cpp", 317 ], 318 319 // This test uses a lot of resources and takes a long time. Due to 320 // design of several tests, it is also very sensitive to resource 321 // contention on the device. b/276820894 322 test_options: { 323 unit_test: false, 324 test_runner_options: [ 325 { 326 name: "native-test-timeout", 327 value: "10m", 328 }, 329 ], 330 }, 331 332 test_suites: ["general-tests"], 333 require_root: true, 334 335 data_bins: [ 336 "binder_rpc_test_service", 337 "binder_rpc_test_service_no_kernel", 338 "binder_rpc_test_service_single_threaded", 339 "binder_rpc_test_service_single_threaded_no_kernel", 340 ], 341} 342 343cc_defaults { 344 name: "binderRpcTest_shared_defaults", 345 cflags: [ 346 "-DBINDER_WITH_KERNEL_IPC", 347 ], 348 349 shared_libs: [ 350 "libbinder", 351 "libbinder_ndk", 352 "libbase", 353 "libutils", 354 "libcutils", 355 "liblog", 356 ], 357} 358 359cc_defaults { 360 name: "binderRpcTest_static_defaults", 361 362 shared_libs: [ 363 "liblog", 364 "libutils", 365 // libcrypto_static is not visible to this module 366 "libcrypto", 367 ], 368 static_libs: [ 369 "libbase", 370 "libcutils", 371 "libssl", 372 ], 373 374 cflags: [ 375 // Disable tests that require shared libraries, 376 // e.g., libbinder.so or libbinder_ndk.so 377 "-DBINDER_TEST_NO_SHARED_LIBS", 378 ], 379} 380 381cc_binary { 382 // The module name cannot start with "binderRpcTest" because 383 // then atest tries to execute it as part of binderRpcTest 384 name: "binder_rpc_test_service", 385 defaults: [ 386 "binderRpcTest_service_defaults", 387 "binderRpcTest_shared_defaults", 388 "libbinder_tls_shared_deps", 389 ], 390} 391 392cc_binary { 393 name: "binder_rpc_test_service_no_kernel", 394 defaults: [ 395 "binderRpcTest_service_defaults", 396 "binderRpcTest_static_defaults", 397 ], 398 static_libs: [ 399 "libbinder_rpc_no_kernel", 400 ], 401} 402 403cc_binary { 404 name: "binder_rpc_test_service_single_threaded", 405 defaults: [ 406 "binderRpcTest_service_defaults", 407 "binderRpcTest_static_defaults", 408 ], 409 cflags: [ 410 "-DBINDER_RPC_SINGLE_THREADED", 411 "-DBINDER_WITH_KERNEL_IPC", 412 ], 413 static_libs: [ 414 "libbinder_rpc_single_threaded", 415 ], 416} 417 418cc_binary { 419 name: "binder_rpc_test_service_single_threaded_no_kernel", 420 defaults: [ 421 "binderRpcTest_service_defaults", 422 "binderRpcTest_static_defaults", 423 ], 424 cflags: [ 425 "-DBINDER_RPC_SINGLE_THREADED", 426 ], 427 static_libs: [ 428 "libbinder_rpc_single_threaded_no_kernel", 429 ], 430 shared_libs: [ 431 "libbinder_ndk", 432 ], 433} 434 435cc_binary { 436 name: "binderRpcTestService_on_trusty_mock", 437 defaults: [ 438 "trusty_mock_defaults", 439 ], 440 441 srcs: [ 442 "binderRpcTestCommon.cpp", 443 "binderRpcTestServiceTrusty.cpp", 444 ], 445 446 shared_libs: [ 447 "libbinder_on_trusty_mock", 448 "libbase", 449 "libutils", 450 "libcutils", 451 ], 452 453 static_libs: [ 454 "binderRpcTestIface-cpp", 455 ], 456} 457 458cc_binary { 459 name: "binderRpcTest_on_trusty_mock", 460 defaults: [ 461 "trusty_mock_defaults", 462 ], 463 464 srcs: [ 465 "binderRpcUniversalTests.cpp", 466 "binderRpcTestCommon.cpp", 467 "binderRpcTestTrusty.cpp", 468 ], 469 470 shared_libs: [ 471 "libbinder_on_trusty_mock", 472 "libbase", 473 "libutils", 474 "libcutils", 475 ], 476 477 static_libs: [ 478 "binderRpcTestIface-cpp", 479 "libgtest", 480 ], 481} 482 483cc_test { 484 name: "binderRpcTest", 485 defaults: [ 486 "binderRpcTest_defaults", 487 "binderRpcTest_shared_defaults", 488 "libbinder_tls_shared_deps", 489 ], 490 491 // Add the Trusty mock library as a fake dependency so it gets built 492 required: [ 493 "libbinder_on_trusty_mock", 494 "libbinder_ndk_on_trusty_mock", 495 "libbinder_rs_on_trusty_mock", 496 "binderRpcTestService_on_trusty_mock", 497 "binderRpcTest_on_trusty_mock", 498 ], 499} 500 501cc_test { 502 name: "binderRpcTestNoKernel", 503 defaults: [ 504 "binderRpcTest_defaults", 505 "binderRpcTest_static_defaults", 506 ], 507 static_libs: [ 508 "libbinder_rpc_no_kernel", 509 ], 510} 511 512cc_test { 513 name: "binderRpcTestNoKernelAtAll", 514 defaults: [ 515 "binderRpcTest_defaults", 516 "binderRpcTest_static_defaults", 517 ], 518 static_libs: [ 519 "libbinder_rpc_no_kernel", 520 ], 521 cflags: [ 522 "-DBINDER_NO_KERNEL_IPC_TESTING", 523 ], 524} 525 526cc_test { 527 name: "binderRpcTestSingleThreaded", 528 defaults: [ 529 "binderRpcTest_defaults", 530 "binderRpcTest_static_defaults", 531 ], 532 cflags: [ 533 "-DBINDER_RPC_SINGLE_THREADED", 534 "-DBINDER_WITH_KERNEL_IPC", 535 ], 536 static_libs: [ 537 "libbinder_rpc_single_threaded", 538 ], 539 shared_libs: [ 540 "libbinder_ndk", 541 ], 542} 543 544cc_test { 545 name: "binderRpcTestSingleThreadedNoKernel", 546 defaults: [ 547 "binderRpcTest_defaults", 548 "binderRpcTest_static_defaults", 549 ], 550 cflags: [ 551 "-DBINDER_RPC_SINGLE_THREADED", 552 ], 553 static_libs: [ 554 "libbinder_rpc_single_threaded_no_kernel", 555 ], 556 shared_libs: [ 557 "libbinder_ndk", 558 ], 559} 560 561cc_test { 562 name: "binderRpcToTrustyTest", 563 vendor: true, 564 host_supported: false, 565 defaults: [ 566 "binderRpcTest_common_defaults", 567 "binderRpcTest_static_defaults", 568 ], 569 570 srcs: [ 571 "binderRpcTest.cpp", 572 "binderRpcTestCommon.cpp", 573 "binderRpcUniversalTests.cpp", 574 ], 575 576 cflags: [ 577 "-DBINDER_RPC_TO_TRUSTY_TEST", 578 ], 579 580 static_libs: [ 581 // We want to link libbinder statically so we can push the binary 582 // to the device for testing independently of the library 583 "libbinder_rpc_no_kernel", 584 "libbinder_trusty", 585 "libtrusty", 586 ], 587 588 test_suites: ["device-tests"], 589 require_root: true, 590} 591 592cc_test { 593 name: "RpcTlsUtilsTest", 594 host_supported: true, 595 target: { 596 darwin: { 597 enabled: false, 598 }, 599 android: { 600 test_suites: ["vts"], 601 }, 602 }, 603 defaults: [ 604 "binder_test_defaults", 605 "libbinder_tls_shared_deps", 606 ], 607 srcs: [ 608 "RpcTlsUtilsTest.cpp", 609 ], 610 shared_libs: [ 611 "libbinder", 612 "libbase", 613 "libutils", 614 "liblog", 615 ], 616 static_libs: [ 617 "libbinder_tls_test_utils", 618 "libbinder_tls_static", 619 ], 620 test_suites: [ 621 "general-tests", 622 "device-tests", 623 ], 624} 625 626cc_benchmark { 627 name: "binderRpcBenchmark", 628 defaults: [ 629 "binder_test_defaults", 630 "libbinder_tls_shared_deps", 631 ], 632 host_supported: true, 633 target: { 634 darwin: { 635 enabled: false, 636 }, 637 }, 638 srcs: [ 639 "binderRpcBenchmark.cpp", 640 "IBinderRpcBenchmark.aidl", 641 ], 642 shared_libs: [ 643 "libbase", 644 "libbinder", 645 "liblog", 646 "libutils", 647 ], 648 static_libs: [ 649 "libbinder_tls_test_utils", 650 "libbinder_tls_static", 651 ], 652} 653 654cc_test { 655 name: "binderRpcWireProtocolTest", 656 host_supported: true, 657 target: { 658 darwin: { 659 enabled: false, 660 }, 661 android: { 662 test_suites: ["vts"], 663 }, 664 }, 665 defaults: [ 666 "binder_test_defaults", 667 ], 668 srcs: [ 669 "binderRpcWireProtocolTest.cpp", 670 ], 671 shared_libs: [ 672 "libbinder", 673 "libbase", 674 "libutils", 675 "libcutils", 676 "liblog", 677 ], 678 test_suites: ["general-tests"], 679} 680 681cc_test { 682 name: "binderThroughputTest", 683 defaults: ["binder_test_defaults"], 684 srcs: ["binderThroughputTest.cpp"], 685 shared_libs: [ 686 "libbinder", 687 "libutils", 688 ], 689 cflags: [ 690 "-g", 691 "-Wno-missing-field-initializers", 692 "-Wno-sign-compare", 693 "-O3", 694 ], 695} 696 697cc_test { 698 name: "binderTextOutputTest", 699 defaults: ["binder_test_defaults"], 700 srcs: ["binderTextOutputTest.cpp"], 701 shared_libs: [ 702 "libbinder", 703 "libutils", 704 "libbase", 705 ], 706 test_suites: ["device-tests"], 707} 708 709cc_test { 710 name: "schd-dbg", 711 defaults: ["binder_test_defaults"], 712 srcs: ["schd-dbg.cpp"], 713 shared_libs: [ 714 "libbinder", 715 "libutils", 716 "libbase", 717 ], 718} 719 720cc_test { 721 name: "binderSafeInterfaceTest", 722 defaults: ["binder_test_defaults"], 723 srcs: ["binderSafeInterfaceTest.cpp"], 724 725 cppflags: [ 726 "-Wextra", 727 ], 728 729 cpp_std: "experimental", 730 gnu_extensions: false, 731 732 shared_libs: [ 733 "libbinder", 734 "libcutils", 735 "liblog", 736 "libutils", 737 ], 738 static_libs: [ 739 "libgmock", 740 ], 741 test_suites: [ 742 "general-tests", 743 "vts", 744 ], 745 require_root: true, 746} 747 748cc_test { 749 name: "binderClearBufTest", 750 defaults: ["binder_test_defaults"], 751 srcs: [ 752 "binderClearBufTest.cpp", 753 ], 754 755 shared_libs: [ 756 "libbase", 757 "libbinder", 758 "liblog", 759 "libutils", 760 ], 761 762 test_suites: ["general-tests"], 763 require_root: true, 764} 765 766aidl_interface { 767 name: "binderStabilityTestIface", 768 unstable: true, 769 srcs: [ 770 "IBinderStabilityTest.aidl", 771 ], 772 backend: { 773 java: { 774 enabled: false, 775 }, 776 }, 777} 778 779cc_test { 780 name: "binderStabilityTest", 781 defaults: ["binder_test_defaults"], 782 srcs: [ 783 "binderStabilityTest.cpp", 784 ], 785 786 // critical that libbinder/libbinder_ndk are shared for VTS 787 shared_libs: [ 788 "libbinder_ndk", 789 "libbinder", 790 "liblog", 791 "libutils", 792 ], 793 static_libs: [ 794 "binderStabilityTestIface-cpp", 795 "binderStabilityTestIface-ndk", 796 ], 797 798 test_suites: [ 799 "general-tests", 800 "vts", 801 ], 802 require_root: true, 803} 804 805cc_test { 806 name: "binderAllocationLimits", 807 defaults: ["binder_test_defaults"], 808 srcs: ["binderAllocationLimits.cpp"], 809 shared_libs: [ 810 "libbinder", 811 "liblog", 812 "libcutils", 813 "libutils", 814 "libutilscallstack", 815 "libbase", 816 ], 817 test_suites: ["device-tests"], 818 require_root: true, 819} 820 821cc_benchmark { 822 name: "binderParcelBenchmark", 823 defaults: ["binder_test_defaults"], 824 srcs: ["binderParcelBenchmark.cpp"], 825 shared_libs: [ 826 "libbase", 827 "libbinder", 828 "liblog", 829 "libutils", 830 ], 831 test_suites: ["general-tests"], 832} 833 834cc_test_host { 835 name: "binderUtilsHostTest", 836 defaults: ["binder_test_defaults"], 837 srcs: ["binderUtilsHostTest.cpp"], 838 shared_libs: [ 839 "libbase", 840 "libbinder", 841 ], 842 static_libs: [ 843 "libgmock", 844 ], 845 test_suites: ["general-tests"], 846 target: { 847 darwin: { 848 enabled: false, 849 }, 850 }, 851} 852 853cc_test_host { 854 name: "binderHostDeviceTest", 855 defaults: ["binder_test_defaults"], 856 srcs: ["binderHostDeviceTest.cpp"], 857 test_config: "binderHostDeviceTest.xml", 858 shared_libs: [ 859 "libbase", 860 "libbinder", 861 "liblog", 862 "libutils", 863 ], 864 static_libs: [ 865 "libgmock", 866 ], 867 target_required: [ 868 "binderHostDeviceTestService", 869 ], 870 test_suites: ["general-tests"], 871 target: { 872 darwin: { 873 enabled: false, 874 }, 875 }, 876 test_options: { 877 unit_test: false, 878 }, 879} 880 881cc_test { 882 name: "binderHostDeviceTestService", 883 // The binary is named differently from the module so that PushFilePreparer pushes the binary 884 // directly, not the test module directory. 885 stem: "binderHostDeviceTest-service", 886 defaults: ["binder_test_defaults"], 887 gtest: false, 888 auto_gen_config: false, 889 srcs: ["binderHostDeviceTestService.cpp"], 890 shared_libs: [ 891 "libbase", 892 "libbinder", 893 "liblog", 894 "libutils", 895 ], 896 test_suites: ["general-tests"], 897} 898 899cc_defaults { 900 name: "service_fuzzer_defaults", 901 static_libs: [ 902 "libbase", 903 "libbinder_random_parcel", 904 "libcutils", 905 ], 906 target: { 907 android: { 908 shared_libs: [ 909 "libbinder_ndk", 910 "libbinder", 911 "libutils", 912 ], 913 }, 914 host: { 915 static_libs: [ 916 "libbinder_ndk", 917 "libbinder", 918 "libutils", 919 ], 920 }, 921 darwin: { 922 enabled: false, 923 }, 924 }, 925 corpus: ["corpus/*"], 926 fuzz_config: { 927 cc: [ 928 "[email protected]", 929 "[email protected]", 930 ], 931 // Adds bugs to hotlist "AIDL fuzzers bugs" on buganizer 932 hotlists: ["4637097"], 933 use_for_presubmit: true, 934 }, 935} 936 937cc_defaults { 938 name: "fuzzer_disable_leaks", 939 fuzz_config: { 940 asan_options: [ 941 "detect_leaks=0", 942 ], 943 hwasan_options: [ 944 "detect_leaks=0", 945 ], 946 }, 947} 948