diff options
| author | 2021-04-13 18:13:34 +0000 | |
|---|---|---|
| committer | 2021-04-13 18:13:34 +0000 | |
| commit | 21fb92d7f6f033f556c5270c702bbcab80c861c1 (patch) | |
| tree | cdab779d94707dbca77ed4dad4728035cc77438b | |
| parent | 6050c3c31e8d8444adc4d8f373fa2f75f321ba1c (diff) | |
| parent | 60264a0b99209ac0ada5e07a509f2ea1358bb7bd (diff) | |
Merge "Improve realism of boot jar tests"
| -rw-r--r-- | apex/apex_test.go | 151 | ||||
| -rw-r--r-- | apex/boot_image_test.go | 8 | ||||
| -rw-r--r-- | apex/platform_bootclasspath_test.go | 6 | ||||
| -rw-r--r-- | java/hiddenapi_singleton_test.go | 20 | ||||
| -rw-r--r-- | java/platform_bootclasspath_test.go | 4 | ||||
| -rw-r--r-- | java/testing.go | 37 |
6 files changed, 121 insertions, 105 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go index ee4255e0c..61e886499 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -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) }) } diff --git a/apex/boot_image_test.go b/apex/boot_image_test.go index aa0d9c4b9..d447d7011 100644 --- a/apex/boot_image_test.go +++ b/apex/boot_image_test.go @@ -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", diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index 2ea640179..74830d385 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -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, ` diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go index 5c449e506..e5e1c2547 100644 --- a/java/hiddenapi_singleton_test.go +++ b/java/hiddenapi_singleton_test.go @@ -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 { diff --git a/java/platform_bootclasspath_test.go b/java/platform_bootclasspath_test.go index a0d05016a..c740911f1 100644 --- a/java/platform_bootclasspath_test.go +++ b/java/platform_bootclasspath_test.go @@ -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 { diff --git a/java/testing.go b/java/testing.go index 6ebc747db..aee0710c4 100644 --- a/java/testing.go +++ b/java/testing.go @@ -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. // |