Prepare tests for dexpreopt changes.

After this change, there is a clear separation between tests that are
related to dexpreopt and tests that are not. The former uses
PrepareForTestWithDexpreopt, while the latter uses
PrepareForTestWithJavaDefaultModules. The benefit is that the latter
will no longer affected by any dexpreopt changes.

Bug: 280776428
Test: m nothing
Change-Id: Ib957765b9287d51c082e0a33cee17a6bb56daeef
This commit is contained in:
Jiakai Zhang 2023-05-11 16:39:27 +01:00
parent 9241da9662
commit b95998be73
13 changed files with 35 additions and 29 deletions

View file

@ -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",

View file

@ -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,

View file

@ -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.

View file

@ -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")

View file

@ -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,

View file

@ -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",

View file

@ -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",

View file

@ -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"),
)

View file

@ -39,7 +39,9 @@ var prepareForTestWithDefaultPlatformBootclasspath = android.FixtureAddTextFile(
`)
var hiddenApiFixtureFactory = android.GroupFixturePreparers(
prepareForJavaTest, PrepareForTestWithHiddenApiBuildComponents)
PrepareForTestWithJavaDefaultModules,
PrepareForTestWithHiddenApiBuildComponents,
)
func TestHiddenAPISingleton(t *testing.T) {
result := android.GroupFixturePreparers(

View file

@ -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) {

View file

@ -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) {

View file

@ -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,
)

View file

@ -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.