Fix some tests for dexpreopt and remove unnecessary tests.

This CL is to prepare for the changes in http://r.android.com/2652081.
See the description of that CL for the reasons.

Some tests were set up in a fragile way and were easy to be broken when
the implementation changes. This CL is a pure test change that fixes
them.

This CL also removes TestNoUpdatableJarsInBootImage. That test checks
what should go to the ART boot image and what should go to the
platform one, which does not apply today because boot images are not
associated with mainline modules anymore: a boot image may take jars
from multiple mainline modules and the platform, and a mainline module
can contribute to multiple boot images. In practice, we have ART jars in
the platform boot image, and we are going to add core-icu4j and
consrypt to the ART boot image, which is now for testing only.

Bug: 290583827
Test: m nothing
Change-Id: I22c45cbf6f853b030b68edb51197854e9c53a02e
This commit is contained in:
Jiakai Zhang 2023-07-11 14:31:22 +01:00
parent bc332f6cd8
commit b69e89559f
6 changed files with 186 additions and 335 deletions

View file

@ -5587,6 +5587,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
`)
})
@ -5664,6 +5665,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
`)
myApex := ctx.ModuleForTests("myapex", "android_common_myapex").Module()
@ -5758,6 +5760,28 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
t.Run("prebuilt library preferred with source", func(t *testing.T) {
bp := `
apex {
name: "myapex",
key: "myapex.key",
updatable: false,
bootclasspath_fragments: ["my-bootclasspath-fragment"],
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
bootclasspath_fragment {
name: "my-bootclasspath-fragment",
contents: ["libfoo", "libbar"],
apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
}
prebuilt_apex {
name: "myapex",
arch: {
@ -5773,6 +5797,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
prebuilt_bootclasspath_fragment {
name: "my-bootclasspath-fragment",
prefer: true,
contents: ["libfoo", "libbar"],
apex_available: ["myapex"],
hidden_api: {
@ -5797,6 +5822,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
name: "libfoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
installable: true,
}
java_sdk_library_import {
@ -5815,6 +5841,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
unsafe_ignore_missing_latest_api: true,
apex_available: ["myapex"],
compile_dex: true,
}
`
@ -5827,6 +5854,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
`)
})
@ -5835,8 +5863,8 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
apex {
name: "myapex",
key: "myapex.key",
java_libs: ["libfoo", "libbar"],
updatable: false,
bootclasspath_fragments: ["my-bootclasspath-fragment"],
}
apex_key {
@ -5845,6 +5873,15 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
private_key: "testkey.pem",
}
bootclasspath_fragment {
name: "my-bootclasspath-fragment",
contents: ["libfoo", "libbar"],
apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
}
prebuilt_apex {
name: "myapex",
arch: {
@ -5883,6 +5920,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
permitted_packages: ["foo"],
installable: true,
}
java_sdk_library_import {
@ -5900,6 +5938,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
unsafe_ignore_missing_latest_api: true,
apex_available: ["myapex"],
permitted_packages: ["bar"],
compile_dex: true,
}
`
@ -5910,8 +5949,9 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
// Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, ``)
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/modular-hiddenapi/index.csv
out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
`)
})
@ -5921,7 +5961,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
name: "myapex",
enabled: false,
key: "myapex.key",
java_libs: ["libfoo", "libbar"],
bootclasspath_fragments: ["my-bootclasspath-fragment"],
}
apex_key {
@ -5930,6 +5970,16 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
private_key: "testkey.pem",
}
bootclasspath_fragment {
name: "my-bootclasspath-fragment",
enabled: false,
contents: ["libfoo", "libbar"],
apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
}
prebuilt_apex {
name: "myapex",
arch: {
@ -5959,7 +6009,6 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
java_import {
name: "libfoo",
prefer: true,
jars: ["libfoo.jar"],
apex_available: ["myapex"],
permitted_packages: ["foo"],
@ -5967,13 +6016,14 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
java_library {
name: "libfoo",
enabled: false,
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
installable: true,
}
java_sdk_library_import {
name: "libbar",
prefer: true,
public: {
jars: ["libbar.jar"],
},
@ -5984,9 +6034,11 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
java_sdk_library {
name: "libbar",
enabled: false,
srcs: ["foo/bar/MyClass.java"],
unsafe_ignore_missing_latest_api: true,
apex_available: ["myapex"],
compile_dex: true,
}
`
@ -5999,6 +6051,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
`)
})
}
@ -8163,126 +8216,6 @@ func TestApexSetApksModuleAssignment(t *testing.T) {
android.AssertArrayString(t, "extractor input", []string{"myapex.apks"}, extractedApex.Inputs.Strings())
}
func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer android.FixturePreparer, fragments ...java.ApexVariantReference) {
t.Helper()
bp := `
java_library {
name: "some-updatable-apex-lib",
srcs: ["a.java"],
sdk_version: "current",
apex_available: [
"some-updatable-apex",
],
permitted_packages: ["some.updatable.apex.lib"],
min_sdk_version: "33",
}
java_library {
name: "some-non-updatable-apex-lib",
srcs: ["a.java"],
apex_available: [
"some-non-updatable-apex",
],
compile_dex: true,
permitted_packages: ["some.non.updatable.apex.lib"],
}
bootclasspath_fragment {
name: "some-non-updatable-fragment",
contents: ["some-non-updatable-apex-lib"],
apex_available: [
"some-non-updatable-apex",
],
hidden_api: {
split_packages: ["*"],
},
}
java_library {
name: "some-platform-lib",
srcs: ["a.java"],
sdk_version: "current",
installable: true,
}
java_library {
name: "some-art-lib",
srcs: ["a.java"],
sdk_version: "current",
apex_available: [
"com.android.art.debug",
],
hostdex: true,
compile_dex: true,
min_sdk_version: "33",
}
apex {
name: "some-updatable-apex",
key: "some-updatable-apex.key",
java_libs: ["some-updatable-apex-lib"],
updatable: true,
min_sdk_version: "33",
}
apex {
name: "some-non-updatable-apex",
key: "some-non-updatable-apex.key",
bootclasspath_fragments: ["some-non-updatable-fragment"],
updatable: false,
}
apex_key {
name: "some-updatable-apex.key",
}
apex_key {
name: "some-non-updatable-apex.key",
}
apex {
name: "com.android.art.debug",
key: "com.android.art.debug.key",
bootclasspath_fragments: ["art-bootclasspath-fragment"],
updatable: true,
min_sdk_version: "33",
}
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
contents: ["some-art-lib"],
apex_available: [
"com.android.art.debug",
],
hidden_api: {
split_packages: ["*"],
},
}
apex_key {
name: "com.android.art.debug.key",
}
filegroup {
name: "some-updatable-apex-file_contexts",
srcs: [
"system/sepolicy/apex/some-updatable-apex-file_contexts",
],
}
filegroup {
name: "some-non-updatable-apex-file_contexts",
srcs: [
"system/sepolicy/apex/some-non-updatable-apex-file_contexts",
],
}
`
testDexpreoptWithApexes(t, bp, errmsg, preparer, fragments...)
}
func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, preparer android.FixturePreparer, fragments ...java.ApexVariantReference) *android.TestContext {
t.Helper()
@ -8306,7 +8239,7 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, preparer android.F
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
java.PrepareForTestWithHiddenApiBuildComponents,
java.PrepareForTestWithJavaDefaultModules,
java.PrepareForTestWithDexpreopt,
java.PrepareForTestWithJavaSdkLibraryFiles,
PrepareForTestWithApexBuildComponents,
preparer,
@ -8321,12 +8254,16 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, preparer android.F
platform_bootclasspath {
name: "platform-bootclasspath",
fragments: [
{apex: "com.android.art", module: "art-bootclasspath-fragment"},
%s
],
}
`, insert))
}
}),
// Dexpreopt for boot jars requires the ART boot image profile.
java.PrepareApexBootJarModule("com.android.art", "core-oj"),
dexpreopt.FixtureSetArtBootJars("com.android.art:core-oj"),
dexpreopt.FixtureSetBootImageProfiles("art/build/boot/boot-image-profile.txt"),
).
ExtendWithErrorHandler(errorHandler).
@ -8633,126 +8570,6 @@ func TestUpdatable_should_not_set_generate_classpaths_proto(t *testing.T) {
)
}
func TestNoUpdatableJarsInBootImage(t *testing.T) {
// Set the BootJars in dexpreopt.GlobalConfig and productVariables to the same value. This can
// result in an invalid configuration as it does not set the ArtApexJars and allows art apex
// modules to be included in the BootJars.
prepareSetBootJars := func(bootJars ...string) android.FixturePreparer {
return android.GroupFixturePreparers(
dexpreopt.FixtureSetBootJars(bootJars...),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BootJars = android.CreateTestConfiguredJarList(bootJars)
}),
)
}
// Set the ArtApexJars and BootJars in dexpreopt.GlobalConfig and productVariables all to the
// same value. This can result in an invalid configuration as it allows non art apex jars to be
// specified in the ArtApexJars configuration.
prepareSetArtJars := func(bootJars ...string) android.FixturePreparer {
return android.GroupFixturePreparers(
dexpreopt.FixtureSetArtBootJars(bootJars...),
dexpreopt.FixtureSetBootJars(bootJars...),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BootJars = android.CreateTestConfiguredJarList(bootJars)
}),
)
}
t.Run("updatable jar from ART apex in the ART boot image => ok", func(t *testing.T) {
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, fragments...)
})
t.Run("updatable jar from ART apex in the platform bootclasspath => error", func(t *testing.T) {
err := `module "some-art-lib" from updatable apexes \["com.android.art.debug"\] is not allowed in the platform bootclasspath`
// Update the dexpreopt BootJars directly.
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)
})
t.Run("updatable jar from some other apex in the ART boot image => error", func(t *testing.T) {
err := `ArtApexJars expects this to be in apex "some-updatable-apex" but this is only in apexes.*"com.android.art.debug"`
// Update the dexpreopt ArtApexJars directly.
preparer := prepareSetArtJars("some-updatable-apex:some-updatable-apex-lib")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("non-updatable jar from some other apex in the ART boot image => error", func(t *testing.T) {
err := `ArtApexJars expects this to be in apex "some-non-updatable-apex" but this is only in apexes.*"com.android.art.debug"`
// Update the dexpreopt ArtApexJars directly.
preparer := prepareSetArtJars("some-non-updatable-apex:some-non-updatable-apex-lib")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("updatable jar from some other apex in the platform bootclasspath => error", func(t *testing.T) {
err := `module "some-updatable-apex-lib" from updatable apexes \["some-updatable-apex"\] is not allowed in the platform bootclasspath`
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 platform bootclasspath => ok", func(t *testing.T) {
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"),
}
testNoUpdatableJarsInBootImage(t, "", preparer, fragment)
})
t.Run("nonexistent jar in the ART boot image => error", func(t *testing.T) {
err := `"platform-bootclasspath" depends on undefined module "nonexistent"`
preparer := java.FixtureConfigureBootJars("platform:nonexistent")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("nonexistent jar in the platform bootclasspath => error", func(t *testing.T) {
err := `"platform-bootclasspath" depends on undefined module "nonexistent"`
preparer := java.FixtureConfigureBootJars("platform:nonexistent")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("platform jar in the ART boot image => error", func(t *testing.T) {
err := `ArtApexJars is invalid as it requests a platform variant of "some-platform-lib"`
// Update the dexpreopt ArtApexJars directly.
preparer := prepareSetArtJars("platform:some-platform-lib")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("platform jar in the platform bootclasspath => ok", func(t *testing.T) {
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.FixtureConfigureApexBootJars("myapex:libfoo")
t.Run("prebuilt no source", func(t *testing.T) {

View file

@ -268,10 +268,10 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: [
"mybootclasspathfragment",
"art-bootclasspath-fragment",
],
// bar (like foo) should be transitively included in this apex because it is part of the
// mybootclasspathfragment bootclasspath_fragment.
// art-bootclasspath-fragment bootclasspath_fragment.
updatable: false,
}
@ -280,42 +280,6 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_library {
name: "foo",
srcs: ["b.java"],
installable: true,
apex_available: [
"com.android.art",
],
}
java_library {
name: "bar",
srcs: ["b.java"],
installable: true,
apex_available: [
"com.android.art",
],
}
java_import {
name: "foo",
jars: ["foo.jar"],
apex_available: [
"com.android.art",
],
compile_dex: true,
}
java_import {
name: "bar",
jars: ["bar.jar"],
apex_available: [
"com.android.art",
],
compile_dex: true,
}
`),
)
@ -330,7 +294,7 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
addSource := func(contents ...string) android.FixturePreparer {
text := fmt.Sprintf(`
bootclasspath_fragment {
name: "mybootclasspathfragment",
name: "art-bootclasspath-fragment",
image_name: "art",
%s
apex_available: [
@ -342,6 +306,19 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
}
`, contentsInsert(contents))
for _, content := range contents {
text += fmt.Sprintf(`
java_library {
name: "%[1]s",
srcs: ["%[1]s.java"],
installable: true,
apex_available: [
"com.android.art",
],
}
`, content)
}
return android.FixtureAddTextFile("art/build/boot/Android.bp", text)
}
@ -357,11 +334,11 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
src: "com.android.art-arm.apex",
},
},
exported_bootclasspath_fragments: ["mybootclasspathfragment"],
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
name: "art-bootclasspath-fragment",
image_name: "art",
%s
prefer: %t,
@ -369,14 +346,29 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
"com.android.art",
],
hidden_api: {
annotation_flags: "mybootclasspathfragment/annotation-flags.csv",
metadata: "mybootclasspathfragment/metadata.csv",
index: "mybootclasspathfragment/index.csv",
stub_flags: "mybootclasspathfragment/stub-flags.csv",
all_flags: "mybootclasspathfragment/all-flags.csv",
annotation_flags: "hiddenapi/annotation-flags.csv",
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
stub_flags: "hiddenapi/stub-flags.csv",
all_flags: "hiddenapi/all-flags.csv",
},
}
`, contentsInsert(contents), prefer)
for _, content := range contents {
text += fmt.Sprintf(`
java_import {
name: "%[1]s",
prefer: %[2]t,
jars: ["%[1]s.jar"],
apex_available: [
"com.android.art",
],
compile_dex: true,
}
`, content, prefer)
}
return android.FixtureAddTextFile("prebuilts/module_sdk/art/Android.bp", text)
}
@ -399,13 +391,13 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
})
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
`art-bootclasspath-fragment`,
`com.android.art.key`,
`mybootclasspathfragment`,
})
// Make sure that the source bootclasspath_fragment copies its dex files to the predefined
// locations for the art image.
module := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
module := result.ModuleForTests("art-bootclasspath-fragment", "android_common_apex10000")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
@ -469,14 +461,14 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
})
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
`art-bootclasspath-fragment`,
`com.android.art.key`,
`mybootclasspathfragment`,
`prebuilt_com.android.art`,
})
// Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined
// locations for the art image.
module := result.ModuleForTests("prebuilt_mybootclasspathfragment", "android_common_com.android.art")
module := result.ModuleForTests("prebuilt_art-bootclasspath-fragment", "android_common_com.android.art")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
@ -566,7 +558,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
src: "com.android.art-arm.apex",
},
},
exported_bootclasspath_fragments: ["mybootclasspathfragment"],
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
java_import {
@ -586,7 +578,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
}
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
name: "art-bootclasspath-fragment",
image_name: "art",
// Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above.
contents: ["foo", "bar"],
@ -594,11 +586,11 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
"com.android.art",
],
hidden_api: {
annotation_flags: "mybootclasspathfragment/annotation-flags.csv",
metadata: "mybootclasspathfragment/metadata.csv",
index: "mybootclasspathfragment/index.csv",
stub_flags: "mybootclasspathfragment/stub-flags.csv",
all_flags: "mybootclasspathfragment/all-flags.csv",
annotation_flags: "hiddenapi/annotation-flags.csv",
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
stub_flags: "hiddenapi/stub-flags.csv",
all_flags: "hiddenapi/all-flags.csv",
},
}
@ -608,7 +600,7 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
apex_name: "com.android.art",
%s
src: "com.mycompany.android.art.apex",
exported_bootclasspath_fragments: ["mybootclasspathfragment"],
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
`
@ -617,17 +609,17 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
`com.android.art.apex.selector`,
`prebuilt_mybootclasspathfragment`,
`prebuilt_art-bootclasspath-fragment`,
})
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_com.android.art", []string{
java.CheckModuleDependencies(t, result.TestContext, "art-bootclasspath-fragment", "android_common_com.android.art", []string{
`com.android.art.deapexer`,
`dex2oatd`,
`prebuilt_bar`,
`prebuilt_foo`,
})
module := result.ModuleForTests("mybootclasspathfragment", "android_common_com.android.art")
module := result.ModuleForTests("art-bootclasspath-fragment", "android_common_com.android.art")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})

View file

@ -155,7 +155,7 @@ func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOu
}
func TestDexpreoptBootJarsWithSourceArtApex(t *testing.T) {
ruleFile := "boot.art"
ruleFile := "out/soong/dexpreopt_arm64/dex_bootjars/android/system/framework/arm64/boot.art"
expectedInputs := []string{
"out/soong/dexpreopt_arm64/dex_bootjars_input/core-oj.jar",
@ -192,7 +192,7 @@ func TestDexpreoptBootJarsWithSourceArtApex(t *testing.T) {
// The only difference is that the ART profile should be deapexed from the prebuilt APEX. Other
// inputs and outputs should be the same as above.
func TestDexpreoptBootJarsWithPrebuiltArtApex(t *testing.T) {
ruleFile := "boot.art"
ruleFile := "out/soong/dexpreopt_arm64/dex_bootjars/android/system/framework/arm64/boot.art"
expectedInputs := []string{
"out/soong/dexpreopt_arm64/dex_bootjars_input/core-oj.jar",

View file

@ -40,6 +40,12 @@ func TestBootclasspathFragment_UnknownImageName(t *testing.T) {
image_name: "unknown",
contents: ["foo"],
}
java_library {
name: "foo",
srcs: ["foo.java"],
installable: true,
}
`)
}
@ -53,6 +59,11 @@ func TestPrebuiltBootclasspathFragment_UnknownImageName(t *testing.T) {
image_name: "unknown",
contents: ["foo"],
}
java_import {
name: "foo",
jars: ["foo.jar"],
}
`)
}
@ -72,6 +83,18 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_Platform(t *testing.T
"apex",
],
}
java_library {
name: "foo",
srcs: ["foo.java"],
installable: true,
}
java_library {
name: "bar",
srcs: ["bar.java"],
installable: true,
}
`)
}
@ -92,6 +115,18 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testin
"apex2",
],
}
java_library {
name: "foo",
srcs: ["foo.java"],
installable: true,
}
java_library {
name: "bar",
srcs: ["bar.java"],
installable: true,
}
`)
}

View file

@ -44,18 +44,18 @@ var PrepareApexBootJarConfigs = FixtureConfigureApexBootJars(
var PrepareApexBootJarConfigsAndModules = android.GroupFixturePreparers(
PrepareApexBootJarConfigs,
prepareApexBootJarModule("com.android.foo", "framework-foo"),
prepareApexBootJarModule("com.android.bar", "framework-bar"),
PrepareApexBootJarModule("com.android.foo", "framework-foo"),
PrepareApexBootJarModule("com.android.bar", "framework-bar"),
)
var ApexBootJarFragmentsForPlatformBootclasspath = fmt.Sprintf(`
{
apex: "%[1]s",
module: "%[1]s-bootclasspathfragment",
module: "%[1]s-bootclasspath-fragment",
},
{
apex: "%[2]s",
module: "%[2]s-bootclasspathfragment",
module: "%[2]s-bootclasspath-fragment",
},
`, "com.android.foo", "com.android.bar")
@ -64,15 +64,22 @@ var ApexBootJarDexJarPaths = []string{
"out/soong/.intermediates/packages/modules/com.android.foo/framework-foo/android_common_apex10000/aligned/framework-foo.jar",
}
func prepareApexBootJarModule(apexName string, moduleName string) android.FixturePreparer {
func PrepareApexBootJarModule(apexName string, moduleName string) android.FixturePreparer {
moduleSourceDir := fmt.Sprintf("packages/modules/%s", apexName)
fragmentName := apexName+"-bootclasspath-fragment"
imageNameProp := ""
if apexName == "com.android.art" {
fragmentName = "art-bootclasspath-fragment"
imageNameProp = `image_name: "art",`
}
return android.GroupFixturePreparers(
android.FixtureAddTextFile(moduleSourceDir+"/Android.bp", fmt.Sprintf(`
apex {
name: "%[1]s",
key: "%[1]s.key",
bootclasspath_fragments: [
"%[1]s-bootclasspathfragment",
"%[3]s",
],
updatable: false,
}
@ -84,7 +91,8 @@ func prepareApexBootJarModule(apexName string, moduleName string) android.Fixtur
}
bootclasspath_fragment {
name: "%[1]s-bootclasspathfragment",
name: "%[3]s",
%[4]s
contents: ["%[2]s"],
apex_available: ["%[1]s"],
hidden_api: {
@ -100,7 +108,7 @@ func prepareApexBootJarModule(apexName string, moduleName string) android.Fixtur
compile_dex: true,
apex_available: ["%[1]s"],
}
`, apexName, moduleName)),
`, apexName, moduleName, fragmentName, imageNameProp)),
android.FixtureMergeMockFs(android.MockFS{
fmt.Sprintf("%s/apex_manifest.json", moduleSourceDir): nil,
fmt.Sprintf("%s/%s.avbpubkey", moduleSourceDir, apexName): nil,
@ -192,7 +200,7 @@ func CheckArtBootImageConfig(t *testing.T, result *android.TestResult) {
// getArtImageConfig gets the ART bootImageConfig that was created during the test.
func getArtImageConfig(result *android.TestResult) *bootImageConfig {
pathCtx := &android.TestPathContext{TestResult: result}
imageConfig := artBootImageConfig(pathCtx)
imageConfig := genBootImageConfigs(pathCtx)["art"]
return imageConfig
}
@ -1136,7 +1144,6 @@ func nestedCheckBootImageConfig(t *testing.T, imageConfig *bootImageConfig, expe
android.AssertPathRelativeToTopEquals(t, "dir", expected.dir, imageConfig.dir)
android.AssertPathRelativeToTopEquals(t, "symbolsDir", expected.symbolsDir, imageConfig.symbolsDir)
android.AssertStringEquals(t, "installDir", expected.installDir, imageConfig.installDir)
android.AssertStringEquals(t, "profileInstallPathInApex", expected.profileInstallPathInApex, imageConfig.profileInstallPathInApex)
android.AssertDeepEquals(t, "modules", expected.modules, imageConfig.modules)
android.AssertPathsRelativeToTopEquals(t, "dexPaths", expected.dexPaths, imageConfig.dexPaths.Paths())
android.AssertPathsRelativeToTopEquals(t, "dexPathsDeps", expected.dexPathsDeps, imageConfig.dexPathsDeps.Paths())

View file

@ -86,27 +86,27 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragmentWithExtra(
"com.android.art", "mybootclasspathfragment", java.ApexBootJarFragmentsForPlatformBootclasspath),
"com.android.art", "art-bootclasspath-fragment", java.ApexBootJarFragmentsForPlatformBootclasspath),
java.PrepareForBootImageConfigTest,
java.PrepareApexBootJarConfigsAndModules,
android.FixtureWithRootAndroidBp(`
sdk {
name: "mysdk",
bootclasspath_fragments: ["mybootclasspathfragment"],
bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: [
"mybootclasspathfragment",
"art-bootclasspath-fragment",
],
updatable: false,
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
name: "art-bootclasspath-fragment",
image_name: "art",
contents: ["core1", "core2"],
apex_available: ["com.android.art"],
@ -142,10 +142,10 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
).RunTest(t)
// A preparer to update the test fixture used when processing an unpackage snapshot.
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment")
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "art-bootclasspath-fragment")
// Check that source on its own configures the bootImageConfig correctly.
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/art-bootclasspath-fragment/android_common_apex10000/meta_lic")
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
CheckSnapshot(t, result, "mysdk", "",
@ -153,7 +153,7 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
name: "art-bootclasspath-fragment",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["com.android.art"],
@ -189,12 +189,12 @@ java_import {
}
`),
checkAllCopyRules(`
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar
`),
@ -213,7 +213,7 @@ java_import {
java.ApexBootJarDexJarPaths...,
)...,
)
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/mybootclasspathfragment/android_common_com.android.art/meta_lic")
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/art-bootclasspath-fragment/android_common_com.android.art/meta_lic")
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
}),
@ -221,7 +221,7 @@ java_import {
// Check the behavior of the snapshot when the source is preferred.
snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) {
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/art-bootclasspath-fragment/android_common_apex10000/meta_lic")
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
}),
@ -229,7 +229,7 @@ java_import {
// Check the behavior of the snapshot when it is preferred.
snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) {
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/prebuilt_mybootclasspathfragment/android_common_com.android.art/meta_lic")
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/prebuilt_art-bootclasspath-fragment/android_common_com.android.art/meta_lic")
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
}),
)