Merge "Revert^4 "Implement detecting container violations."" into main am: 7344482ff3 am: 9e40f8f9b4

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3248019

Change-Id: I77818bede2be74dc6755a55c5a8e69a1c6a7f64c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jihoon Kang
2024-08-30 20:31:34 +00:00
committed by Automerger Merge Worker
17 changed files with 225 additions and 19 deletions

View File

@@ -74,6 +74,8 @@ func TestValidationAcrossContainersExportedPass(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "none",
system_modules: "none",
}`,
},
{
@@ -122,6 +124,8 @@ func TestValidationAcrossContainersExportedPass(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "none",
system_modules: "none",
}`,
},
{
@@ -345,6 +349,8 @@ func TestValidationAcrossContainersNotExportedFail(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "none",
system_modules: "none",
}`,
expectedError: `.*my_java_library_foo/myapex depends on my_java_aconfig_library_foo/otherapex/production across containers`,
},
@@ -392,6 +398,8 @@ func TestValidationAcrossContainersNotExportedFail(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "none",
system_modules: "none",
}`,
expectedError: `.*my_android_app_foo/myapex depends on my_java_aconfig_library_foo/otherapex/production across containers`,
},
@@ -693,6 +701,8 @@ func TestValidationAcrossContainersNotExportedFail(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "none",
system_modules: "none",
}`,
expectedError: `.*my_android_app_foo/myapex depends on my_java_aconfig_library_foo/otherapex/production across containers`,
},
@@ -769,6 +779,8 @@ func TestValidationNotPropagateAcrossShared(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "none",
system_modules: "none",
}`,
},
}

View File

@@ -4929,6 +4929,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
java_import {
name: "libfoo",
jars: ["libfoo.jar"],
sdk_version: "core_current",
}
java_sdk_library_import {
@@ -4969,6 +4970,22 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
t.Run("prebuilt with source preferred", func(t *testing.T) {
bp := `
apex {
name: "myapex",
key: "myapex.key",
updatable: false,
java_libs: [
"libfoo",
"libbar",
],
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
prebuilt_apex {
name: "myapex",
arch: {
@@ -4985,10 +5002,21 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
java_import {
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: [
"myapex",
],
compile_dex: true,
sdk_version: "core_current",
}
java_library {
name: "libfoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: [
"myapex",
],
compile_dex: true,
sdk_version: "core_current",
}
java_sdk_library_import {
@@ -4996,12 +5024,21 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
public: {
jars: ["libbar.jar"],
},
apex_available: [
"myapex",
],
compile_dex: true,
}
java_sdk_library {
name: "libbar",
srcs: ["foo/bar/MyClass.java"],
unsafe_ignore_missing_latest_api: true,
apex_available: [
"myapex",
],
compile_dex: true,
sdk_version: "core_current",
}
`
@@ -5010,11 +5047,9 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
checkDexJarInstallPath(t, ctx, "prebuilt_libfoo")
ensureNoSourceVariant(t, ctx, "libfoo")
checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
checkDexJarInstallPath(t, ctx, "prebuilt_libbar")
ensureNoSourceVariant(t, ctx, "libbar")
})
t.Run("prebuilt preferred with source", func(t *testing.T) {
@@ -5040,6 +5075,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
java_library {
name: "libfoo",
sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5166,6 +5202,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
jars: ["libfoo.jar"],
apex_available: ["myapex"],
permitted_packages: ["foo"],
sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5320,12 +5357,14 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: ["myapex"],
sdk_version: "core_current",
}
java_library {
name: "libfoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5417,6 +5456,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
jars: ["libfoo.jar"],
apex_available: ["myapex"],
permitted_packages: ["foo"],
sdk_version: "core_current",
}
java_library {
@@ -5424,6 +5464,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
installable: true,
sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5514,6 +5555,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: ["myapex"],
sdk_version: "core_current",
}
java_library {
@@ -5522,6 +5564,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
apex_available: ["myapex"],
permitted_packages: ["foo"],
installable: true,
sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5540,6 +5583,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
apex_available: ["myapex"],
permitted_packages: ["bar"],
compile_dex: true,
sdk_version: "core_current",
}
`
@@ -6134,6 +6178,7 @@ func TestApexWithTestHelperApp(t *testing.T) {
name: "TesterHelpAppFoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: [ "myapex" ],
sdk_version: "test_current",
}
`)
@@ -7735,7 +7780,7 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
sdk_version: "none",
system_modules: "none",
libs: ["myotherjar"],
static_libs: ["myotherjar"],
apex_available: [
"myapex",
"myapex.updatable",
@@ -8396,6 +8441,7 @@ func TestUpdatable_should_not_set_generate_classpaths_proto(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "current",
}
systemserverclasspath_fragment {
@@ -9438,6 +9484,7 @@ func TestApexJavaCoverage(t *testing.T) {
srcs: ["mybootclasspathlib.java"],
apex_available: ["myapex"],
compile_dex: true,
sdk_version: "current",
}
systemserverclasspath_fragment {
@@ -9753,6 +9800,7 @@ func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
unsafe_ignore_missing_latest_api: true,
min_sdk_version: "31",
static_libs: ["util"],
sdk_version: "core_current",
}
java_library {
@@ -9761,6 +9809,7 @@ func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
apex_available: ["myapex"],
min_sdk_version: "31",
static_libs: ["another_util"],
sdk_version: "core_current",
}
java_library {
@@ -9768,6 +9817,7 @@ func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
srcs: ["a.java"],
min_sdk_version: "31",
apex_available: ["myapex"],
sdk_version: "core_current",
}
`)
})
@@ -9823,7 +9873,7 @@ func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
})
t.Run("bootclasspath_fragment jar must set min_sdk_version", func(t *testing.T) {
preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "mybootclasspathlib".*must set min_sdk_version`)).
preparer.
RunTestWithBp(t, `
apex {
name: "myapex",
@@ -9854,6 +9904,8 @@ func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
apex_available: ["myapex"],
compile_dex: true,
unsafe_ignore_missing_latest_api: true,
sdk_version: "current",
min_sdk_version: "30",
}
`)
})
@@ -10106,6 +10158,9 @@ func TestApexLintBcpFragmentSdkLibDeps(t *testing.T) {
key: "myapex.key",
bootclasspath_fragments: ["mybootclasspathfragment"],
min_sdk_version: "29",
java_libs: [
"jacocoagent",
],
}
apex_key {
name: "myapex.key",

View File

@@ -104,6 +104,7 @@ func TestBootclasspathFragments_FragmentDependency(t *testing.T) {
test: {
enabled: true,
},
sdk_version: "core_current",
}
java_library {
@@ -749,6 +750,7 @@ func TestBootclasspathFragment_HiddenAPIList(t *testing.T) {
],
srcs: ["b.java"],
compile_dex: true,
sdk_version: "core_current",
}
java_sdk_library {
@@ -922,6 +924,7 @@ func TestBootclasspathFragment_AndroidNonUpdatable_FromSource(t *testing.T) {
],
srcs: ["b.java"],
compile_dex: true,
sdk_version: "core_current",
}
java_library {
@@ -1093,6 +1096,7 @@ func TestBootclasspathFragment_AndroidNonUpdatable_FromText(t *testing.T) {
],
srcs: ["b.java"],
compile_dex: true,
sdk_version: "core_current",
}
java_library {
@@ -1245,6 +1249,7 @@ func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *test
],
srcs: ["b.java"],
compile_dex: true,
sdk_version: "core_current",
}
java_library {

View File

@@ -92,6 +92,7 @@ func TestCreateClasspathElements(t *testing.T) {
],
srcs: ["b.java"],
installable: true,
sdk_version: "core_current",
}
java_library {

View File

@@ -30,7 +30,7 @@ func TestApexDepsContainers(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForApexTest,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("mybootclasspathlib"),
java.FixtureWithLastReleaseApis("mybootclasspathlib", "bar"),
).RunTestWithBp(t, `
apex {
name: "myapex",
@@ -68,16 +68,17 @@ func TestApexDepsContainers(t *testing.T) {
],
compile_dex: true,
static_libs: [
"foo",
"food",
"baz",
],
libs: [
"bar",
"bar.stubs",
],
min_sdk_version: "30",
sdk_version: "current",
}
java_library {
name: "foo",
name: "food",
srcs:[
"A.java",
],
@@ -85,13 +86,15 @@ func TestApexDepsContainers(t *testing.T) {
"myapex",
],
min_sdk_version: "30",
sdk_version: "core_current",
}
java_library {
java_sdk_library {
name: "bar",
srcs:[
"A.java",
],
min_sdk_version: "30",
sdk_version: "core_current",
}
java_library {
name: "baz",
@@ -103,6 +106,7 @@ func TestApexDepsContainers(t *testing.T) {
"myapex",
],
min_sdk_version: "30",
sdk_version: "core_current",
}
`)
testcases := []struct {
@@ -130,7 +134,7 @@ func TestApexDepsContainers(t *testing.T) {
isApexContainer: false,
},
{
moduleName: "foo",
moduleName: "food",
variant: "android_common_apex30",
isSystemContainer: true,
isApexContainer: true,
@@ -162,7 +166,7 @@ func TestNonUpdatableApexDepsContainers(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForApexTest,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("mybootclasspathlib"),
java.FixtureWithLastReleaseApis("mybootclasspathlib", "bar"),
).RunTestWithBp(t, `
apex {
name: "myapex",
@@ -199,26 +203,30 @@ func TestNonUpdatableApexDepsContainers(t *testing.T) {
],
compile_dex: true,
static_libs: [
"foo",
"food",
],
libs: [
"bar",
"bar.stubs",
],
sdk_version: "current",
}
java_library {
name: "foo",
name: "food",
srcs:[
"A.java",
],
apex_available: [
"myapex",
],
sdk_version: "core_current",
}
java_library {
java_sdk_library {
name: "bar",
srcs:[
"A.java",
],
sdk_version: "none",
system_modules: "none",
}
`)
testcases := []struct {
@@ -246,7 +254,7 @@ func TestNonUpdatableApexDepsContainers(t *testing.T) {
isApexContainer: false,
},
{
moduleName: "foo",
moduleName: "food",
variant: "android_common_apex10000",
isSystemContainer: true,
isApexContainer: true,

View File

@@ -293,6 +293,7 @@ func TestPlatformBootclasspathDependencies(t *testing.T) {
],
srcs: ["b.java"],
installable: true,
sdk_version: "core_current",
}
// Add a java_import that is not preferred and so won't have an appropriate apex variant created

View File

@@ -80,6 +80,7 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "core_current",
}
systemserverclasspath_fragment {
@@ -350,6 +351,7 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) {
apex_available: [
"myapex",
],
sdk_version: "core_current",
}
systemserverclasspath_fragment {