Merge "Refactor some tests to not use bp2build_avail" into main

This commit is contained in:
Christopher Parsons
2023-09-21 20:57:33 +00:00
committed by Gerrit Code Review
7 changed files with 21 additions and 33 deletions

View File

@@ -818,7 +818,7 @@ func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroid
Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp", Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp",
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"//a/b:com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{ Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": ` "system/sepolicy/apex/Android.bp": `
filegroup { filegroup {
@@ -828,7 +828,6 @@ filegroup {
"a/b/Android.bp": ` "a/b/Android.bp": `
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
bazel_module: { bp2build_available: false },
} }
`, `,
}, },
@@ -852,7 +851,7 @@ func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp
Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp", Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp",
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"//a/b:com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{ Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": ` "system/sepolicy/apex/Android.bp": `
filegroup { filegroup {
@@ -863,7 +862,6 @@ filegroup {
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
manifest: "apogee_manifest.json", manifest: "apogee_manifest.json",
bazel_module: { bp2build_available: false },
} }
`, `,
}, },
@@ -887,7 +885,7 @@ func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t
Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp", Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp",
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{ Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": ` "system/sepolicy/apex/Android.bp": `
filegroup { filegroup {
@@ -898,7 +896,6 @@ filegroup {
Blueprint: ` Blueprint: `
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
bazel_module: { bp2build_available: false },
} }
override_apex { override_apex {
@@ -920,7 +917,7 @@ func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *t
Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp", Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp",
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{ Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": ` "system/sepolicy/apex/Android.bp": `
filegroup { filegroup {
@@ -932,7 +929,6 @@ filegroup {
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
manifest: "apogee_manifest.json", manifest: "apogee_manifest.json",
bazel_module: { bp2build_available: false },
} }
override_apex { override_apex {
@@ -954,7 +950,7 @@ func TestApexBundleSimple_packageNameOverride(t *testing.T) {
Description: "override_apex - override package name", Description: "override_apex - override package name",
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{ Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": ` "system/sepolicy/apex/Android.bp": `
filegroup { filegroup {
@@ -965,7 +961,6 @@ filegroup {
Blueprint: ` Blueprint: `
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
bazel_module: { bp2build_available: false },
} }
override_apex { override_apex {
@@ -1109,7 +1104,7 @@ func TestApexBundleSimple_NoLoggingParentOverride(t *testing.T) {
Description: "override_apex - logging_parent - no override", Description: "override_apex - logging_parent - no override",
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{ Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": ` "system/sepolicy/apex/Android.bp": `
filegroup { filegroup {
@@ -1120,7 +1115,6 @@ filegroup {
Blueprint: ` Blueprint: `
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
bazel_module: { bp2build_available: false },
logging_parent: "foo.bar.baz", logging_parent: "foo.bar.baz",
} }
@@ -1144,7 +1138,7 @@ func TestApexBundleSimple_LoggingParentOverride(t *testing.T) {
Description: "override_apex - logging_parent - override", Description: "override_apex - logging_parent - override",
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{ Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": ` "system/sepolicy/apex/Android.bp": `
filegroup { filegroup {
@@ -1155,7 +1149,6 @@ filegroup {
Blueprint: ` Blueprint: `
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
bazel_module: { bp2build_available: false },
logging_parent: "foo.bar.baz", logging_parent: "foo.bar.baz",
} }
@@ -1398,7 +1391,7 @@ func TestBp2BuildOverrideApex_CertificateIsSrc(t *testing.T) {
ModuleTypeUnderTest: "override_apex", ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory, ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "com.android.apogee", "com.android.apogee-file_contexts"}, StubbedBuildDefinitions: []string{"com.android.apogee", "com.android.apogee.certificate", "com.android.apogee", "com.android.apogee-file_contexts"},
Blueprint: ` Blueprint: `
android_app_certificate { android_app_certificate {
name: "com.android.apogee.certificate", name: "com.android.apogee.certificate",
@@ -1417,7 +1410,6 @@ apex {
manifest: "apogee_manifest.json", manifest: "apogee_manifest.json",
file_contexts: ":com.android.apogee-file_contexts", file_contexts: ":com.android.apogee-file_contexts",
certificate: ":com.android.apogee.certificate", certificate: ":com.android.apogee.certificate",
bazel_module: { bp2build_available: false },
} }
override_apex { override_apex {

View File

@@ -1857,7 +1857,6 @@ func TestCcLibrary_SystemSharedLibsBionicEmpty(t *testing.T) {
Blueprint: soongCcLibraryPreamble + ` Blueprint: soongCcLibraryPreamble + `
cc_library { cc_library {
name: "libc_musl", name: "libc_musl",
bazel_module: { bp2build_available: false },
} }
cc_library { cc_library {
@@ -1912,10 +1911,10 @@ func TestCcLibrary_SystemSharedLibsLinuxMuslEmpty(t *testing.T) {
Description: "cc_library system_shared_lib empty for linux_musl variant", Description: "cc_library system_shared_lib empty for linux_musl variant",
ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory, ModuleTypeUnderTestFactory: cc.LibraryFactory,
StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryPreamble + ` Blueprint: soongCcLibraryPreamble + `
cc_library { cc_library {
name: "libc_musl", name: "libc_musl",
bazel_module: { bp2build_available: false },
} }
cc_library { cc_library {

View File

@@ -1595,6 +1595,7 @@ func TestCcLibrarySdkVariantUsesStubs(t *testing.T) {
Description: "cc_library_shared stubs", Description: "cc_library_shared stubs",
ModuleTypeUnderTest: "cc_library_shared", ModuleTypeUnderTest: "cc_library_shared",
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory, ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
StubbedBuildDefinitions: []string{"libNoStubs", "libHasApexStubs", "libHasApexAndNdkStubs"},
Blueprint: soongCcLibrarySharedPreamble + ` Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared { cc_library_shared {
name: "libUsesSdk", name: "libUsesSdk",
@@ -1607,22 +1608,21 @@ cc_library_shared {
} }
cc_library_shared { cc_library_shared {
name: "libNoStubs", name: "libNoStubs",
bazel_module: { bp2build_available: false },
} }
cc_library_shared { cc_library_shared {
name: "libHasApexStubs", name: "libHasApexStubs",
stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] }, stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
bazel_module: { bp2build_available: false },
apex_available: ["apex_a"], apex_available: ["apex_a"],
} }
cc_library_shared { cc_library_shared {
name: "libHasApexAndNdkStubs", name: "libHasApexAndNdkStubs",
stubs: { symbol_file: "b.map.txt", versions: ["28", "29", "current"] }, stubs: { symbol_file: "b.map.txt", versions: ["28", "29", "current"] },
bazel_module: { bp2build_available: false },
apex_available: ["apex_b"], apex_available: ["apex_b"],
} }
ndk_library { ndk_library {
name: "libHasApexAndNdkStubs", name: "libHasApexAndNdkStubs",
// TODO: b/301321658 - Stub this once existing-build-file handling can deal with
// modules that generate targets of a different name.
bazel_module: { bp2build_available: false }, bazel_module: { bp2build_available: false },
} }
`, `,

View File

@@ -1398,11 +1398,11 @@ cc_library_static {
func TestStaticLibrary_SystemSharedLibsMuslEmpty(t *testing.T) { func TestStaticLibrary_SystemSharedLibsMuslEmpty(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
Description: "cc_library_static system_shared_lib empty for musl variant", Description: "cc_library_static system_shared_lib empty for musl variant",
StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryStaticPreamble + ` Blueprint: soongCcLibraryStaticPreamble + `
cc_library { cc_library {
name: "libc_musl", name: "libc_musl",
bazel_module: { bp2build_available: false },
} }
cc_library_static { cc_library_static {
@@ -1425,11 +1425,11 @@ cc_library_static {
func TestStaticLibrary_SystemSharedLibsLinuxMuslEmpty(t *testing.T) { func TestStaticLibrary_SystemSharedLibsLinuxMuslEmpty(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
Description: "cc_library_static system_shared_lib empty for linux_musl variant", Description: "cc_library_static system_shared_lib empty for linux_musl variant",
StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryStaticPreamble + ` Blueprint: soongCcLibraryStaticPreamble + `
cc_library { cc_library {
name: "libc_musl", name: "libc_musl",
bazel_module: { bp2build_available: false },
} }
cc_library_static { cc_library_static {

View File

@@ -86,13 +86,11 @@ func TestJavaPluginNoSrcs(t *testing.T) {
java_library { java_library {
name: "java-lib-1", name: "java-lib-1",
srcs: ["b.java"], srcs: ["b.java"],
bazel_module: { bp2build_available: false },
} }
java_library { java_library {
name: "java-lib-2", name: "java-lib-2",
srcs: ["c.java"], srcs: ["c.java"],
bazel_module: { bp2build_available: false },
}`, }`,
ExpectedBazelTargets: []string{ ExpectedBazelTargets: []string{
MakeBazelTarget("java_plugin", "java-plug-1", AttrNameToString{ MakeBazelTarget("java_plugin", "java-plug-1", AttrNameToString{

View File

@@ -140,7 +140,8 @@ func TestJavaProtoDefault(t *testing.T) {
func TestJavaLibsAndOnlyProtoSrcs(t *testing.T) { func TestJavaLibsAndOnlyProtoSrcs(t *testing.T) {
runJavaProtoTestCase(t, Bp2buildTestCase{ runJavaProtoTestCase(t, Bp2buildTestCase{
Description: "java_library that has only proto srcs", Description: "java_library that has only proto srcs",
StubbedBuildDefinitions: []string{"java-lib"},
Blueprint: `java_library_static { Blueprint: `java_library_static {
name: "java-protos", name: "java-protos",
srcs: ["a.proto"], srcs: ["a.proto"],
@@ -151,7 +152,6 @@ func TestJavaLibsAndOnlyProtoSrcs(t *testing.T) {
java_library_static { java_library_static {
name: "java-lib", name: "java-lib",
bazel_module: { bp2build_available: false },
} }
`, `,
ExpectedBazelTargets: []string{ ExpectedBazelTargets: []string{

View File

@@ -32,8 +32,9 @@ func runJavaTestHostTestCase(t *testing.T, tc Bp2buildTestCase) {
func TestJavaTestHostGeneral(t *testing.T) { func TestJavaTestHostGeneral(t *testing.T) {
runJavaTestHostTestCase(t, Bp2buildTestCase{ runJavaTestHostTestCase(t, Bp2buildTestCase{
Description: "java_test_host general", Description: "java_test_host general",
Filesystem: map[string]string{}, Filesystem: map[string]string{},
StubbedBuildDefinitions: []string{"lib_a", "lib_b"},
Blueprint: ` Blueprint: `
java_test_host { java_test_host {
name: "java_test_host-1", name: "java_test_host-1",
@@ -47,12 +48,10 @@ java_test_host {
java_library { java_library {
name: "lib_a", name: "lib_a",
bazel_module: { bp2build_available: false },
} }
java_library { java_library {
name: "static_libs_a", name: "static_libs_a",
bazel_module: { bp2build_available: false },
} }
`, `,
ExpectedBazelTargets: []string{ ExpectedBazelTargets: []string{