2021-01-20 16:16:56 +01:00
|
|
|
// Copyright (C) 2021 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// 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 (
|
2022-07-27 18:27:42 +02:00
|
|
|
"strings"
|
2021-01-20 16:16:56 +01:00
|
|
|
"testing"
|
2021-03-24 00:13:53 +01:00
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/dexpreopt"
|
2021-01-20 16:16:56 +01:00
|
|
|
)
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
// Contains some simple tests for bootclasspath_fragment logic, additional tests can be found in
|
|
|
|
// apex/bootclasspath_fragment_test.go as the ART boot image requires modules from the ART apex.
|
2021-01-20 16:16:56 +01:00
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers(
|
2021-03-24 00:13:53 +01:00
|
|
|
PrepareForTestWithJavaDefaultModules,
|
|
|
|
dexpreopt.PrepareForTestByEnablingDexpreopt,
|
|
|
|
)
|
|
|
|
|
2021-05-21 20:28:09 +02:00
|
|
|
func TestBootclasspathFragment_UnknownImageName(t *testing.T) {
|
2021-04-23 15:25:28 +02:00
|
|
|
prepareForTestWithBootclasspathFragment.
|
2021-03-24 00:13:53 +01:00
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
2021-05-21 20:28:09 +02:00
|
|
|
`\Qimage_name: unknown image name "unknown", expected "art"\E`)).
|
2021-03-24 00:13:53 +01:00
|
|
|
RunTestWithBp(t, `
|
2021-04-23 15:25:28 +02:00
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "unknown-bootclasspath-fragment",
|
2021-03-24 00:13:53 +01:00
|
|
|
image_name: "unknown",
|
2021-05-21 20:28:09 +02:00
|
|
|
contents: ["foo"],
|
2021-03-24 00:13:53 +01:00
|
|
|
}
|
|
|
|
`)
|
2021-01-20 16:16:56 +01:00
|
|
|
}
|
2021-03-10 16:00:46 +01:00
|
|
|
|
2021-05-21 20:28:09 +02:00
|
|
|
func TestPrebuiltBootclasspathFragment_UnknownImageName(t *testing.T) {
|
2021-04-23 15:25:28 +02:00
|
|
|
prepareForTestWithBootclasspathFragment.
|
2021-03-29 12:02:53 +02:00
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
2021-05-21 20:28:09 +02:00
|
|
|
`\Qimage_name: unknown image name "unknown", expected "art"\E`)).
|
2021-03-24 00:13:53 +01:00
|
|
|
RunTestWithBp(t, `
|
2021-04-23 15:25:28 +02:00
|
|
|
prebuilt_bootclasspath_fragment {
|
|
|
|
name: "unknown-bootclasspath-fragment",
|
2021-03-24 00:13:53 +01:00
|
|
|
image_name: "unknown",
|
2021-05-21 20:28:09 +02:00
|
|
|
contents: ["foo"],
|
2021-03-24 00:13:53 +01:00
|
|
|
}
|
|
|
|
`)
|
2021-03-10 16:00:46 +01:00
|
|
|
}
|
2021-03-24 00:21:59 +01:00
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func TestBootclasspathFragmentInconsistentArtConfiguration_Platform(t *testing.T) {
|
2021-03-24 00:21:59 +01:00
|
|
|
android.GroupFixturePreparers(
|
2021-04-23 15:25:28 +02:00
|
|
|
prepareForTestWithBootclasspathFragment,
|
2021-03-24 00:21:59 +01:00
|
|
|
dexpreopt.FixtureSetArtBootJars("platform:foo", "apex:bar"),
|
|
|
|
).
|
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
|
|
|
`\QArtApexJars is invalid as it requests a platform variant of "foo"\E`)).
|
|
|
|
RunTestWithBp(t, `
|
2021-04-23 15:25:28 +02:00
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "bootclasspath-fragment",
|
2021-03-24 00:21:59 +01:00
|
|
|
image_name: "art",
|
2021-05-21 20:28:09 +02:00
|
|
|
contents: ["foo", "bar"],
|
2021-03-24 00:21:59 +01:00
|
|
|
apex_available: [
|
|
|
|
"apex",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2021-04-23 15:25:28 +02:00
|
|
|
func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testing.T) {
|
2021-03-24 00:21:59 +01:00
|
|
|
android.GroupFixturePreparers(
|
2021-04-23 15:25:28 +02:00
|
|
|
prepareForTestWithBootclasspathFragment,
|
2021-03-24 00:21:59 +01:00
|
|
|
dexpreopt.FixtureSetArtBootJars("apex1:foo", "apex2:bar"),
|
|
|
|
).
|
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
|
|
|
`\QArtApexJars configuration is inconsistent, expected all jars to be in the same apex but it specifies apex "apex1" and "apex2"\E`)).
|
|
|
|
RunTestWithBp(t, `
|
2021-04-23 15:25:28 +02:00
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "bootclasspath-fragment",
|
2021-03-24 00:21:59 +01:00
|
|
|
image_name: "art",
|
2021-05-21 20:28:09 +02:00
|
|
|
contents: ["foo", "bar"],
|
2021-03-24 00:21:59 +01:00
|
|
|
apex_available: [
|
|
|
|
"apex1",
|
|
|
|
"apex2",
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
2021-03-24 02:34:57 +01:00
|
|
|
|
2021-04-23 14:55:49 +02:00
|
|
|
func TestBootclasspathFragment_Coverage(t *testing.T) {
|
|
|
|
prepareWithBp := android.FixtureWithRootAndroidBp(`
|
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "myfragment",
|
|
|
|
contents: [
|
|
|
|
"mybootlib",
|
|
|
|
],
|
2021-04-25 14:40:15 +02:00
|
|
|
api: {
|
|
|
|
stub_libs: [
|
|
|
|
"mysdklibrary",
|
|
|
|
],
|
|
|
|
},
|
2021-04-23 14:55:49 +02:00
|
|
|
coverage: {
|
|
|
|
contents: [
|
|
|
|
"coveragelib",
|
|
|
|
],
|
2021-04-25 14:40:15 +02:00
|
|
|
api: {
|
|
|
|
stub_libs: [
|
|
|
|
"mycoveragestubs",
|
|
|
|
],
|
|
|
|
},
|
2021-04-23 14:55:49 +02:00
|
|
|
},
|
2022-03-31 16:42:30 +02:00
|
|
|
hidden_api: {
|
|
|
|
split_packages: ["*"],
|
|
|
|
},
|
2021-04-23 14:55:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "mybootlib",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "coveragelib",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
2021-04-25 14:40:15 +02:00
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
compile_dex: true,
|
|
|
|
public: {enabled: true},
|
|
|
|
system: {enabled: true},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mycoveragestubs",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
compile_dex: true,
|
|
|
|
public: {enabled: true},
|
|
|
|
}
|
2021-04-23 14:55:49 +02:00
|
|
|
`)
|
|
|
|
|
|
|
|
checkContents := func(t *testing.T, result *android.TestResult, expected ...string) {
|
|
|
|
module := result.Module("myfragment", "android_common").(*BootclasspathFragmentModule)
|
|
|
|
android.AssertArrayString(t, "contents property", expected, module.properties.Contents)
|
|
|
|
}
|
|
|
|
|
2021-04-25 14:40:15 +02:00
|
|
|
preparer := android.GroupFixturePreparers(
|
|
|
|
prepareForTestWithBootclasspathFragment,
|
|
|
|
PrepareForTestWithJavaSdkLibraryFiles,
|
|
|
|
FixtureWithLastReleaseApis("mysdklibrary", "mycoveragestubs"),
|
2021-08-06 18:49:46 +02:00
|
|
|
FixtureConfigureApexBootJars("someapex:mybootlib"),
|
2021-04-25 14:40:15 +02:00
|
|
|
prepareWithBp,
|
|
|
|
)
|
|
|
|
|
2021-04-23 14:55:49 +02:00
|
|
|
t.Run("without coverage", func(t *testing.T) {
|
2021-04-25 14:40:15 +02:00
|
|
|
result := preparer.RunTest(t)
|
2021-04-23 14:55:49 +02:00
|
|
|
checkContents(t, result, "mybootlib")
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("with coverage", func(t *testing.T) {
|
|
|
|
result := android.GroupFixturePreparers(
|
2022-09-07 18:07:07 +02:00
|
|
|
prepareForTestWithFrameworkJacocoInstrumentation,
|
2021-04-25 14:40:15 +02:00
|
|
|
preparer,
|
2021-04-23 14:55:49 +02:00
|
|
|
).RunTest(t)
|
|
|
|
checkContents(t, result, "mybootlib", "coveragelib")
|
|
|
|
})
|
|
|
|
}
|
2021-04-25 11:13:54 +02:00
|
|
|
|
|
|
|
func TestBootclasspathFragment_StubLibs(t *testing.T) {
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForTestWithBootclasspathFragment,
|
|
|
|
PrepareForTestWithJavaSdkLibraryFiles,
|
2021-05-13 22:25:05 +02:00
|
|
|
FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"),
|
2021-08-06 18:49:46 +02:00
|
|
|
FixtureConfigureApexBootJars("someapex:mysdklibrary"),
|
2021-04-25 11:13:54 +02:00
|
|
|
).RunTestWithBp(t, `
|
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "myfragment",
|
|
|
|
contents: ["mysdklibrary"],
|
|
|
|
api: {
|
|
|
|
stub_libs: [
|
|
|
|
"mystublib",
|
2021-05-13 22:25:05 +02:00
|
|
|
"myothersdklibrary",
|
2021-04-25 11:13:54 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
core_platform_api: {
|
2021-06-30 19:25:36 +02:00
|
|
|
stub_libs: ["mycoreplatform.stubs"],
|
2021-04-25 11:13:54 +02:00
|
|
|
},
|
2022-03-31 16:42:30 +02:00
|
|
|
hidden_api: {
|
|
|
|
split_packages: ["*"],
|
|
|
|
},
|
2021-04-25 11:13:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "mystublib",
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
compile_dex: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
srcs: ["a.java"],
|
2021-05-13 23:34:45 +02:00
|
|
|
shared_library: false,
|
2021-04-25 11:13:54 +02:00
|
|
|
public: {enabled: true},
|
|
|
|
system: {enabled: true},
|
|
|
|
}
|
|
|
|
|
2021-05-13 22:25:05 +02:00
|
|
|
java_sdk_library {
|
|
|
|
name: "myothersdklibrary",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
shared_library: false,
|
|
|
|
public: {enabled: true},
|
|
|
|
}
|
|
|
|
|
2021-04-25 11:13:54 +02:00
|
|
|
java_sdk_library {
|
|
|
|
name: "mycoreplatform",
|
|
|
|
srcs: ["a.java"],
|
2021-05-13 23:34:45 +02:00
|
|
|
shared_library: false,
|
2021-04-25 11:13:54 +02:00
|
|
|
public: {enabled: true},
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
fragment := result.Module("myfragment", "android_common")
|
2021-05-21 23:46:59 +02:00
|
|
|
info := result.ModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
|
2021-04-25 11:13:54 +02:00
|
|
|
|
|
|
|
stubsJar := "out/soong/.intermediates/mystublib/android_common/dex/mystublib.jar"
|
|
|
|
|
2021-05-13 22:25:05 +02:00
|
|
|
// Stubs jars for mysdklibrary
|
2021-04-25 11:13:54 +02:00
|
|
|
publicStubsJar := "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar"
|
|
|
|
systemStubsJar := "out/soong/.intermediates/mysdklibrary.stubs.system/android_common/dex/mysdklibrary.stubs.system.jar"
|
|
|
|
|
2021-05-13 22:25:05 +02:00
|
|
|
// Stubs jars for myothersdklibrary
|
|
|
|
otherPublicStubsJar := "out/soong/.intermediates/myothersdklibrary.stubs/android_common/dex/myothersdklibrary.stubs.jar"
|
|
|
|
|
|
|
|
// Check that SdkPublic uses public stubs for all sdk libraries.
|
2021-06-27 21:28:29 +02:00
|
|
|
android.AssertPathsRelativeToTopEquals(t, "public dex stubs jar", []string{otherPublicStubsJar, publicStubsJar, stubsJar}, info.TransitiveStubDexJarsByScope.StubDexJarsForScope(PublicHiddenAPIScope))
|
2021-05-13 22:25:05 +02:00
|
|
|
|
|
|
|
// Check that SdkSystem uses system stubs for mysdklibrary and public stubs for myothersdklibrary
|
|
|
|
// as it does not provide system stubs.
|
2021-06-27 21:28:29 +02:00
|
|
|
android.AssertPathsRelativeToTopEquals(t, "system dex stubs jar", []string{otherPublicStubsJar, systemStubsJar, stubsJar}, info.TransitiveStubDexJarsByScope.StubDexJarsForScope(SystemHiddenAPIScope))
|
2021-05-13 22:25:05 +02:00
|
|
|
|
|
|
|
// Check that SdkTest also uses system stubs for mysdklibrary as it does not provide test stubs
|
|
|
|
// and public stubs for myothersdklibrary as it does not provide test stubs either.
|
2021-06-27 21:28:29 +02:00
|
|
|
android.AssertPathsRelativeToTopEquals(t, "test dex stubs jar", []string{otherPublicStubsJar, systemStubsJar, stubsJar}, info.TransitiveStubDexJarsByScope.StubDexJarsForScope(TestHiddenAPIScope))
|
2021-04-25 11:13:54 +02:00
|
|
|
|
|
|
|
// Check that SdkCorePlatform uses public stubs from the mycoreplatform library.
|
|
|
|
corePlatformStubsJar := "out/soong/.intermediates/mycoreplatform.stubs/android_common/dex/mycoreplatform.stubs.jar"
|
2021-06-27 21:28:29 +02:00
|
|
|
android.AssertPathsRelativeToTopEquals(t, "core platform dex stubs jar", []string{corePlatformStubsJar}, info.TransitiveStubDexJarsByScope.StubDexJarsForScope(CorePlatformHiddenAPIScope))
|
2021-06-27 21:53:39 +02:00
|
|
|
|
2021-06-27 21:28:29 +02:00
|
|
|
// Check the widest stubs.. The list contains the widest stub dex jar provided by each module.
|
|
|
|
expectedWidestPaths := []string{
|
|
|
|
// mycoreplatform's widest API is core platform.
|
|
|
|
corePlatformStubsJar,
|
|
|
|
|
|
|
|
// myothersdklibrary's widest API is public.
|
|
|
|
otherPublicStubsJar,
|
|
|
|
|
|
|
|
// sdklibrary's widest API is system.
|
|
|
|
systemStubsJar,
|
|
|
|
|
|
|
|
// mystublib's only provides one API and so it must be the widest.
|
|
|
|
stubsJar,
|
|
|
|
}
|
|
|
|
|
|
|
|
android.AssertPathsRelativeToTopEquals(t, "widest dex stubs jar", expectedWidestPaths, info.TransitiveStubDexJarsByScope.StubDexJarsForWidestAPIScope())
|
2021-04-25 11:13:54 +02:00
|
|
|
}
|
2022-03-31 16:42:30 +02:00
|
|
|
|
2022-07-27 18:27:42 +02:00
|
|
|
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForTestWithBootclasspathFragment,
|
|
|
|
PrepareForTestWithJavaSdkLibraryFiles,
|
|
|
|
FixtureWithLastReleaseApis("mysdklibrary", "mynewlibrary"),
|
|
|
|
FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:mynewlibrary"),
|
|
|
|
android.MockFS{
|
|
|
|
"my-blocked.txt": nil,
|
|
|
|
"my-max-target-o-low-priority.txt": nil,
|
|
|
|
"my-max-target-p.txt": nil,
|
|
|
|
"my-max-target-q.txt": nil,
|
|
|
|
"my-max-target-r-low-priority.txt": nil,
|
|
|
|
"my-removed.txt": nil,
|
|
|
|
"my-unsupported-packages.txt": nil,
|
|
|
|
"my-unsupported.txt": nil,
|
|
|
|
"my-new-max-target-q.txt": nil,
|
|
|
|
}.AddToFixture(),
|
|
|
|
android.FixtureWithRootAndroidBp(`
|
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "mybootclasspathfragment",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
contents: ["mybootlib", "mynewlibrary"],
|
|
|
|
hidden_api: {
|
|
|
|
unsupported: [
|
|
|
|
"my-unsupported.txt",
|
|
|
|
],
|
|
|
|
removed: [
|
|
|
|
"my-removed.txt",
|
|
|
|
],
|
|
|
|
max_target_r_low_priority: [
|
|
|
|
"my-max-target-r-low-priority.txt",
|
|
|
|
],
|
|
|
|
max_target_q: [
|
|
|
|
"my-max-target-q.txt",
|
|
|
|
],
|
|
|
|
max_target_p: [
|
|
|
|
"my-max-target-p.txt",
|
|
|
|
],
|
|
|
|
max_target_o_low_priority: [
|
|
|
|
"my-max-target-o-low-priority.txt",
|
|
|
|
],
|
|
|
|
blocked: [
|
|
|
|
"my-blocked.txt",
|
|
|
|
],
|
|
|
|
unsupported_packages: [
|
|
|
|
"my-unsupported-packages.txt",
|
|
|
|
],
|
|
|
|
split_packages: ["sdklibrary"],
|
|
|
|
package_prefixes: ["sdklibrary.all.mine"],
|
|
|
|
single_packages: ["sdklibrary.mine"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
java_library {
|
|
|
|
name: "mybootlib",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
system_modules: "none",
|
|
|
|
sdk_version: "none",
|
|
|
|
min_sdk_version: "1",
|
|
|
|
compile_dex: true,
|
|
|
|
permitted_packages: ["mybootlib"],
|
|
|
|
}
|
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mynewlibrary",
|
|
|
|
apex_available: ["myapex"],
|
|
|
|
srcs: ["Test.java"],
|
|
|
|
min_sdk_version: "10",
|
|
|
|
compile_dex: true,
|
|
|
|
public: {enabled: true},
|
|
|
|
permitted_packages: ["mysdklibrary"],
|
|
|
|
hidden_api: {
|
|
|
|
max_target_q: [
|
|
|
|
"my-new-max-target-q.txt",
|
|
|
|
],
|
|
|
|
split_packages: ["sdklibrary", "newlibrary"],
|
|
|
|
package_prefixes: ["newlibrary.all.mine"],
|
|
|
|
single_packages: ["newlibrary.mine"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`),
|
|
|
|
).RunTest(t)
|
|
|
|
|
|
|
|
// Make sure that the library exports hidden API properties for use by the bootclasspath_fragment.
|
|
|
|
library := result.Module("mynewlibrary", "android_common")
|
|
|
|
info := result.ModuleProvider(library, hiddenAPIPropertyInfoProvider).(HiddenAPIPropertyInfo)
|
|
|
|
android.AssertArrayString(t, "split packages", []string{"sdklibrary", "newlibrary"}, info.SplitPackages)
|
|
|
|
android.AssertArrayString(t, "package prefixes", []string{"newlibrary.all.mine"}, info.PackagePrefixes)
|
|
|
|
android.AssertArrayString(t, "single packages", []string{"newlibrary.mine"}, info.SinglePackages)
|
|
|
|
for _, c := range HiddenAPIFlagFileCategories {
|
|
|
|
expectedMaxTargetQPaths := []string(nil)
|
|
|
|
if c.PropertyName == "max_target_q" {
|
|
|
|
expectedMaxTargetQPaths = []string{"my-new-max-target-q.txt"}
|
|
|
|
}
|
|
|
|
android.AssertPathsRelativeToTopEquals(t, c.PropertyName, expectedMaxTargetQPaths, info.FlagFilesByCategory[c])
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that the signature-patterns.csv is passed all the appropriate package properties
|
|
|
|
// from the bootclasspath_fragment and its contents.
|
|
|
|
fragment := result.ModuleForTests("mybootclasspathfragment", "android_common")
|
|
|
|
rule := fragment.Output("modular-hiddenapi/signature-patterns.csv")
|
|
|
|
expectedCommand := strings.Join([]string{
|
|
|
|
"--split-package newlibrary",
|
|
|
|
"--split-package sdklibrary",
|
|
|
|
"--package-prefix newlibrary.all.mine",
|
|
|
|
"--package-prefix sdklibrary.all.mine",
|
|
|
|
"--single-package newlibrary.mine",
|
|
|
|
"--single-package sdklibrary",
|
|
|
|
}, " ")
|
|
|
|
android.AssertStringDoesContain(t, "signature patterns command", rule.RuleParams.Command, expectedCommand)
|
|
|
|
}
|
|
|
|
|
2022-03-31 16:42:30 +02:00
|
|
|
func TestBootclasspathFragment_Test(t *testing.T) {
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForTestWithBootclasspathFragment,
|
|
|
|
PrepareForTestWithJavaSdkLibraryFiles,
|
|
|
|
FixtureWithLastReleaseApis("mysdklibrary"),
|
|
|
|
).RunTestWithBp(t, `
|
|
|
|
bootclasspath_fragment {
|
|
|
|
name: "myfragment",
|
|
|
|
contents: ["mysdklibrary"],
|
|
|
|
hidden_api: {
|
|
|
|
split_packages: [],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
bootclasspath_fragment_test {
|
|
|
|
name: "a_test_fragment",
|
|
|
|
contents: ["mysdklibrary"],
|
|
|
|
hidden_api: {
|
|
|
|
split_packages: [],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
java_sdk_library {
|
|
|
|
name: "mysdklibrary",
|
|
|
|
srcs: ["a.java"],
|
|
|
|
shared_library: false,
|
|
|
|
public: {enabled: true},
|
|
|
|
system: {enabled: true},
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
fragment := result.Module("myfragment", "android_common").(*BootclasspathFragmentModule)
|
|
|
|
android.AssertBoolEquals(t, "not a test fragment", false, fragment.isTestFragment())
|
|
|
|
|
|
|
|
fragment = result.Module("a_test_fragment", "android_common").(*BootclasspathFragmentModule)
|
|
|
|
android.AssertBoolEquals(t, "is a test fragment by type", true, fragment.isTestFragment())
|
|
|
|
}
|