diff options
author | Colin Cross <ccross@android.com> | 2019-03-04 19:40:21 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-03-04 19:40:21 -0800 |
commit | 1885ec2b7934f054a930d26d1ef9479ba9b27e67 (patch) | |
tree | e2672a4a66dfcdda4e2d9e6abe28b797b3fa5a2d /java | |
parent | 33db6a29cce03315fba7ea66d486875af7456462 (diff) | |
parent | 15836b9ceb6186863e4ffe33bd9cfa18dbf6b50a (diff) | |
download | android_build_soong-1885ec2b7934f054a930d26d1ef9479ba9b27e67.tar.gz android_build_soong-1885ec2b7934f054a930d26d1ef9479ba9b27e67.tar.bz2 android_build_soong-1885ec2b7934f054a930d26d1ef9479ba9b27e67.zip |
Add dexpreopt_bootjars_test.go am: 762286723a am: 2c81ab734f
am: 15836b9ceb
Change-Id: I4d047c47d783f6e788eeccdf83dab646338d15d8
Diffstat (limited to 'java')
-rw-r--r-- | java/dexpreopt_bootjars_test.go | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go new file mode 100644 index 00000000..c99540da --- /dev/null +++ b/java/dexpreopt_bootjars_test.go @@ -0,0 +1,103 @@ +// 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" + "reflect" + "sort" + "testing" + + "android/soong/android" + "android/soong/dexpreopt" +) + +func TestDexpreoptBootJars(t *testing.T) { + bp := ` + java_sdk_library { + name: "foo", + srcs: ["a.java"], + api_packages: ["foo"], + } + + java_library { + name: "bar", + srcs: ["b.java"], + installable: true, + } + ` + + config := testConfig(nil) + + pathCtx := android.PathContextForTesting(config, nil) + dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx) + dexpreoptConfig.RuntimeApexJars = []string{"foo", "bar"} + setDexpreoptTestGlobalConfig(config, dexpreoptConfig) + + ctx := testContext(config, bp, nil) + + ctx.RegisterSingletonType("dex_bootjars", android.SingletonFactoryAdaptor(dexpreoptBootJarsFactory)) + + run(t, ctx, config) + + dexpreoptBootJars := ctx.SingletonForTests("dex_bootjars") + + bootArt := dexpreoptBootJars.Output("boot.art") + + expectedInputs := []string{ + "dex_bootjars_input/foo.jar", + "dex_bootjars_input/bar.jar", + } + + for i := range expectedInputs { + expectedInputs[i] = filepath.Join(buildDir, "test_device", expectedInputs[i]) + } + + inputs := bootArt.Implicits.Strings() + sort.Strings(inputs) + sort.Strings(expectedInputs) + + if !reflect.DeepEqual(inputs, expectedInputs) { + t.Errorf("want inputs %q\n got inputs %q", expectedInputs, inputs) + } + + expectedOutputs := []string{ + "dex_bootjars/system/framework/arm64/boot.invocation", + + "dex_bootjars/system/framework/arm64/boot.art", + "dex_bootjars/system/framework/arm64/boot-bar.art", + + "dex_bootjars/system/framework/arm64/boot.oat", + "dex_bootjars/system/framework/arm64/boot-bar.oat", + + "dex_bootjars/system/framework/arm64/boot.vdex", + "dex_bootjars/system/framework/arm64/boot-bar.vdex", + + "dex_bootjars_unstripped/system/framework/arm64/boot.oat", + "dex_bootjars_unstripped/system/framework/arm64/boot-bar.oat", + } + + for i := range expectedOutputs { + expectedOutputs[i] = filepath.Join(buildDir, "test_device", expectedOutputs[i]) + } + + outputs := bootArt.Outputs.Strings() + sort.Strings(outputs) + sort.Strings(expectedOutputs) + + if !reflect.DeepEqual(outputs, expectedOutputs) { + t.Errorf("want outputs %q\n got outputs %q", expectedOutputs, outputs) + } +} |