diff options
author | 2021-09-15 14:11:07 +0000 | |
---|---|---|
committer | 2021-09-15 14:11:07 +0000 | |
commit | 92346c483249726164f4bd140413d60391121763 (patch) | |
tree | dbfcb43369c2e014c83676633aa4da9b6c8fb212 /java/dexpreopt_test.go | |
parent | ca9bc98e0cfe9a519cfdd13450a68f1ed7ad5b02 (diff) |
Revert "Preopt APEX system server jars."
This reverts commit ca9bc98e0cfe9a519cfdd13450a68f1ed7ad5b02.
Reason for revert: breaks build
Bug: 200024131
Change-Id: Ide07b4c4d267370ae31107b1598b2f878c701282
Diffstat (limited to 'java/dexpreopt_test.go')
-rw-r--r-- | java/dexpreopt_test.go | 227 |
1 files changed, 5 insertions, 222 deletions
diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go index 1c1070add..8dc7b798a 100644 --- a/java/dexpreopt_test.go +++ b/java/dexpreopt_test.go @@ -17,7 +17,6 @@ package java import ( "fmt" "runtime" - "strings" "testing" "android/soong/android" @@ -25,17 +24,11 @@ import ( "android/soong/dexpreopt" ) -func init() { - RegisterFakeRuntimeApexMutator() -} - func TestDexpreoptEnabled(t *testing.T) { tests := []struct { - name string - bp string - moduleName string - apexVariant bool - enabled bool + name string + bp string + enabled bool }{ { name: "app", @@ -155,81 +148,13 @@ func TestDexpreoptEnabled(t *testing.T) { }`, enabled: true, }, - { - name: "apex variant", - bp: ` - java_library { - name: "foo", - installable: true, - srcs: ["a.java"], - apex_available: ["com.android.apex1"], - }`, - apexVariant: true, - enabled: false, - }, - { - name: "apex variant of apex system server jar", - bp: ` - java_library { - name: "service-foo", - installable: true, - srcs: ["a.java"], - apex_available: ["com.android.apex1"], - }`, - moduleName: "service-foo", - apexVariant: true, - enabled: true, - }, - { - name: "apex variant of prebuilt apex system server jar", - bp: ` - java_library { - name: "prebuilt_service-foo", - installable: true, - srcs: ["a.java"], - apex_available: ["com.android.apex1"], - }`, - moduleName: "prebuilt_service-foo", - apexVariant: true, - enabled: true, - }, - { - name: "platform variant of apex system server jar", - bp: ` - java_library { - name: "service-foo", - installable: true, - srcs: ["a.java"], - apex_available: ["com.android.apex1"], - }`, - moduleName: "service-foo", - apexVariant: false, - enabled: false, - }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - preparers := android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModules, - PrepareForTestWithFakeApexMutator, - dexpreopt.FixtureSetApexSystemServerJars("com.android.apex1:service-foo"), - ) - - result := preparers.RunTestWithBp(t, test.bp) - ctx := result.TestContext - - moduleName := "foo" - if test.moduleName != "" { - moduleName = test.moduleName - } - - variant := "android_common" - if test.apexVariant { - variant += "_apex1000" - } + ctx, _ := testJava(t, test.bp) - dexpreopt := ctx.ModuleForTests(moduleName, variant).MaybeRule("dexpreopt") + dexpreopt := ctx.ModuleForTests("foo", "android_common").MaybeRule("dexpreopt") enabled := dexpreopt.Rule != nil if enabled != test.enabled { @@ -295,145 +220,3 @@ func TestDex2oatToolDeps(t *testing.T) { testDex2oatToolDep(true, true, true, prebuiltDex2oatPath) testDex2oatToolDep(false, true, false, prebuiltDex2oatPath) } - -func TestDexpreoptBuiltInstalledForApex(t *testing.T) { - preparers := android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModules, - PrepareForTestWithFakeApexMutator, - dexpreopt.FixtureSetApexSystemServerJars("com.android.apex1:service-foo"), - ) - - // An APEX system server jar. - result := preparers.RunTestWithBp(t, ` - java_library { - name: "service-foo", - installable: true, - srcs: ["a.java"], - apex_available: ["com.android.apex1"], - }`) - ctx := result.TestContext - module := ctx.ModuleForTests("service-foo", "android_common_apex1000") - library := module.Module().(*Library) - - installs := library.dexpreopter.DexpreoptBuiltInstalledForApex() - - android.AssertIntEquals(t, "install count", 2, len(installs)) - - android.AssertStringEquals(t, "installs[0] FullModuleName", - "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.odex", - installs[0].FullModuleName()) - - android.AssertStringEquals(t, "installs[0] SubModuleName", - "-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.odex", - installs[0].SubModuleName()) - - android.AssertStringEquals(t, "installs[1] FullModuleName", - "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.vdex", - installs[1].FullModuleName()) - - android.AssertStringEquals(t, "installs[1] SubModuleName", - "-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.vdex", - installs[1].SubModuleName()) - - // Not an APEX system server jar. - result = preparers.RunTestWithBp(t, ` - java_library { - name: "foo", - installable: true, - srcs: ["a.java"], - }`) - ctx = result.TestContext - module = ctx.ModuleForTests("foo", "android_common") - library = module.Module().(*Library) - - installs = library.dexpreopter.DexpreoptBuiltInstalledForApex() - - android.AssertIntEquals(t, "install count", 0, len(installs)) -} - -func filterDexpreoptEntriesList(entriesList []android.AndroidMkEntries) []android.AndroidMkEntries { - var results []android.AndroidMkEntries - for _, entries := range entriesList { - if strings.Contains(entries.EntryMap["LOCAL_MODULE"][0], "-dexpreopt-") { - results = append(results, entries) - } - } - return results -} - -func verifyEntries(t *testing.T, message string, expectedModule string, - expectedPrebuiltModuleFile string, expectedModulePath string, expectedInstalledModuleStem string, - entries android.AndroidMkEntries) { - android.AssertStringEquals(t, message+" LOCAL_MODULE", expectedModule, - entries.EntryMap["LOCAL_MODULE"][0]) - - android.AssertStringEquals(t, message+" LOCAL_MODULE_CLASS", "ETC", - entries.EntryMap["LOCAL_MODULE_CLASS"][0]) - - android.AssertStringDoesContain(t, message+" LOCAL_PREBUILT_MODULE_FILE", - entries.EntryMap["LOCAL_PREBUILT_MODULE_FILE"][0], expectedPrebuiltModuleFile) - - android.AssertStringDoesContain(t, message+" LOCAL_MODULE_PATH", - entries.EntryMap["LOCAL_MODULE_PATH"][0], expectedModulePath) - - android.AssertStringEquals(t, message+" LOCAL_INSTALLED_MODULE_STEM", - expectedInstalledModuleStem, entries.EntryMap["LOCAL_INSTALLED_MODULE_STEM"][0]) - - android.AssertStringEquals(t, message+" LOCAL_NOT_AVAILABLE_FOR_PLATFORM", - "false", entries.EntryMap["LOCAL_NOT_AVAILABLE_FOR_PLATFORM"][0]) -} - -func TestAndroidMkEntriesForApex(t *testing.T) { - preparers := android.GroupFixturePreparers( - PrepareForTestWithJavaDefaultModules, - PrepareForTestWithFakeApexMutator, - dexpreopt.FixtureSetApexSystemServerJars("com.android.apex1:service-foo"), - ) - - // An APEX system server jar. - result := preparers.RunTestWithBp(t, ` - java_library { - name: "service-foo", - installable: true, - srcs: ["a.java"], - apex_available: ["com.android.apex1"], - }`) - ctx := result.TestContext - module := ctx.ModuleForTests("service-foo", "android_common_apex1000") - - entriesList := android.AndroidMkEntriesForTest(t, ctx, module.Module()) - entriesList = filterDexpreoptEntriesList(entriesList) - - android.AssertIntEquals(t, "entries count", 2, len(entriesList)) - - verifyEntries(t, - "entriesList[0]", - "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.odex", - "/dexpreopt/oat/arm64/javalib.odex", - "/system/framework/oat/arm64", - "apex@com.android.apex1@javalib@service-foo.jar@classes.odex", - entriesList[0]) - - verifyEntries(t, - "entriesList[1]", - "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.vdex", - "/dexpreopt/oat/arm64/javalib.vdex", - "/system/framework/oat/arm64", - "apex@com.android.apex1@javalib@service-foo.jar@classes.vdex", - entriesList[1]) - - // Not an APEX system server jar. - result = preparers.RunTestWithBp(t, ` - java_library { - name: "foo", - installable: true, - srcs: ["a.java"], - }`) - ctx = result.TestContext - module = ctx.ModuleForTests("foo", "android_common") - - entriesList = android.AndroidMkEntriesForTest(t, ctx, module.Module()) - entriesList = filterDexpreoptEntriesList(entriesList) - - android.AssertIntEquals(t, "entries count", 0, len(entriesList)) -} |