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
diff --git a/apex/Android.bp b/apex/Android.bp
index 7ffca0e..61d7fb2 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -38,6 +38,7 @@
"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 bf9c71b..a83b94d 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -147,7 +147,7 @@
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 3e55ccc..0a72116 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -1250,7 +1250,7 @@
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/apex/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go
new file mode 100644
index 0000000..ef66807
--- /dev/null
+++ b/apex/dexpreopt_bootjars_test.go
@@ -0,0 +1,131 @@
+// Copyright 2019 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package apex
+
+import (
+ "path/filepath"
+ "sort"
+ "testing"
+
+ "android/soong/android"
+ "android/soong/java"
+)
+
+func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOutputs []string) {
+ bp := `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java"],
+ api_packages: ["foo"],
+ }
+
+ java_library {
+ name: "bar",
+ srcs: ["b.java"],
+ installable: true,
+ system_ext_specific: true,
+ }
+
+ dex_import {
+ name: "baz",
+ jars: ["a.jar"],
+ }
+
+ platform_bootclasspath {
+ name: "platform-bootclasspath",
+ }
+ `
+
+ result := android.GroupFixturePreparers(
+ 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")
+ rule := platformBootclasspath.Output(ruleFile)
+
+ for i := range expectedInputs {
+ expectedInputs[i] = filepath.Join("out/soong/dexpreopt_arm64", expectedInputs[i])
+ }
+
+ for i := range expectedOutputs {
+ expectedOutputs[i] = filepath.Join("out/soong/dexpreopt_arm64", expectedOutputs[i])
+ }
+
+ inputs := rule.Implicits.Strings()
+ sort.Strings(inputs)
+ sort.Strings(expectedInputs)
+
+ outputs := append(android.WritablePaths{rule.Output}, rule.ImplicitOutputs...).Strings()
+ sort.Strings(outputs)
+ sort.Strings(expectedOutputs)
+
+ android.AssertStringPathsRelativeToTopEquals(t, "inputs", result.Config, expectedInputs, inputs)
+
+ android.AssertStringPathsRelativeToTopEquals(t, "outputs", result.Config, expectedOutputs, outputs)
+}
+
+func TestDexpreoptBootJars(t *testing.T) {
+ ruleFile := "boot-foo.art"
+
+ expectedInputs := []string{
+ "dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.art",
+ "dex_bootjars_input/foo.jar",
+ "dex_bootjars_input/bar.jar",
+ "dex_bootjars_input/baz.jar",
+ }
+
+ expectedOutputs := []string{
+ "dex_bootjars/android/system/framework/arm64/boot.invocation",
+ "dex_bootjars/android/system/framework/arm64/boot-foo.art",
+ "dex_bootjars/android/system/framework/arm64/boot-bar.art",
+ "dex_bootjars/android/system/framework/arm64/boot-baz.art",
+ "dex_bootjars/android/system/framework/arm64/boot-foo.oat",
+ "dex_bootjars/android/system/framework/arm64/boot-bar.oat",
+ "dex_bootjars/android/system/framework/arm64/boot-baz.oat",
+ "dex_bootjars/android/system/framework/arm64/boot-foo.vdex",
+ "dex_bootjars/android/system/framework/arm64/boot-bar.vdex",
+ "dex_bootjars/android/system/framework/arm64/boot-baz.vdex",
+ "dex_bootjars_unstripped/android/system/framework/arm64/boot-foo.oat",
+ "dex_bootjars_unstripped/android/system/framework/arm64/boot-bar.oat",
+ "dex_bootjars_unstripped/android/system/framework/arm64/boot-baz.oat",
+ }
+
+ testDexpreoptBoot(t, ruleFile, expectedInputs, expectedOutputs)
+}
+
+// Changes to the boot.zip structure may break the ART APK scanner.
+func TestDexpreoptBootZip(t *testing.T) {
+ ruleFile := "boot.zip"
+
+ ctx := android.PathContextForTesting(android.TestArchConfig("", nil, "", nil))
+ expectedInputs := []string{}
+ for _, target := range ctx.Config().Targets[android.Android] {
+ for _, ext := range []string{".art", ".oat", ".vdex"} {
+ for _, jar := range []string{"foo", "bar", "baz"} {
+ expectedInputs = append(expectedInputs,
+ filepath.Join("dex_bootjars", target.Os.String(), "system/framework", target.Arch.ArchType.String(), "boot-"+jar+ext))
+ }
+ }
+ }
+
+ expectedOutputs := []string{
+ "dex_bootjars/boot.zip",
+ }
+
+ testDexpreoptBoot(t, ruleFile, expectedInputs, expectedOutputs)
+}
diff --git a/apex/metadata_test.go b/apex/metadata_test.go
index f6ead42..fed5bea 100644
--- a/apex/metadata_test.go
+++ b/apex/metadata_test.go
@@ -27,7 +27,7 @@
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 4b48da8..05bb136 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -20,6 +20,7 @@
"testing"
"android/soong/android"
+ "android/soong/dexpreopt"
"android/soong/java"
"github.com/google/blueprint"
@@ -30,7 +31,7 @@
// apexes.
var prepareForTestWithPlatformBootclasspath = android.GroupFixturePreparers(
- java.PrepareForTestWithDexpreopt,
+ java.PrepareForTestWithJavaDefaultModules,
PrepareForTestWithApexBuildComponents,
)
@@ -249,6 +250,8 @@
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 @@
// 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",