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:
@@ -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",
|
||||
|
@@ -1,130 +0,0 @@
|
||||
// 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 java
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
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(
|
||||
prepareForJavaTest,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
FixtureWithLastReleaseApis("foo"),
|
||||
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)
|
||||
}
|
@@ -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"),
|
||||
)
|
||||
|
@@ -39,7 +39,9 @@ var prepareForTestWithDefaultPlatformBootclasspath = android.FixtureAddTextFile(
|
||||
`)
|
||||
|
||||
var hiddenApiFixtureFactory = android.GroupFixturePreparers(
|
||||
prepareForJavaTest, PrepareForTestWithHiddenApiBuildComponents)
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithHiddenApiBuildComponents,
|
||||
)
|
||||
|
||||
func TestHiddenAPISingleton(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
|
@@ -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) {
|
||||
|
@@ -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) {
|
||||
|
@@ -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,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user