diff --git a/apex/Android.bp b/apex/Android.bp index 7ffca0ea5..61d7fb2e2 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -38,6 +38,7 @@ bootstrap_go_package { "apex_test.go", "bootclasspath_fragment_test.go", "classpath_element_test.go", + "dexpreopt_bootjars_test.go", "metadata_test.go", "platform_bootclasspath_test.go", "systemserver_classpath_fragment_test.go", diff --git a/apex/apex_test.go b/apex/apex_test.go index bf9c71b2e..a83b94db0 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -147,7 +147,7 @@ var prepareForApexTest = android.GroupFixturePreparers( android.PrepareForTestWithAndroidBuildComponents, bpf.PrepareForTestWithBpf, cc.PrepareForTestWithCcBuildComponents, - java.PrepareForTestWithJavaDefaultModules, + java.PrepareForTestWithDexpreopt, prebuilt_etc.PrepareForTestWithPrebuiltEtc, rust.PrepareForTestWithRustDefaultModules, sh.PrepareForTestWithShBuildComponents, diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go index 3e55ccc11..0a72116a6 100644 --- a/apex/bootclasspath_fragment_test.go +++ b/apex/bootclasspath_fragment_test.go @@ -1250,7 +1250,7 @@ func TestBootclasspathFragment_AndroidNonUpdatable(t *testing.T) { func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithBootclasspathFragment, - java.PrepareForTestWithJavaDefaultModules, + java.PrepareForTestWithDexpreopt, prepareForTestWithArtApex, prepareForTestWithMyapex, // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. diff --git a/java/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go similarity index 94% rename from java/dexpreopt_bootjars_test.go rename to apex/dexpreopt_bootjars_test.go index 908380813..ef66807f0 100644 --- a/java/dexpreopt_bootjars_test.go +++ b/apex/dexpreopt_bootjars_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package java +package apex import ( "path/filepath" @@ -20,6 +20,7 @@ import ( "testing" "android/soong/android" + "android/soong/java" ) func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOutputs []string) { @@ -48,10 +49,10 @@ func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOu ` result := android.GroupFixturePreparers( - prepareForJavaTest, - PrepareForTestWithJavaSdkLibraryFiles, - FixtureWithLastReleaseApis("foo"), - FixtureConfigureBootJars("platform:foo", "system_ext:bar", "platform:baz"), + java.PrepareForTestWithDexpreopt, + java.PrepareForTestWithJavaSdkLibraryFiles, + java.FixtureWithLastReleaseApis("foo"), + java.FixtureConfigureBootJars("platform:foo", "system_ext:bar", "platform:baz"), ).RunTestWithBp(t, bp) platformBootclasspath := result.ModuleForTests("platform-bootclasspath", "android_common") diff --git a/apex/metadata_test.go b/apex/metadata_test.go index f6ead424e..fed5beae7 100644 --- a/apex/metadata_test.go +++ b/apex/metadata_test.go @@ -27,7 +27,7 @@ import ( func TestModulesSingleton(t *testing.T) { result := android.GroupFixturePreparers( PrepareForTestWithApexMultitreeSingleton, - java.PrepareForTestWithDexpreopt, + java.PrepareForTestWithJavaDefaultModules, PrepareForTestWithApexBuildComponents, java.FixtureConfigureApexBootJars("myapex:foo"), java.PrepareForTestWithJavaSdkLibraryFiles, diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index 4b48da8e2..05bb13689 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -20,6 +20,7 @@ import ( "testing" "android/soong/android" + "android/soong/dexpreopt" "android/soong/java" "github.com/google/blueprint" @@ -30,7 +31,7 @@ import ( // apexes. var prepareForTestWithPlatformBootclasspath = android.GroupFixturePreparers( - java.PrepareForTestWithDexpreopt, + java.PrepareForTestWithJavaDefaultModules, PrepareForTestWithApexBuildComponents, ) @@ -249,6 +250,8 @@ func TestPlatformBootclasspathDependencies(t *testing.T) { java.FixtureConfigureApexBootJars("myapex:bar"), java.PrepareForTestWithJavaSdkLibraryFiles, java.FixtureWithLastReleaseApis("foo"), + java.PrepareForTestWithDexpreopt, + dexpreopt.FixtureDisableDexpreoptBootImages(false), ).RunTestWithBp(t, ` apex { name: "com.android.art", @@ -539,9 +542,6 @@ func TestPlatformBootclasspath_AlwaysUsePrebuiltSdks(t *testing.T) { // Not a prebuilt as no prebuilt existed when it was added. "platform:legacy.core.platform.api.stubs", - // Needed for generating the boot image. - "platform:dex2oatd", - // The platform_bootclasspath intentionally adds dependencies on both source and prebuilt // modules when available as it does not know which one will be preferred. "myapex:foo", diff --git a/java/Android.bp b/java/Android.bp index 27a0a3853..4af2a14eb 100644 --- a/java/Android.bp +++ b/java/Android.bp @@ -87,7 +87,6 @@ bootstrap_go_package { "device_host_converter_test.go", "dex_test.go", "dexpreopt_test.go", - "dexpreopt_bootjars_test.go", "dexpreopt_config_test.go", "droiddoc_test.go", "droidstubs_test.go", diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go index f91ac5cc3..fedd5640e 100644 --- a/java/dexpreopt_test.go +++ b/java/dexpreopt_test.go @@ -212,7 +212,7 @@ func TestDexpreoptEnabled(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { preparers := android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModules, + PrepareForTestWithDexpreopt, PrepareForTestWithFakeApexMutator, dexpreopt.FixtureSetApexSystemServerJars("com.android.apex1:service-foo"), ) @@ -257,7 +257,7 @@ func TestDex2oatToolDeps(t *testing.T) { preparers := android.GroupFixturePreparers( cc.PrepareForTestWithCcDefaultModules, - PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd, + PrepareForTestWithDexpreoptWithoutFakeDex2oatd, dexpreopt.PrepareForTestByEnablingDexpreopt) testDex2oatToolDep := func(sourceEnabled, prebuiltEnabled, prebuiltPreferred bool, @@ -299,7 +299,7 @@ func TestDex2oatToolDeps(t *testing.T) { func TestDexpreoptBuiltInstalledForApex(t *testing.T) { preparers := android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModules, + PrepareForTestWithDexpreopt, PrepareForTestWithFakeApexMutator, dexpreopt.FixtureSetApexSystemServerJars("com.android.apex1:service-foo"), ) @@ -386,7 +386,7 @@ func verifyEntries(t *testing.T, message string, expectedModule string, func TestAndroidMkEntriesForApex(t *testing.T) { preparers := android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModules, + PrepareForTestWithDexpreopt, PrepareForTestWithFakeApexMutator, dexpreopt.FixtureSetApexSystemServerJars("com.android.apex1:service-foo"), ) diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go index 75b7bb7c8..ef792f970 100644 --- a/java/hiddenapi_singleton_test.go +++ b/java/hiddenapi_singleton_test.go @@ -39,7 +39,9 @@ var prepareForTestWithDefaultPlatformBootclasspath = android.FixtureAddTextFile( `) var hiddenApiFixtureFactory = android.GroupFixturePreparers( - prepareForJavaTest, PrepareForTestWithHiddenApiBuildComponents) + PrepareForTestWithJavaDefaultModules, + PrepareForTestWithHiddenApiBuildComponents, +) func TestHiddenAPISingleton(t *testing.T) { result := android.GroupFixturePreparers( diff --git a/java/java_test.go b/java/java_test.go index 553b762ee..2a4913ecd 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -46,12 +46,11 @@ var prepareForJavaTest = android.GroupFixturePreparers( // Get the CC build components but not default modules. cc.PrepareForTestWithCcBuildComponents, // Include all the default java modules. - PrepareForTestWithJavaDefaultModules, + PrepareForTestWithDexpreopt, PrepareForTestWithOverlayBuildComponents, android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { ctx.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory) }), - PrepareForTestWithDexpreopt, ) func TestMain(m *testing.M) { diff --git a/java/platform_bootclasspath_test.go b/java/platform_bootclasspath_test.go index 10c918715..ff2da4bb2 100644 --- a/java/platform_bootclasspath_test.go +++ b/java/platform_bootclasspath_test.go @@ -18,14 +18,12 @@ import ( "testing" "android/soong/android" - "android/soong/dexpreopt" ) // Contains some simple tests for platform_bootclasspath. var prepareForTestWithPlatformBootclasspath = android.GroupFixturePreparers( PrepareForTestWithJavaDefaultModules, - dexpreopt.PrepareForTestByEnablingDexpreopt, ) func TestPlatformBootclasspath(t *testing.T) { diff --git a/java/testing.go b/java/testing.go index f68e12ff4..4ff2aa497 100644 --- a/java/testing.go +++ b/java/testing.go @@ -80,9 +80,7 @@ var prepareForTestWithFrameworkDeps = android.GroupFixturePreparers( }.AddToFixture(), ) -// Test fixture preparer that will define all default java modules except the -// fake_tool_binary for dex2oatd. -var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixturePreparers( +var prepareForTestWithJavaDefaultModulesBase = android.GroupFixturePreparers( // Make sure that all the module types used in the defaults are registered. PrepareForTestWithJavaBuildComponents, prepareForTestWithFrameworkDeps, @@ -92,13 +90,21 @@ var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixtu // Test fixture preparer that will define default java modules, e.g. standard prebuilt modules. var PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd, - dexpreopt.PrepareForTestWithFakeDex2oatd, + prepareForTestWithJavaDefaultModulesBase, + dexpreopt.FixtureDisableDexpreoptBootImages(true), + dexpreopt.FixtureDisableDexpreopt(true), ) // Provides everything needed by dexpreopt. var PrepareForTestWithDexpreopt = android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModules, + prepareForTestWithJavaDefaultModulesBase, + dexpreopt.PrepareForTestWithFakeDex2oatd, + dexpreopt.PrepareForTestByEnablingDexpreopt, +) + +// Provides everything needed by dexpreopt except the fake_tool_binary for dex2oatd. +var PrepareForTestWithDexpreoptWithoutFakeDex2oatd = android.GroupFixturePreparers( + prepareForTestWithJavaDefaultModulesBase, dexpreopt.PrepareForTestByEnablingDexpreopt, ) diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index 0d6496dd3..bef82d601 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -74,7 +74,7 @@ func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) andro func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJava, - java.PrepareForTestWithJavaDefaultModules, + java.PrepareForTestWithDexpreopt, prepareForSdkTestWithApex, // Some additional files needed for the art apex.