summaryrefslogtreecommitdiff
path: root/java/app_test.go
diff options
context:
space:
mode:
author Ulya Trafimovich <skvadrik@google.com> 2021-03-22 16:02:28 +0000
committer Ulya Trafimovich <skvadrik@google.com> 2021-03-24 11:16:11 +0000
commit9023b02c007d7a6b579c552aaafabbf630e93274 (patch)
treeae5beac0730dfd2d05840bb99283fe4b9484c0aa /java/app_test.go
parent8ef5b4f95fae49a7c5d61f0fa40f9cf86b1d0a48 (diff)
Allow using updatable boot jars in dexpreopt (but don't use them yet).
This CL handles updatable boot jars in the same hacky way as we handle non-updatable boot jars: it creates a set of predefined paths to the dex jars in a global config, then traverses all modules in a singleton context, finds updatable boot jars and adds copy rules from these jars to the predefined paths. A proper way would be to register dependencies of the dexpreopted modules on the boot jars and extracting paths to dex files by walking these dependencies. Bug: 178467404 Test: lunch aosp_cf_x86_64_phone-userdebug && m Test: added new Soong test Change-Id: I87f764109315f79315d73bf43799b70eb010fc0b
Diffstat (limited to 'java/app_test.go')
-rw-r--r--java/app_test.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go
index 252353364..825ad203a 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -26,6 +26,7 @@ import (
"android/soong/android"
"android/soong/cc"
+ "android/soong/dexpreopt"
"android/soong/genrule"
)
@@ -2422,6 +2423,66 @@ func TestUsesLibraries(t *testing.T) {
`#PCL[/system/framework/android.test.mock.jar] `)
}
+func TestDexpreoptBcp(t *testing.T) {
+ bp := `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java"],
+ api_packages: ["foo"],
+ sdk_version: "current",
+ }
+
+ java_sdk_library {
+ name: "bar",
+ srcs: ["a.java"],
+ api_packages: ["bar"],
+ permitted_packages: ["bar"],
+ sdk_version: "current",
+ }
+
+ android_app {
+ name: "app",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ }
+ `
+
+ testCases := []struct {
+ name string
+ with bool
+ expect string
+ }{
+ {
+ name: "with updatable bcp",
+ with: true,
+ expect: "/system/framework/foo.jar:/system/framework/bar.jar",
+ },
+ {
+ name: "without updatable bcp",
+ with: false,
+ expect: "/system/framework/foo.jar",
+ },
+ }
+
+ for _, test := range testCases {
+ t.Run(test.name, func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("runtime-library", "foo", "bar"),
+ dexpreopt.FixtureSetBootJars("platform:foo"),
+ dexpreopt.FixtureSetUpdatableBootJars("platform:bar"),
+ dexpreopt.FixtureSetPreoptWithUpdatableBcp(test.with),
+ ).RunTestWithBp(t, bp)
+
+ app := result.ModuleForTests("app", "android_common")
+ cmd := app.Rule("dexpreopt").RuleParams.Command
+ bcp := " -Xbootclasspath-locations:" + test.expect + " " // space at the end matters
+ android.AssertStringDoesContain(t, "dexpreopt app bcp", cmd, bcp)
+ })
+ }
+}
+
func TestCodelessApp(t *testing.T) {
testCases := []struct {
name string