Merge "Fix tests to use correct fixtures for configuring (Apex)BootJars." am: 721f42d12a
am: 9958b36643
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1787998 Change-Id: Id9248b6b54547e55c28bb386c867294ec20df873
This commit is contained in:
@@ -4513,6 +4513,7 @@ func TestPrebuiltApexNameWithPlatformBootclasspath(t *testing.T) {
|
||||
|
||||
prebuilt_bootclasspath_fragment {
|
||||
name: "art-bootclasspath-fragment",
|
||||
image_name: "art",
|
||||
contents: ["core-oj"],
|
||||
hidden_api: {
|
||||
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
|
||||
@@ -4721,7 +4722,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
||||
|
||||
func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
preparer := android.GroupFixturePreparers(
|
||||
java.FixtureConfigureBootJars("myapex:libfoo", "myapex:libbar"),
|
||||
java.FixtureConfigureApexBootJars("myapex:libfoo", "myapex:libbar"),
|
||||
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
|
||||
// is disabled.
|
||||
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
|
||||
@@ -4799,6 +4800,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
name: "libfoo",
|
||||
jars: ["libfoo.jar"],
|
||||
apex_available: ["myapex"],
|
||||
permitted_packages: ["foo"],
|
||||
}
|
||||
|
||||
java_sdk_library_import {
|
||||
@@ -4808,6 +4810,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
},
|
||||
apex_available: ["myapex"],
|
||||
shared_library: false,
|
||||
permitted_packages: ["bar"],
|
||||
}
|
||||
`
|
||||
|
||||
@@ -4848,6 +4851,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
name: "libfoo",
|
||||
jars: ["libfoo.jar"],
|
||||
apex_available: ["myapex"],
|
||||
permitted_packages: ["foo"],
|
||||
}
|
||||
|
||||
java_sdk_library_import {
|
||||
@@ -4857,6 +4861,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
},
|
||||
apex_available: ["myapex"],
|
||||
shared_library: false,
|
||||
permitted_packages: ["bar"],
|
||||
}
|
||||
`
|
||||
|
||||
@@ -4970,6 +4975,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
prefer: true,
|
||||
jars: ["libfoo.jar"],
|
||||
apex_available: ["myapex"],
|
||||
permitted_packages: ["foo"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
@@ -4986,6 +4992,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
},
|
||||
apex_available: ["myapex"],
|
||||
shared_library: false,
|
||||
permitted_packages: ["bar"],
|
||||
}
|
||||
|
||||
java_sdk_library {
|
||||
@@ -5059,6 +5066,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
name: "libfoo",
|
||||
srcs: ["foo/bar/MyClass.java"],
|
||||
apex_available: ["myapex"],
|
||||
permitted_packages: ["foo"],
|
||||
}
|
||||
|
||||
java_sdk_library_import {
|
||||
@@ -5075,6 +5083,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
srcs: ["foo/bar/MyClass.java"],
|
||||
unsafe_ignore_missing_latest_api: true,
|
||||
apex_available: ["myapex"],
|
||||
permitted_packages: ["bar"],
|
||||
}
|
||||
`
|
||||
|
||||
@@ -5136,6 +5145,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
prefer: true,
|
||||
jars: ["libfoo.jar"],
|
||||
apex_available: ["myapex"],
|
||||
permitted_packages: ["foo"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
@@ -5152,6 +5162,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
},
|
||||
apex_available: ["myapex"],
|
||||
shared_library: false,
|
||||
permitted_packages: ["bar"],
|
||||
}
|
||||
|
||||
java_sdk_library {
|
||||
@@ -6749,6 +6760,7 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer androi
|
||||
apex_available: [
|
||||
"some-updatable-apex",
|
||||
],
|
||||
permitted_packages: ["some.updatable.apex.lib"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
@@ -6758,6 +6770,7 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer androi
|
||||
"some-non-updatable-apex",
|
||||
],
|
||||
compile_dex: true,
|
||||
permitted_packages: ["some.non.updatable.apex.lib"],
|
||||
}
|
||||
|
||||
bootclasspath_fragment {
|
||||
@@ -6968,7 +6981,9 @@ func TestUpdatable_should_not_set_generate_classpaths_proto(t *testing.T) {
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
`)
|
||||
`,
|
||||
dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
|
||||
)
|
||||
}
|
||||
|
||||
func TestNoUpdatableJarsInBootImage(t *testing.T) {
|
||||
@@ -6998,18 +7013,30 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("updatable jar from ART apex in the ART boot image => ok", func(t *testing.T) {
|
||||
preparer := java.FixtureConfigureBootJars("com.android.art.debug:some-art-lib")
|
||||
fragment := java.ApexVariantReference{
|
||||
Apex: proptools.StringPtr("com.android.art.debug"),
|
||||
Module: proptools.StringPtr("art-bootclasspath-fragment"),
|
||||
preparer := android.GroupFixturePreparers(
|
||||
java.FixtureConfigureBootJars("com.android.art.debug:some-art-lib"),
|
||||
java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
|
||||
)
|
||||
fragments := []java.ApexVariantReference{
|
||||
{
|
||||
Apex: proptools.StringPtr("com.android.art.debug"),
|
||||
Module: proptools.StringPtr("art-bootclasspath-fragment"),
|
||||
},
|
||||
{
|
||||
Apex: proptools.StringPtr("some-non-updatable-apex"),
|
||||
Module: proptools.StringPtr("some-non-updatable-fragment"),
|
||||
},
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", preparer, fragment)
|
||||
testNoUpdatableJarsInBootImage(t, "", preparer, fragments...)
|
||||
})
|
||||
|
||||
t.Run("updatable jar from ART apex in the framework boot image => error", func(t *testing.T) {
|
||||
err := `module "some-art-lib" from updatable apexes \["com.android.art.debug"\] is not allowed in the framework boot image`
|
||||
// Update the dexpreopt BootJars directly.
|
||||
preparer := prepareSetBootJars("com.android.art.debug:some-art-lib")
|
||||
preparer := android.GroupFixturePreparers(
|
||||
prepareSetBootJars("com.android.art.debug:some-art-lib"),
|
||||
java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
|
||||
)
|
||||
testNoUpdatableJarsInBootImage(t, err, preparer)
|
||||
})
|
||||
|
||||
@@ -7029,12 +7056,15 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) {
|
||||
|
||||
t.Run("updatable jar from some other apex in the framework boot image => error", func(t *testing.T) {
|
||||
err := `module "some-updatable-apex-lib" from updatable apexes \["some-updatable-apex"\] is not allowed in the framework boot image`
|
||||
preparer := java.FixtureConfigureBootJars("some-updatable-apex:some-updatable-apex-lib")
|
||||
preparer := android.GroupFixturePreparers(
|
||||
java.FixtureConfigureBootJars("some-updatable-apex:some-updatable-apex-lib"),
|
||||
java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
|
||||
)
|
||||
testNoUpdatableJarsInBootImage(t, err, preparer)
|
||||
})
|
||||
|
||||
t.Run("non-updatable jar from some other apex in the framework boot image => ok", func(t *testing.T) {
|
||||
preparer := java.FixtureConfigureBootJars("some-non-updatable-apex:some-non-updatable-apex-lib")
|
||||
preparer := java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib")
|
||||
fragment := java.ApexVariantReference{
|
||||
Apex: proptools.StringPtr("some-non-updatable-apex"),
|
||||
Module: proptools.StringPtr("some-non-updatable-fragment"),
|
||||
@@ -7062,13 +7092,22 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("platform jar in the framework boot image => ok", func(t *testing.T) {
|
||||
preparer := java.FixtureConfigureBootJars("platform:some-platform-lib")
|
||||
testNoUpdatableJarsInBootImage(t, "", preparer)
|
||||
preparer := android.GroupFixturePreparers(
|
||||
java.FixtureConfigureBootJars("platform:some-platform-lib"),
|
||||
java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
|
||||
)
|
||||
fragments := []java.ApexVariantReference{
|
||||
{
|
||||
Apex: proptools.StringPtr("some-non-updatable-apex"),
|
||||
Module: proptools.StringPtr("some-non-updatable-fragment"),
|
||||
},
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", preparer, fragments...)
|
||||
})
|
||||
}
|
||||
|
||||
func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
|
||||
preparer := java.FixtureConfigureBootJars("myapex:libfoo")
|
||||
preparer := java.FixtureConfigureApexBootJars("myapex:libfoo")
|
||||
t.Run("prebuilt no source", func(t *testing.T) {
|
||||
fragment := java.ApexVariantReference{
|
||||
Apex: proptools.StringPtr("myapex"),
|
||||
@@ -7106,6 +7145,7 @@ func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
|
||||
name: "libfoo",
|
||||
jars: ["libfoo.jar"],
|
||||
apex_available: ["myapex"],
|
||||
permitted_packages: ["libfoo"],
|
||||
}
|
||||
`, "", preparer, fragment)
|
||||
})
|
||||
@@ -8018,6 +8058,8 @@ func TestApexJavaCoverage(t *testing.T) {
|
||||
java.PrepareForTestWithJavaDefaultModules,
|
||||
android.PrepareForTestWithAndroidBuildComponents,
|
||||
android.FixtureWithRootAndroidBp(bp),
|
||||
dexpreopt.FixtureSetApexBootJars("myapex:mybootclasspathlib"),
|
||||
dexpreopt.FixtureSetApexSystemServerJars("myapex:mysystemserverclasspathlib"),
|
||||
android.FixtureMergeEnv(map[string]string{
|
||||
"EMMA_INSTRUMENT": "true",
|
||||
}),
|
||||
|
Reference in New Issue
Block a user