Improve realism of boot jar tests

Boot jars, updatable boot jars and art apex jars are part of two
separate but related configuration objects, the main Config struct
(actually the nested productVariables struct) and the dexpreopt
specific GlobalConfig. The fields in both are initialized from the same
data in the make config files but handled separately.

Previously each test that used one of the configuration objects would
generally just initialize the one it used. That would make the test
sensitive to the specific configuration object that was used. A
refactoring that change the code from using one configuration object to
the other would cause the test to fail.

Also, some tests would inadvertently create invalid configurations by
setting ArtApexJars without also setting BootJars. While the ability to
create invalid configurations is useful (and there are some tests that
exist to verify the behavior in that case) most tests should not be
using them.

This change simplifies the configuration of the tests and improves
their realism by:
1. Providing a new FixtureConfigureBootJars method that takes a set of
   boot jars and sets ArtApexJars, and BootJars in the
   dexpreopt.GlobalConfig and BootJars in the product variables too.
2. Providing a new FixtureConfigureUpdatableBootJars method that takes
   a set of boot jars and sets UpdatableBootJars in both the
   dexpreopt.GlobalConfig and productVariables.
3. Migrating existing tests to use these new methods.

Some tests still use the dexpreopt.FixtureSet...Jars() methods directly,
generally to create invalid configurations.

Bug: 177892522
Test: m nothing
Change-Id: I4d8f0b9762cfcc7ae6383bef08563d7c3fa13955
This commit is contained in:
Paul Duffin
2021-04-12 20:02:36 +01:00
parent 0b659866e8
commit 60264a0b99
6 changed files with 121 additions and 105 deletions

View File

@@ -4375,9 +4375,7 @@ func TestPrebuiltOverrides(t *testing.T) {
// These tests verify that the prebuilt_apex/deapexer to java_import wiring allows for the
// propagation of paths to dex implementation jars from the former to the latter.
func TestPrebuiltExportDexImplementationJars(t *testing.T) {
transform := func(config *dexpreopt.GlobalConfig) {
// Empty transformation.
}
transform := android.NullFixturePreparer
checkDexJarBuildPath := func(t *testing.T, ctx *android.TestContext, name string) {
// Make sure the import has been given the correct path to the dex jar.
@@ -4547,9 +4545,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
}
func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
transform := func(config *dexpreopt.GlobalConfig) {
config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo", "myapex:libbar"})
}
preparer := java.FixtureConfigureBootJars("myapex:libfoo", "myapex:libbar")
checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) {
t.Helper()
@@ -4605,7 +4601,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
}
`
ctx := testDexpreoptWithApexes(t, bp, "", transform)
ctx := testDexpreoptWithApexes(t, bp, "", preparer)
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
@@ -4639,7 +4635,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
}
`
ctx := testDexpreoptWithApexes(t, bp, "", transform)
ctx := testDexpreoptWithApexes(t, bp, "", preparer)
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
@@ -4698,7 +4694,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
// prebuilt_apex module always depends on the prebuilt, and so it doesn't
// find the dex boot jar in it. We either need to disable the source libfoo
// or make the prebuilt libfoo preferred.
testDexpreoptWithApexes(t, bp, "failed to find a dex jar path for module 'libfoo'", transform)
testDexpreoptWithApexes(t, bp, "failed to find a dex jar path for module 'libfoo'", preparer)
})
t.Run("prebuilt library preferred with source", func(t *testing.T) {
@@ -4746,7 +4742,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
}
`
ctx := testDexpreoptWithApexes(t, bp, "", transform)
ctx := testDexpreoptWithApexes(t, bp, "", preparer)
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
@@ -4813,7 +4809,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
}
`
ctx := testDexpreoptWithApexes(t, bp, "", transform)
ctx := testDexpreoptWithApexes(t, bp, "", preparer)
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar")
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar")
@@ -4882,7 +4878,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
}
`
ctx := testDexpreoptWithApexes(t, bp, "", transform)
ctx := testDexpreoptWithApexes(t, bp, "", preparer)
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
@@ -6440,7 +6436,7 @@ func TestAppSetBundlePrebuilt(t *testing.T) {
android.AssertStringEquals(t, "myapex input", extractorOutput, copiedApex.Input.String())
}
func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, transformDexpreoptConfig func(*dexpreopt.GlobalConfig)) {
func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer android.FixturePreparer) {
t.Helper()
bp := `
@@ -6528,10 +6524,10 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, transformDexpre
}
`
testDexpreoptWithApexes(t, bp, errmsg, transformDexpreoptConfig)
testDexpreoptWithApexes(t, bp, errmsg, preparer)
}
func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreoptConfig func(*dexpreopt.GlobalConfig)) *android.TestContext {
func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, preparer android.FixturePreparer) *android.TestContext {
t.Helper()
fs := android.MockFS{
@@ -6557,17 +6553,7 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt
java.PrepareForTestWithJavaDefaultModules,
java.PrepareForTestWithJavaSdkLibraryFiles,
PrepareForTestWithApexBuildComponents,
android.FixtureModifyConfig(func(config android.Config) {
pathCtx := android.PathContextForTesting(config)
dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx)
transformDexpreoptConfig(dexpreoptConfig)
dexpreopt.SetTestGlobalConfig(config, dexpreoptConfig)
// Make sure that any changes to these dexpreopt properties are mirrored in the corresponding
// product variables.
config.TestProductVariables.BootJars = dexpreoptConfig.BootJars
config.TestProductVariables.UpdatableBootJars = dexpreoptConfig.UpdatableBootJars
}),
preparer,
fs.AddToFixture(),
).
ExtendWithErrorHandler(errorHandler).
@@ -6608,92 +6594,95 @@ func TestUpdatableDefault_should_set_min_sdk_version(t *testing.T) {
}
func TestNoUpdatableJarsInBootImage(t *testing.T) {
var err string
var transform func(*dexpreopt.GlobalConfig)
// 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) {
transform = func(config *dexpreopt.GlobalConfig) {
config.ArtApexJars = android.CreateTestConfiguredJarList([]string{"com.android.art.debug:some-art-lib"})
}
testNoUpdatableJarsInBootImage(t, "", transform)
preparer := java.FixtureConfigureBootJars("com.android.art.debug:some-art-lib")
testNoUpdatableJarsInBootImage(t, "", preparer)
})
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`
transform = func(config *dexpreopt.GlobalConfig) {
config.BootJars = android.CreateTestConfiguredJarList([]string{"com.android.art.debug:some-art-lib"})
}
testNoUpdatableJarsInBootImage(t, err, transform)
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")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("updatable jar from some other apex in the ART boot image => error", func(t *testing.T) {
err = `module "some-updatable-apex-lib" from updatable apexes \["some-updatable-apex"\] is not allowed in the ART boot image`
transform = func(config *dexpreopt.GlobalConfig) {
config.ArtApexJars = android.CreateTestConfiguredJarList([]string{"some-updatable-apex:some-updatable-apex-lib"})
}
testNoUpdatableJarsInBootImage(t, err, transform)
err := `module "some-updatable-apex-lib" from updatable apexes \["some-updatable-apex"\] is not allowed in the ART boot image`
// 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 = `module "some-non-updatable-apex-lib" is not allowed in the ART boot image`
transform = func(config *dexpreopt.GlobalConfig) {
config.ArtApexJars = android.CreateTestConfiguredJarList([]string{"some-non-updatable-apex:some-non-updatable-apex-lib"})
}
testNoUpdatableJarsInBootImage(t, err, transform)
err := `module "some-non-updatable-apex-lib" is not allowed in the ART boot image`
// 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 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`
transform = func(config *dexpreopt.GlobalConfig) {
config.BootJars = android.CreateTestConfiguredJarList([]string{"some-updatable-apex:some-updatable-apex-lib"})
}
testNoUpdatableJarsInBootImage(t, err, transform)
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")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("non-updatable jar from some other apex in the framework boot image => ok", func(t *testing.T) {
transform = func(config *dexpreopt.GlobalConfig) {
config.BootJars = android.CreateTestConfiguredJarList([]string{"some-non-updatable-apex:some-non-updatable-apex-lib"})
}
testNoUpdatableJarsInBootImage(t, "", transform)
preparer := java.FixtureConfigureBootJars("some-non-updatable-apex:some-non-updatable-apex-lib")
testNoUpdatableJarsInBootImage(t, "", preparer)
})
t.Run("nonexistent jar in the ART boot image => error", func(t *testing.T) {
err = "failed to find a dex jar path for module 'nonexistent'"
transform = func(config *dexpreopt.GlobalConfig) {
config.ArtApexJars = android.CreateTestConfiguredJarList([]string{"platform:nonexistent"})
}
testNoUpdatableJarsInBootImage(t, err, transform)
err := "failed to find a dex jar path for module 'nonexistent'"
preparer := java.FixtureConfigureBootJars("platform:nonexistent")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("nonexistent jar in the framework boot image => error", func(t *testing.T) {
err = "failed to find a dex jar path for module 'nonexistent'"
transform = func(config *dexpreopt.GlobalConfig) {
config.BootJars = android.CreateTestConfiguredJarList([]string{"platform:nonexistent"})
}
testNoUpdatableJarsInBootImage(t, err, transform)
err := "failed to find a dex jar path for 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 = `module "some-platform-lib" is not allowed in the ART boot image`
transform = func(config *dexpreopt.GlobalConfig) {
config.ArtApexJars = android.CreateTestConfiguredJarList([]string{"platform:some-platform-lib"})
}
testNoUpdatableJarsInBootImage(t, err, transform)
err := `module "some-platform-lib" is not allowed in the ART boot image`
// Update the dexpreopt ArtApexJars directly.
preparer := prepareSetArtJars("platform:some-platform-lib")
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("platform jar in the framework boot image => ok", func(t *testing.T) {
transform = func(config *dexpreopt.GlobalConfig) {
config.BootJars = android.CreateTestConfiguredJarList([]string{"platform:some-platform-lib"})
}
testNoUpdatableJarsInBootImage(t, "", transform)
preparer := java.FixtureConfigureBootJars("platform:some-platform-lib")
testNoUpdatableJarsInBootImage(t, "", preparer)
})
}
func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
transform := func(config *dexpreopt.GlobalConfig) {
config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo"})
}
preparer := java.FixtureConfigureBootJars("myapex:libfoo")
t.Run("prebuilt no source", func(t *testing.T) {
testDexpreoptWithApexes(t, `
prebuilt_apex {
@@ -6713,7 +6702,7 @@ func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
name: "libfoo",
jars: ["libfoo.jar"],
}
`, "", transform)
`, "", preparer)
})
t.Run("prebuilt no source", func(t *testing.T) {
@@ -6735,7 +6724,7 @@ func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
name: "libfoo",
jars: ["libfoo.jar"],
}
`, "", transform)
`, "", preparer)
})
}

View File

@@ -19,7 +19,6 @@ import (
"testing"
"android/soong/android"
"android/soong/dexpreopt"
"android/soong/java"
)
@@ -42,8 +41,7 @@ func TestBootImages(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithBootImage,
// Configure some libraries in the art and framework boot images.
dexpreopt.FixtureSetArtBootJars("com.android.art:baz", "com.android.art:quuz"),
dexpreopt.FixtureSetBootJars("platform:foo", "platform:bar"),
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "platform:foo", "platform:bar"),
prepareForTestWithArtApex,
java.PrepareForTestWithJavaSdkLibraryFiles,
@@ -169,7 +167,7 @@ func TestBootImageInArtApex(t *testing.T) {
prepareForTestWithArtApex,
// Configure some libraries in the art boot image.
dexpreopt.FixtureSetArtBootJars("com.android.art:foo", "com.android.art:bar"),
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
).RunTestWithBp(t, `
apex {
name: "com.android.art",
@@ -264,7 +262,7 @@ func TestBootImageInPrebuiltArtApex(t *testing.T) {
}),
// Configure some libraries in the art boot image.
dexpreopt.FixtureSetArtBootJars("com.android.art:foo", "com.android.art:bar"),
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
).RunTestWithBp(t, `
prebuilt_apex {
name: "com.android.art",

View File

@@ -18,7 +18,6 @@ import (
"testing"
"android/soong/android"
"android/soong/dexpreopt"
"android/soong/java"
"github.com/google/blueprint"
)
@@ -37,9 +36,8 @@ func TestPlatformBootclasspathDependencies(t *testing.T) {
prepareForTestWithArtApex,
prepareForTestWithMyapex,
// Configure some libraries in the art and framework boot images.
dexpreopt.FixtureSetArtBootJars("com.android.art:baz", "com.android.art:quuz"),
dexpreopt.FixtureSetBootJars("platform:foo"),
dexpreopt.FixtureSetUpdatableBootJars("myapex:bar"),
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "platform:foo"),
java.FixtureConfigureUpdatableBootJars("myapex:bar"),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `

View File

@@ -23,12 +23,6 @@ import (
"github.com/google/blueprint/proptools"
)
func fixtureSetBootJarsProductVariable(bootJars ...string) android.FixturePreparer {
return android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BootJars = android.CreateTestConfiguredJarList(bootJars)
})
}
func fixtureSetPrebuiltHiddenApiDirProductVariable(prebuiltHiddenApiDir *string) android.FixturePreparer {
return android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.PrebuiltHiddenApiDir = prebuiltHiddenApiDir
@@ -41,7 +35,7 @@ var hiddenApiFixtureFactory = android.GroupFixturePreparers(
func TestHiddenAPISingleton(t *testing.T) {
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
fixtureSetBootJarsProductVariable("platform:foo"),
FixtureConfigureBootJars("platform:foo"),
).RunTestWithBp(t, `
java_library {
name: "foo",
@@ -61,7 +55,7 @@ func TestHiddenAPIIndexSingleton(t *testing.T) {
hiddenApiFixtureFactory,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("bar"),
fixtureSetBootJarsProductVariable("platform:foo", "platform:bar"),
FixtureConfigureBootJars("platform:foo", "platform:bar"),
).RunTestWithBp(t, `
java_library {
name: "foo",
@@ -119,7 +113,7 @@ func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T)
android.GroupFixturePreparers(
hiddenApiFixtureFactory,
fixtureSetBootJarsProductVariable("platform:foo"),
FixtureConfigureBootJars("platform:foo"),
).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorMessage)).
RunTestWithBp(t, `
java_library {
@@ -139,7 +133,7 @@ func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T)
func TestHiddenAPISingletonWithPrebuilt(t *testing.T) {
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
fixtureSetBootJarsProductVariable("platform:foo"),
FixtureConfigureBootJars("platform:foo"),
).RunTestWithBp(t, `
java_import {
name: "foo",
@@ -157,7 +151,7 @@ func TestHiddenAPISingletonWithPrebuilt(t *testing.T) {
func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) {
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
fixtureSetBootJarsProductVariable("platform:foo"),
FixtureConfigureBootJars("platform:foo"),
).RunTestWithBp(t, `
java_library {
name: "foo",
@@ -185,7 +179,7 @@ func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) {
func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) {
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
fixtureSetBootJarsProductVariable("platform:foo"),
FixtureConfigureBootJars("platform:foo"),
).RunTestWithBp(t, `
java_library {
name: "foo",
@@ -295,7 +289,7 @@ func TestHiddenAPISingletonWithPrebuiltCsvFile(t *testing.T) {
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
fixtureSetBootJarsProductVariable("platform:foo"),
FixtureConfigureBootJars("platform:foo"),
fixtureSetPrebuiltHiddenApiDirProductVariable(&prebuiltHiddenApiDir),
).RunTestWithBp(t, `
java_import {

View File

@@ -31,7 +31,7 @@ var prepareForTestWithPlatformBootclasspath = android.GroupFixturePreparers(
func TestPlatformBootclasspath(t *testing.T) {
preparer := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
dexpreopt.FixtureSetBootJars("platform:foo", "platform:bar"),
FixtureConfigureBootJars("platform:foo", "platform:bar"),
android.FixtureWithRootAndroidBp(`
platform_bootclasspath {
name: "platform-bootclasspath",
@@ -135,7 +135,7 @@ func TestPlatformBootclasspath(t *testing.T) {
func TestPlatformBootclasspath_Dist(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
dexpreopt.FixtureSetBootJars("platform:foo", "platform:bar"),
FixtureConfigureBootJars("platform:foo", "platform:bar"),
android.PrepareForTestWithAndroidMk,
android.FixtureWithRootAndroidBp(`
platform_bootclasspath {

View File

@@ -178,6 +178,43 @@ func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][
return fs
}
// FixtureConfigureBootJars configures the boot jars in both the dexpreopt.GlobalConfig and
// Config.productVariables structs. As a side effect that enables dexpreopt.
func FixtureConfigureBootJars(bootJars ...string) android.FixturePreparer {
artBootJars := []string{}
for _, j := range bootJars {
artApex := false
for _, artApexName := range artApexNames {
if strings.HasPrefix(j, artApexName+":") {
artApex = true
break
}
}
if artApex {
artBootJars = append(artBootJars, j)
}
}
return android.GroupFixturePreparers(
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BootJars = android.CreateTestConfiguredJarList(bootJars)
}),
dexpreopt.FixtureSetBootJars(bootJars...),
dexpreopt.FixtureSetArtBootJars(artBootJars...),
)
}
// FixtureConfigureUpdatableBootJars configures the updatable boot jars in both the
// dexpreopt.GlobalConfig and Config.productVariables structs. As a side effect that enables
// dexpreopt.
func FixtureConfigureUpdatableBootJars(bootJars ...string) android.FixturePreparer {
return android.GroupFixturePreparers(
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.UpdatableBootJars = android.CreateTestConfiguredJarList(bootJars)
}),
dexpreopt.FixtureSetUpdatableBootJars(bootJars...),
)
}
// registerRequiredBuildComponentsForTest registers the build components used by
// PrepareForTestWithJavaDefaultModules.
//