Merge "Allow contents and image_name to be specified together" am: 3d14889c5b
am: 1081c7d85e
am: 143eb249d6
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1686066 Change-Id: I0a6cce08f1c1b48aa2e9a1832212bf7aa2d8fdec
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package apex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -162,13 +163,11 @@ func checkBootclasspathFragment(t *testing.T, result *android.TestResult, module
|
||||
}
|
||||
|
||||
func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
commonPreparer := android.GroupFixturePreparers(
|
||||
prepareForTestWithBootclasspathFragment,
|
||||
prepareForTestWithArtApex,
|
||||
|
||||
// Configure some libraries in the art bootclasspath_fragment.
|
||||
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
||||
).RunTestWithBp(t, `
|
||||
android.FixtureWithRootAndroidBp(`
|
||||
apex {
|
||||
name: "com.android.art",
|
||||
key: "com.android.art.key",
|
||||
@@ -208,14 +207,6 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
||||
],
|
||||
}
|
||||
|
||||
bootclasspath_fragment {
|
||||
name: "mybootclasspathfragment",
|
||||
image_name: "art",
|
||||
apex_available: [
|
||||
"com.android.art",
|
||||
],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "foo",
|
||||
jars: ["foo.jar"],
|
||||
@@ -231,39 +222,141 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
||||
"com.android.art",
|
||||
],
|
||||
}
|
||||
`),
|
||||
)
|
||||
|
||||
// Make sure that a preferred prebuilt doesn't affect the apex.
|
||||
prebuilt_bootclasspath_fragment {
|
||||
name: "mybootclasspathfragment",
|
||||
image_name: "art",
|
||||
prefer: true,
|
||||
apex_available: [
|
||||
"com.android.art",
|
||||
],
|
||||
contentsInsert := func(contents []string) string {
|
||||
insert := ""
|
||||
if contents != nil {
|
||||
insert = fmt.Sprintf(`contents: ["%s"],`, strings.Join(contents, `", "`))
|
||||
}
|
||||
`)
|
||||
return insert
|
||||
}
|
||||
|
||||
ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
|
||||
"javalib/arm/boot.art",
|
||||
"javalib/arm/boot.oat",
|
||||
"javalib/arm/boot.vdex",
|
||||
"javalib/arm/boot-bar.art",
|
||||
"javalib/arm/boot-bar.oat",
|
||||
"javalib/arm/boot-bar.vdex",
|
||||
"javalib/arm64/boot.art",
|
||||
"javalib/arm64/boot.oat",
|
||||
"javalib/arm64/boot.vdex",
|
||||
"javalib/arm64/boot-bar.art",
|
||||
"javalib/arm64/boot-bar.oat",
|
||||
"javalib/arm64/boot-bar.vdex",
|
||||
"javalib/bar.jar",
|
||||
"javalib/foo.jar",
|
||||
addSource := func(contents ...string) android.FixturePreparer {
|
||||
text := fmt.Sprintf(`
|
||||
bootclasspath_fragment {
|
||||
name: "mybootclasspathfragment",
|
||||
image_name: "art",
|
||||
%s
|
||||
apex_available: [
|
||||
"com.android.art",
|
||||
],
|
||||
}
|
||||
`, contentsInsert(contents))
|
||||
|
||||
return android.FixtureAddTextFile("art/build/boot/Android.bp", text)
|
||||
}
|
||||
|
||||
addPrebuilt := func(prefer bool, contents ...string) android.FixturePreparer {
|
||||
text := fmt.Sprintf(`
|
||||
prebuilt_bootclasspath_fragment {
|
||||
name: "mybootclasspathfragment",
|
||||
image_name: "art",
|
||||
%s
|
||||
prefer: %t,
|
||||
apex_available: [
|
||||
"com.android.art",
|
||||
],
|
||||
}
|
||||
`, contentsInsert(contents), prefer)
|
||||
return android.FixtureAddTextFile("prebuilts/module_sdk/art/Android.bp", text)
|
||||
}
|
||||
|
||||
t.Run("boot image files", func(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
commonPreparer,
|
||||
|
||||
// Configure some libraries in the art bootclasspath_fragment that match the source
|
||||
// bootclasspath_fragment's contents property.
|
||||
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
||||
addSource("foo", "bar"),
|
||||
|
||||
// Make sure that a preferred prebuilt with consistent contents doesn't affect the apex.
|
||||
addPrebuilt(true, "foo", "bar"),
|
||||
).RunTest(t)
|
||||
|
||||
ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
|
||||
"javalib/arm/boot.art",
|
||||
"javalib/arm/boot.oat",
|
||||
"javalib/arm/boot.vdex",
|
||||
"javalib/arm/boot-bar.art",
|
||||
"javalib/arm/boot-bar.oat",
|
||||
"javalib/arm/boot-bar.vdex",
|
||||
"javalib/arm64/boot.art",
|
||||
"javalib/arm64/boot.oat",
|
||||
"javalib/arm64/boot.vdex",
|
||||
"javalib/arm64/boot-bar.art",
|
||||
"javalib/arm64/boot-bar.oat",
|
||||
"javalib/arm64/boot-bar.vdex",
|
||||
"javalib/bar.jar",
|
||||
"javalib/foo.jar",
|
||||
})
|
||||
|
||||
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
|
||||
`bar`,
|
||||
`com.android.art.key`,
|
||||
`mybootclasspathfragment`,
|
||||
})
|
||||
})
|
||||
|
||||
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
|
||||
`bar`,
|
||||
`com.android.art.key`,
|
||||
`mybootclasspathfragment`,
|
||||
t.Run("source with inconsistency between config and contents", func(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
commonPreparer,
|
||||
|
||||
// Create an inconsistency between the ArtApexJars configuration and the art source
|
||||
// bootclasspath_fragment module's contents property.
|
||||
java.FixtureConfigureBootJars("com.android.art:foo"),
|
||||
addSource("foo", "bar"),
|
||||
).
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)).
|
||||
RunTest(t)
|
||||
})
|
||||
|
||||
t.Run("prebuilt with inconsistency between config and contents", func(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
commonPreparer,
|
||||
|
||||
// Create an inconsistency between the ArtApexJars configuration and the art
|
||||
// prebuilt_bootclasspath_fragment module's contents property.
|
||||
java.FixtureConfigureBootJars("com.android.art:foo"),
|
||||
addPrebuilt(false, "foo", "bar"),
|
||||
).
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)).
|
||||
RunTest(t)
|
||||
})
|
||||
|
||||
t.Run("preferred prebuilt with inconsistency between config and contents", func(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
commonPreparer,
|
||||
|
||||
// Create an inconsistency between the ArtApexJars configuration and the art
|
||||
// prebuilt_bootclasspath_fragment module's contents property.
|
||||
java.FixtureConfigureBootJars("com.android.art:foo"),
|
||||
addPrebuilt(true, "foo", "bar"),
|
||||
|
||||
// Source contents property is consistent with the config.
|
||||
addSource("foo"),
|
||||
).
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)).
|
||||
RunTest(t)
|
||||
})
|
||||
|
||||
t.Run("source preferred and prebuilt with inconsistency between config and contents", func(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
commonPreparer,
|
||||
|
||||
// Create an inconsistency between the ArtApexJars configuration and the art
|
||||
// prebuilt_bootclasspath_fragment module's contents property.
|
||||
java.FixtureConfigureBootJars("com.android.art:foo"),
|
||||
addPrebuilt(false, "foo", "bar"),
|
||||
|
||||
// Source contents property is consistent with the config.
|
||||
addSource("foo"),
|
||||
|
||||
// This should pass because while the prebuilt is inconsistent with the configuration it is
|
||||
// not actually used.
|
||||
).RunTest(t)
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user