Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 537242c6 authored by Jingwen Chen's avatar Jingwen Chen
Browse files

Convert cc_test targets with bp2build.

Starting with libutils_test, adb_test, libcutils_test, (and ~47 other host_supported tests).

Test: $ b build --config=android_x86_64 //system/core/libutils:libutils_test && adb push bazel-bin/system/core/libutils/. /data/tmp/libutils_test_files/ && adb shell /data/tmp/libutils_test_files/libutils_test
Test: presubmits with newly converted cc_test targets
Test: $ b test //system/... --config=linux_x86_64 --verbose_failures --test_output=errors --keep_going --build_tests_only

Fixes: 242038415

Change-Id: I10051aadb880c3aabeba6d7fb079523e6fb4ac43
parent bf9c26c3
Loading
Loading
Loading
Loading
+474 −19
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ var (
		"external/lzma/C":                        Bp2BuildDefaultTrueRecursively,
		"external/mdnsresponder":                 Bp2BuildDefaultTrueRecursively,
		"external/minijail":                      Bp2BuildDefaultTrueRecursively,
		"external/openscreen":                    Bp2BuildDefaultTrueRecursively,
		"external/pcre":                          Bp2BuildDefaultTrueRecursively,
		"external/protobuf":                      Bp2BuildDefaultTrueRecursively,
		"external/python/six":                    Bp2BuildDefaultTrueRecursively,
@@ -225,6 +226,8 @@ var (
		"prebuilts/sdk/current/support":            Bp2BuildDefaultTrue,
		"prebuilts/tools/common/m2":                Bp2BuildDefaultTrue,

		"platform_testing/tests/example": Bp2BuildDefaultTrueRecursively,

		"system/apex":                                            Bp2BuildDefaultFalse, // TODO(b/207466993): flaky failures
		"system/apex/apexer":                                     Bp2BuildDefaultTrue,
		"system/apex/libs":                                       Bp2BuildDefaultTrueRecursively,
@@ -268,6 +271,7 @@ var (
		"system/memory/libion":                                   Bp2BuildDefaultTrueRecursively,
		"system/memory/libmemunreachable":                        Bp2BuildDefaultTrueRecursively,
		"system/sepolicy/apex":                                   Bp2BuildDefaultTrueRecursively,
		"system/testing/gtest_extras":                            Bp2BuildDefaultTrueRecursively,
		"system/timezone/apex":                                   Bp2BuildDefaultTrueRecursively,
		"system/timezone/output_data":                            Bp2BuildDefaultTrueRecursively,
		"system/tools/sysprop":                                   Bp2BuildDefaultTrue,
@@ -432,6 +436,8 @@ var (

		// needed for aidl_interface's ndk backend
		"libbinder_ndk",

		"libusb",
	}

	Bp2buildModuleTypeAlwaysConvertList = []string{
@@ -446,7 +452,13 @@ var (
		"libactivitymanager_aidl",                   // TODO(b/207426160): Unsupported use of aidl sources (via Dactivity_manager_procstate_aidl) in a cc_library
		"gen-kotlin-build-file.py",                  // TODO(b/198619163) module has same name as source
		"libgtest_ndk_c++", "libgtest_main_ndk_c++", // TODO(b/201816222): Requires sdk_version support.
		"linkerconfig", "mdnsd", // TODO(b/202876379): has arch-variant static_executable

		// TODO(b/202876379): has arch-variant static_executable
		"linkerconfig",
		"mdnsd",
		"libcutils_test_static",
		"KernelLibcutilsTest",

		"linker",                 // TODO(b/228316882): cc_binary uses link_crt
		"libdebuggerd",           // TODO(b/228314770): support product variable-specific header_libs
		"versioner",              // TODO(b/228313961):  depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library
@@ -516,7 +528,6 @@ var (
		"generated_android_icu4j_resources",                          // depends on unconverted modules: android_icu4j_srcgen_binary, soong_zip
		"generated_android_icu4j_test_resources",                     // depends on unconverted modules: android_icu4j_srcgen_binary, soong_zip
		"host-libprotobuf-java-nano",                                 // b/220869005, depends on libprotobuf-java-nano
		"libadb_host",                                                // depends on unconverted modules: AdbWinApi, libopenscreen-discovery, libopenscreen-platform-impl, libusb
		"libapexutil",                                                // depends on unconverted modules: apex-info-list-tinyxml
		"libart",                                                     // depends on unconverted modules: apex-info-list-tinyxml, libtinyxml2, libnativeloader-headers, heapprofd_client_api, art_operator_srcs, libcpu_features, libodrstatslog, libelffile, art_cmdlineparser_headers, cpp-define-generator-definitions, libdexfile, libnativebridge, libnativeloader, libsigchain, libartbase, libprofile, cpp-define-generator-asm-support
		"libart-runtime-gtest",                                       // depends on unconverted modules: libgtest_isolated, libart-compiler, libdexfile, libprofile, libartbase, libartbase-art-gtest
@@ -555,23 +566,467 @@ var (
		// '//bionic/libc:libc_bp2build_cc_library_static' is duplicated in the 'deps' attribute of rule
		"toybox-static",

		// Do not convert the following modules because of duplicate labels checking in Bazel.
		// See b/241283350. They should be removed from this list once the bug is fixed.
		"libartpalette",
		"libartbase",
		"libdexfile",
		"libartbased",
		"libdexfile_static",
		"libartbase-testing",
		"libartbased-testing",
		"libdexfile_support",
		"libunwindstack",
		"libunwindstack_local",
		"libfdtrack",
		"libc_malloc_debug",
		"libutilscallstack",
		"libunwindstack_utils",
		"unwind_for_offline",
		// cc_test related.
		// Failing host cc_tests
		"memunreachable_unit_test",
		"libprocinfo_test",
		"ziparchive-tests",
		"gtest_isolated_tests",
		"libunwindstack_unit_test",
		"task_profiles_test",
		"power_tests", // failing test on server, but not on host

		// reflect: call of reflect.Value.NumField on interface Value
		// affects all cc_tests that depend on art_defaults
		"libnativebridge-tests",
		"libnativeloader_test",
		"art_libnativebridge_cts_tests",
		"art_standalone_libdexfile_external_tests",
		"art_standalone_libdexfile_support_tests",
		"libnativebridge-lazy-tests",
		"libnativebridge-test-case",
		"libnativebridge2-test-case",
		"libnativebridge3-test-case",
		"libnativebridge6-test-case",
		"libnativebridge6prezygotefork",

		// cc_test with unconverted deps, or are device-only (and not verified to pass yet)
		"AMRWBEncTest",
		"AmrnbDecoderTest", // depends on unconverted modules: libaudioutils, libsndfile
		"AmrnbEncoderTest", // depends on unconverted modules: libaudioutils, libsndfile
		"AmrwbDecoderTest", // depends on unconverted modules: libsndfile, libaudioutils
		"AmrwbEncoderTest", // depends on unconverted modules: libaudioutils, libsndfile
		"CtsLiblogTestCases",
		"Mp3DecoderTest",       // depends on unconverted modules: libsndfile, libaudioutils
		"Mpeg4H263DecoderTest", // depends on unconverted modules: libstagefright_foundation
		"Mpeg4H263EncoderTest",
		"adb_crypto_test",
		"adb_pairing_auth_test",
		"adb_pairing_connection_test",
		"adb_tls_connection_test",
		"adbd_test", // depends on unconverted modules: libusb
		"avcdec",
		"avcenc",
		"bionic-benchmarks-tests",
		"bionic-fortify-runtime-asan-test",
		"bionic-stress-tests",
		"bionic-unit-tests",
		"bionic-unit-tests-glibc",
		"bionic-unit-tests-static",
		"boringssl_crypto_test",
		"boringssl_ssl_test",
		"cfi_test_helper",
		"cfi_test_helper2",
		"cintltst32",
		"cintltst64",
		"compare",
		"cpuid",
		"debuggerd_test", // depends on unconverted modules: libdebuggerd
		"elftls_dlopen_ie_error_helper",
		"exec_linker_helper",
		"fastdeploy_test", // depends on unconverted modules: AdbWinApi, libadb_host, libandroidfw, libfastdeploy_host, libopenscreen-discovery, libopenscreen-platform-impl, libusb
		"fdtrack_test",
		"google-benchmark-test",
		"googletest-param-test-test_ndk", // depends on unconverted modules: libgtest_ndk_c++
		"gtest-typed-test_test",
		"gtest-typed-test_test_ndk", // depends on unconverted modules: libgtest_ndk_c++, libgtest_main_ndk_c++
		"gtest_ndk_tests",           // depends on unconverted modules: libgtest_ndk_c++, libgtest_main_ndk_c++
		"gtest_ndk_tests_no_main",   // depends on unconverted modules: libgtest_ndk_c++
		"gtest_prod_test_ndk",       // depends on unconverted modules: libgtest_ndk_c++, libgtest_main_ndk_c++
		"gtest_tests",
		"gtest_tests_no_main",
		"gwp_asan_unittest",
		"half_test",
		"hashcombine_test",
		"hevcdec",
		"hevcenc",
		"hwbinderThroughputTest", // depends on unconverted modules: android.hardware.tests.libhwbinder@1.0-impl.test, android.hardware.tests.libhwbinder@1.0
		"i444tonv12_eg",
		"icu4c_sample_break",
		"intltest32",
		"intltest64",
		"ion-unit-tests",
		"jemalloc5_integrationtests",
		"jemalloc5_unittests",
		"ld_config_test_helper",
		"ld_preload_test_helper",
		"libBionicCtsGtestMain", // depends on unconverted modules: libgtest_isolated
		"libBionicLoaderTests",  // depends on unconverted modules: libmeminfo
		"libapexutil_tests",     // depends on unconverted modules: apex-info-list-tinyxml, libapexutil
		"libavservices_minijail_unittest",
		"libcutils_sockets_test",
		"libexpectedutils_test",
		"libhwbinder_latency",
		"liblog-host-test",
		"liblog-unit-tests",
		"libminijail_test",
		"libminijail_unittest_gtest",
		"libpackagelistparser_test",
		"libprotobuf_vendor_suffix_test",
		"libstagefright_amrnbdec_test", // depends on unconverted modules: libsndfile, libaudioutils
		"libstagefright_amrnbenc_test",
		"libstagefright_amrwbdec_test", // depends on unconverted modules: libsndfile, libaudioutils
		"libstagefright_m4vh263enc_test",
		"libstagefright_mp3dec_test", // depends on unconverted modules: libsndfile, libaudioutils
		"libstatssocket_test",
		"libvndksupport-tests",
		"libyuv_unittest",
		"linker-unit-tests",
		"malloc_debug_system_tests",
		"malloc_debug_unit_tests",
		"malloc_hooks_system_tests",
		"mat_test",
		"mathtest",
		"memunreachable_binder_test", // depends on unconverted modules: libbinder
		"memunreachable_test",
		"metadata_tests",
		"minijail0_cli_unittest_gtest",
		"mpeg2dec",
		"mvcdec",
		"ns_hidden_child_helper",
		"pngtest",
		"preinit_getauxval_test_helper",
		"preinit_syscall_test_helper",
		"psnr",
		"quat_test",
		"rappor-tests", // depends on unconverted modules: jsr305, guava
		"scudo_unit_tests",
		"stats-log-api-gen-test", // depends on unconverted modules: libstats_proto_host
		"syscall_filter_unittest_gtest",
		"sysprop_test", // depends on unconverted modules: libcom.android.sysprop.tests
		"thread_exit_cb_helper",
		"tls_properties_helper",
		"ulp",
		"vec_test",
		"yuvconstants",
		"yuvconvert",
		"zipalign_tests",
		// "zlib_tests",

		// cc_test_library
		"clang_diagnostic_tests",
		"exec_linker_helper_lib",
		"fortify_disabled_for_tidy",
		"ld_config_test_helper_lib1",
		"ld_config_test_helper_lib2",
		"ld_config_test_helper_lib3",
		"ld_preload_test_helper_lib1",
		"ld_preload_test_helper_lib2",
		"libBionicElfTlsLoaderTests",
		"libBionicElfTlsTests",
		"libBionicElfTlsTests",
		"libBionicFramePointerTests",
		"libBionicFramePointerTests",
		"libBionicStandardTests",
		"libBionicStandardTests",
		"libBionicTests",
		"libart-broken",
		"libatest_simple_zip",
		"libcfi-test",
		"libcfi-test-bad",
		"libcrash_test",
		// "libcrypto_fuzz_unsafe",
		"libdl_preempt_test_1",
		"libdl_preempt_test_2",
		"libdl_test_df_1_global",
		"libdlext_test",
		"libdlext_test_different_soname",
		"libdlext_test_fd",
		"libdlext_test_norelro",
		"libdlext_test_recursive",
		"libdlext_test_zip",
		"libfortify1-new-tests-clang",
		"libfortify1-new-tests-clang",
		"libfortify1-tests-clang",
		"libfortify1-tests-clang",
		"libfortify2-new-tests-clang",
		"libfortify2-new-tests-clang",
		"libfortify2-tests-clang",
		"libfortify2-tests-clang",
		"libgnu-hash-table-library",
		"libicutest_static",
		"liblinker_reloc_bench_000",
		"liblinker_reloc_bench_001",
		"liblinker_reloc_bench_002",
		"liblinker_reloc_bench_003",
		"liblinker_reloc_bench_004",
		"liblinker_reloc_bench_005",
		"liblinker_reloc_bench_006",
		"liblinker_reloc_bench_007",
		"liblinker_reloc_bench_008",
		"liblinker_reloc_bench_009",
		"liblinker_reloc_bench_010",
		"liblinker_reloc_bench_011",
		"liblinker_reloc_bench_012",
		"liblinker_reloc_bench_013",
		"liblinker_reloc_bench_014",
		"liblinker_reloc_bench_015",
		"liblinker_reloc_bench_016",
		"liblinker_reloc_bench_017",
		"liblinker_reloc_bench_018",
		"liblinker_reloc_bench_019",
		"liblinker_reloc_bench_020",
		"liblinker_reloc_bench_021",
		"liblinker_reloc_bench_022",
		"liblinker_reloc_bench_023",
		"liblinker_reloc_bench_024",
		"liblinker_reloc_bench_025",
		"liblinker_reloc_bench_026",
		"liblinker_reloc_bench_027",
		"liblinker_reloc_bench_028",
		"liblinker_reloc_bench_029",
		"liblinker_reloc_bench_030",
		"liblinker_reloc_bench_031",
		"liblinker_reloc_bench_032",
		"liblinker_reloc_bench_033",
		"liblinker_reloc_bench_034",
		"liblinker_reloc_bench_035",
		"liblinker_reloc_bench_036",
		"liblinker_reloc_bench_037",
		"liblinker_reloc_bench_038",
		"liblinker_reloc_bench_039",
		"liblinker_reloc_bench_040",
		"liblinker_reloc_bench_041",
		"liblinker_reloc_bench_042",
		"liblinker_reloc_bench_043",
		"liblinker_reloc_bench_044",
		"liblinker_reloc_bench_045",
		"liblinker_reloc_bench_046",
		"liblinker_reloc_bench_047",
		"liblinker_reloc_bench_048",
		"liblinker_reloc_bench_049",
		"liblinker_reloc_bench_050",
		"liblinker_reloc_bench_051",
		"liblinker_reloc_bench_052",
		"liblinker_reloc_bench_053",
		"liblinker_reloc_bench_054",
		"liblinker_reloc_bench_055",
		"liblinker_reloc_bench_056",
		"liblinker_reloc_bench_057",
		"liblinker_reloc_bench_058",
		"liblinker_reloc_bench_059",
		"liblinker_reloc_bench_060",
		"liblinker_reloc_bench_061",
		"liblinker_reloc_bench_062",
		"liblinker_reloc_bench_063",
		"liblinker_reloc_bench_064",
		"liblinker_reloc_bench_065",
		"liblinker_reloc_bench_066",
		"liblinker_reloc_bench_067",
		"liblinker_reloc_bench_068",
		"liblinker_reloc_bench_069",
		"liblinker_reloc_bench_070",
		"liblinker_reloc_bench_071",
		"liblinker_reloc_bench_072",
		"liblinker_reloc_bench_073",
		"liblinker_reloc_bench_074",
		"liblinker_reloc_bench_075",
		"liblinker_reloc_bench_076",
		"liblinker_reloc_bench_077",
		"liblinker_reloc_bench_078",
		"liblinker_reloc_bench_079",
		"liblinker_reloc_bench_080",
		"liblinker_reloc_bench_081",
		"liblinker_reloc_bench_082",
		"liblinker_reloc_bench_083",
		"liblinker_reloc_bench_084",
		"liblinker_reloc_bench_085",
		"liblinker_reloc_bench_086",
		"liblinker_reloc_bench_087",
		"liblinker_reloc_bench_088",
		"liblinker_reloc_bench_089",
		"liblinker_reloc_bench_090",
		"liblinker_reloc_bench_091",
		"liblinker_reloc_bench_092",
		"liblinker_reloc_bench_093",
		"liblinker_reloc_bench_094",
		"liblinker_reloc_bench_095",
		"liblinker_reloc_bench_096",
		"liblinker_reloc_bench_097",
		"liblinker_reloc_bench_098",
		"liblinker_reloc_bench_099",
		"liblinker_reloc_bench_100",
		"liblinker_reloc_bench_101",
		"liblinker_reloc_bench_102",
		"liblinker_reloc_bench_103",
		"liblinker_reloc_bench_104",
		"liblinker_reloc_bench_105",
		"liblinker_reloc_bench_106",
		"liblinker_reloc_bench_107",
		"liblinker_reloc_bench_108",
		"liblinker_reloc_bench_109",
		"liblinker_reloc_bench_110",
		"liblinker_reloc_bench_111",
		"liblinker_reloc_bench_112",
		"liblinker_reloc_bench_113",
		"liblinker_reloc_bench_114",
		"liblinker_reloc_bench_115",
		"liblinker_reloc_bench_116",
		"liblinker_reloc_bench_117",
		"liblinker_reloc_bench_118",
		"liblinker_reloc_bench_119",
		"liblinker_reloc_bench_120",
		"liblinker_reloc_bench_121",
		"liblinker_reloc_bench_122",
		"liblinker_reloc_bench_123",
		"liblinker_reloc_bench_124",
		"liblinker_reloc_bench_125",
		"liblinker_reloc_bench_126",
		"liblinker_reloc_bench_127",
		"liblinker_reloc_bench_128",
		"liblinker_reloc_bench_129",
		"liblinker_reloc_bench_130",
		"liblinker_reloc_bench_131",
		"liblinker_reloc_bench_132",
		"liblinker_reloc_bench_133",
		"liblinker_reloc_bench_134",
		"liblinker_reloc_bench_135",
		"liblinker_reloc_bench_136",
		"liblinker_reloc_bench_137",
		"liblinker_reloc_bench_138",
		"liblinker_reloc_bench_139",
		"liblinker_reloc_bench_140",
		"liblinker_reloc_bench_141",
		"liblinker_reloc_bench_142",
		"liblinker_reloc_bench_143",
		"liblinker_reloc_bench_144",
		"liblinker_reloc_bench_145",
		"liblinker_reloc_bench_146",
		"liblinker_reloc_bench_147",
		"liblinker_reloc_bench_148",
		"liblinker_reloc_bench_149",
		"liblinker_reloc_bench_150",
		"liblinker_reloc_bench_151",
		"liblinker_reloc_bench_152",
		"liblinker_reloc_bench_153",
		"liblinker_reloc_bench_154",
		"liblinker_reloc_bench_155",
		"liblinker_reloc_bench_156",
		"liblinker_reloc_bench_157",
		"liblinker_reloc_bench_158",
		"liblinker_reloc_bench_159",
		"liblinker_reloc_bench_160",
		"liblinker_reloc_bench_161",
		"liblinker_reloc_bench_162",
		"liblinker_reloc_bench_163",
		"liblinker_reloc_bench_164",
		"liblinker_reloc_bench_165",
		"liblinker_reloc_bench_166",
		"liblinker_reloc_bench_167",
		"liblinker_reloc_bench_168",
		"libns_hidden_child_app",
		"libns_hidden_child_global",
		"libns_hidden_child_internal",
		"libns_hidden_child_public",
		"libnstest_dlopened",
		"libnstest_ns_a_public1",
		"libnstest_ns_a_public1_internal",
		"libnstest_ns_b_public2",
		"libnstest_ns_b_public3",
		"libnstest_private",
		"libnstest_private_external",
		"libnstest_public",
		"libnstest_public_internal",
		"libnstest_root",
		"libnstest_root_not_isolated",
		"librelocations-ANDROID_REL",
		"librelocations-ANDROID_RELR",
		"librelocations-RELR",
		"librelocations-fat",
		"libsegment_gap_inner",
		"libsegment_gap_outer",
		// "libssl_fuzz_unsafe",
		"libstatssocket_private",
		"libsysv-hash-table-library",
		"libtest_atexit",
		"libtest_check_order_dlsym",
		"libtest_check_order_dlsym_1_left",
		"libtest_check_order_dlsym_2_right",
		"libtest_check_order_dlsym_3_c",
		"libtest_check_order_dlsym_a",
		"libtest_check_order_dlsym_b",
		"libtest_check_order_dlsym_d",
		"libtest_check_order_reloc_root",
		"libtest_check_order_reloc_root_1",
		"libtest_check_order_reloc_root_2",
		"libtest_check_order_reloc_siblings",
		"libtest_check_order_reloc_siblings_1",
		"libtest_check_order_reloc_siblings_2",
		"libtest_check_order_reloc_siblings_3",
		"libtest_check_order_reloc_siblings_a",
		"libtest_check_order_reloc_siblings_b",
		"libtest_check_order_reloc_siblings_c",
		"libtest_check_order_reloc_siblings_c_1",
		"libtest_check_order_reloc_siblings_c_2",
		"libtest_check_order_reloc_siblings_d",
		"libtest_check_order_reloc_siblings_e",
		"libtest_check_order_reloc_siblings_f",
		"libtest_check_rtld_next_from_library",
		"libtest_dlopen_df_1_global",
		"libtest_dlopen_from_ctor",
		"libtest_dlopen_from_ctor_main",
		"libtest_dlopen_weak_undefined_func",
		"libtest_dlsym_df_1_global",
		"libtest_dlsym_from_this",
		"libtest_dlsym_from_this_child",
		"libtest_dlsym_from_this_grandchild",
		"libtest_dlsym_weak_func",
		"libtest_dt_runpath_a",
		"libtest_dt_runpath_b",
		"libtest_dt_runpath_c",
		"libtest_dt_runpath_d",
		"libtest_dt_runpath_d_zip",
		"libtest_dt_runpath_x",
		"libtest_dt_runpath_y",
		"libtest_elftls_dynamic",
		"libtest_elftls_dynamic_filler_1",
		"libtest_elftls_dynamic_filler_2",
		"libtest_elftls_dynamic_filler_3",
		"libtest_elftls_shared_var",
		"libtest_elftls_shared_var_ie",
		"libtest_elftls_tprel",
		"libtest_empty",
		"libtest_ifunc",
		"libtest_ifunc_variable",
		"libtest_ifunc_variable_impl",
		"libtest_indirect_thread_local_dtor",
		"libtest_init_fini_order_child",
		"libtest_init_fini_order_grand_child",
		"libtest_init_fini_order_root",
		"libtest_init_fini_order_root2",
		"libtest_missing_symbol",
		"libtest_missing_symbol_child_private",
		"libtest_missing_symbol_child_public",
		"libtest_missing_symbol_root",
		"libtest_nodelete_1",
		"libtest_nodelete_2",
		"libtest_nodelete_dt_flags_1",
		"libtest_pthread_atfork",
		"libtest_relo_check_dt_needed_order",
		"libtest_relo_check_dt_needed_order_1",
		"libtest_relo_check_dt_needed_order_2",
		"libtest_simple",
		"libtest_thread_local_dtor",
		"libtest_thread_local_dtor2",
		"libtest_two_parents_child",
		"libtest_two_parents_parent1",
		"libtest_two_parents_parent2",
		"libtest_versioned_lib",
		"libtest_versioned_libv1",
		"libtest_versioned_libv2",
		"libtest_versioned_otherlib",
		"libtest_versioned_otherlib_empty",
		"libtest_versioned_uselibv1",
		"libtest_versioned_uselibv2",
		"libtest_versioned_uselibv2_other",
		"libtest_versioned_uselibv3_other",
		"libtest_with_dependency",
		"libtest_with_dependency_loop",
		"libtest_with_dependency_loop_a",
		"libtest_with_dependency_loop_b",
		"libtest_with_dependency_loop_b_tmp",
		"libtest_with_dependency_loop_c",
		"libtestshared",
	}

	Bp2buildCcLibraryStaticOnlyList = []string{}
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ bootstrap_go_package {
        "cc_prebuilt_library_conversion_test.go",
        "cc_prebuilt_library_shared_test.go",
        "cc_prebuilt_library_static_test.go",
        "cc_test_conversion_test.go",
        "cc_yasm_conversion_test.go",
        "conversion_test.go",
        "filegroup_conversion_test.go",
+150 −0
Original line number Diff line number Diff line
// Copyright 2022 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bp2build

import (
	"fmt"
	"testing"

	"android/soong/android"
	"android/soong/cc"
	"android/soong/genrule"
)

type ccTestBp2buildTestCase struct {
	description string
	blueprint   string
	targets     []testBazelTarget
}

func registerCcTestModuleTypes(ctx android.RegistrationContext) {
	cc.RegisterCCBuildComponents(ctx)
	ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
	ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
	ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
	ctx.RegisterModuleType("cc_test_library", cc.TestLibraryFactory)
	ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
}

func runCcTestTestCase(t *testing.T, testCase ccTestBp2buildTestCase) {
	t.Helper()
	moduleTypeUnderTest := "cc_test"

	description := fmt.Sprintf("%s %s", moduleTypeUnderTest, testCase.description)
	t.Run(description, func(t *testing.T) {
		t.Helper()
		RunBp2BuildTestCase(t, registerCcTestModuleTypes, Bp2buildTestCase{
			ExpectedBazelTargets:       generateBazelTargetsForTest(testCase.targets, android.HostAndDeviceSupported),
			ModuleTypeUnderTest:        moduleTypeUnderTest,
			ModuleTypeUnderTestFactory: cc.TestFactory,
			Description:                description,
			Blueprint:                  testCase.blueprint,
		})
	})
}

func TestBasicCcTest(t *testing.T) {
	runCcTestTestCase(t, ccTestBp2buildTestCase{
		description: "basic cc_test with commonly used attributes",
		blueprint: `
cc_test {
    name: "mytest",
    host_supported: true,
    srcs: ["test.cpp"],
    target: {
        android: {
            srcs: ["android.cpp"],
            shared_libs: ["foolib"],
        },
        linux: {
            srcs: ["linux.cpp"],
        },
        host: {
            static_libs: ["hostlib"],
        },
    },
    data: [":data_mod", "file.txt"],
    data_bins: [":cc_bin"],
    data_libs: [":cc_lib"],
    cflags: ["-Wall"],
}
` + simpleModuleDoNotConvertBp2build("cc_library", "foolib") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "hostlib") +
			simpleModuleDoNotConvertBp2build("genrule", "data_mod") +
			simpleModuleDoNotConvertBp2build("cc_binary", "cc_bin") +
			simpleModuleDoNotConvertBp2build("cc_test_library", "cc_lib"),
		targets: []testBazelTarget{
			{"cc_test", "mytest", AttrNameToString{
				"copts": `["-Wall"]`,
				"data": `[
        ":data_mod",
        "file.txt",
        ":cc_bin",
        ":cc_lib",
    ]`,
				"deps": `select({
        "//build/bazel/platforms/os:darwin": [":hostlib"],
        "//build/bazel/platforms/os:linux": [":hostlib"],
        "//build/bazel/platforms/os:linux_bionic": [":hostlib"],
        "//build/bazel/platforms/os:linux_musl": [":hostlib"],
        "//build/bazel/platforms/os:windows": [":hostlib"],
        "//conditions:default": [],
    })`,
				"gtest":          "True",
				"isolated":       "True",
				"local_includes": `["."]`,
				"dynamic_deps": `select({
        "//build/bazel/platforms/os:android": [":foolib"],
        "//conditions:default": [],
    })`,
				"srcs": `["test.cpp"] + select({
        "//build/bazel/platforms/os:android": [
            "linux.cpp",
            "android.cpp",
        ],
        "//build/bazel/platforms/os:linux": ["linux.cpp"],
        "//build/bazel/platforms/os:linux_bionic": ["linux.cpp"],
        "//build/bazel/platforms/os:linux_musl": ["linux.cpp"],
        "//conditions:default": [],
    })`,
			},
			},
		},
	})
}

func TestBasicCcTestGtestIsolatedDisabled(t *testing.T) {
	runCcTestTestCase(t, ccTestBp2buildTestCase{
		description: "cc test with disabled gtest and isolated props",
		blueprint: `
cc_test {
    name: "mytest",
    host_supported: true,
    srcs: ["test.cpp"],
    gtest: false,
    isolated: false,
}
`,
		targets: []testBazelTarget{
			{"cc_test", "mytest", AttrNameToString{
				"gtest":          "False",
				"isolated":       "False",
				"local_includes": `["."]`,
				"srcs":           `["test.cpp"]`,
			},
			},
		},
	})
}
+11 −3

File changed.

Preview size limit exceeded, changes collapsed.

+27 −2

File changed.

Preview size limit exceeded, changes collapsed.

Loading