Perform validation of shared library attributes
Perform consistency checks as per http://go/updatable-shared-libraries
These include:
* no attribute can specified can be less than T
* max-device-sdk can't be less than min-device-sdk
* min and max-device-sdk need to be at least the module's
min_sdk_version
* using on-bootclasspath-before implies that the module's
min_sdk_version is at least T or the library has min-device-sdk of at
least T
Test: m nothing
Bug: 191978330
Change-Id: Iaca5cf23fb0bc7e65effb3529c8e829560894c2e
Merged-In: Iaca5cf23fb0bc7e65effb3529c8e829560894c2e
(cherry picked from commit f9e584dd20
)
This commit is contained in:
@@ -15,12 +15,13 @@
|
||||
package java
|
||||
|
||||
import (
|
||||
"android/soong/android"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
@@ -171,16 +172,20 @@ func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
|
||||
"29": {"foo"},
|
||||
"30": {"foo", "fooUpdatable", "fooUpdatableErr"},
|
||||
}),
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.Platform_version_active_codenames = []string{"Tiramisu", "U", "V", "W"}
|
||||
}),
|
||||
).RunTestWithBp(t,
|
||||
`
|
||||
java_sdk_library {
|
||||
name: "fooUpdatable",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
on_bootclasspath_since: "29",
|
||||
on_bootclasspath_before: "30",
|
||||
min_device_sdk: "R",
|
||||
max_device_sdk: "current",
|
||||
on_bootclasspath_since: "U",
|
||||
on_bootclasspath_before: "V",
|
||||
min_device_sdk: "W",
|
||||
max_device_sdk: "current",
|
||||
min_sdk_version: "S",
|
||||
}
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
@@ -190,9 +195,9 @@ func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
|
||||
`)
|
||||
// test that updatability attributes are passed on correctly
|
||||
fooUpdatable := result.ModuleForTests("fooUpdatable.xml", "android_common").Rule("java_sdk_xml")
|
||||
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_since=\"29\"`)
|
||||
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_before=\"30\"`)
|
||||
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min_device_sdk=\"30\"`)
|
||||
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_since=\"9001\"`)
|
||||
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_before=\"9002\"`)
|
||||
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min_device_sdk=\"9003\"`)
|
||||
android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `max_device_sdk=\"10000\"`)
|
||||
|
||||
// double check that updatability attributes are not written if they don't exist in the bp file
|
||||
@@ -204,7 +209,7 @@ func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
|
||||
android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `max_device_sdk`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_UpdatableLibrary_Validation(t *testing.T) {
|
||||
func TestJavaSdkLibrary_UpdatableLibrary_Validation_ValidVersion(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
prepareForJavaTest,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
@@ -223,14 +228,120 @@ func TestJavaSdkLibrary_UpdatableLibrary_Validation(t *testing.T) {
|
||||
name: "fooUpdatableErr",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
on_bootclasspath_since: "aaa",
|
||||
on_bootclasspath_before: "bbc",
|
||||
min_device_sdk: "ccc",
|
||||
max_device_sdk: "ddd",
|
||||
on_bootclasspath_since: "aaa",
|
||||
on_bootclasspath_before: "bbc",
|
||||
min_device_sdk: "ccc",
|
||||
max_device_sdk: "ddd",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_UpdatableLibrary_Validation_AtLeastTAttributes(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
prepareForJavaTest,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
FixtureWithPrebuiltApis(map[string][]string{
|
||||
"28": {"foo"},
|
||||
}),
|
||||
).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(
|
||||
[]string{
|
||||
"on_bootclasspath_since: Attribute value needs to be at least T",
|
||||
"on_bootclasspath_before: Attribute value needs to be at least T",
|
||||
"min_device_sdk: Attribute value needs to be at least T",
|
||||
"max_device_sdk: Attribute value needs to be at least T",
|
||||
},
|
||||
)).RunTestWithBp(t,
|
||||
`
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
on_bootclasspath_since: "S",
|
||||
on_bootclasspath_before: "S",
|
||||
min_device_sdk: "S",
|
||||
max_device_sdk: "S",
|
||||
min_sdk_version: "S",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_UpdatableLibrary_Validation_MinAndMaxDeviceSdk(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
prepareForJavaTest,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
FixtureWithPrebuiltApis(map[string][]string{
|
||||
"28": {"foo"},
|
||||
}),
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.Platform_version_active_codenames = []string{"Tiramisu", "U", "V"}
|
||||
}),
|
||||
).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(
|
||||
[]string{
|
||||
"min_device_sdk can't be greater than max_device_sdk",
|
||||
},
|
||||
)).RunTestWithBp(t,
|
||||
`
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
min_device_sdk: "V",
|
||||
max_device_sdk: "U",
|
||||
min_sdk_version: "S",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_UpdatableLibrary_Validation_MinAndMaxDeviceSdkAndModuleMinSdk(t *testing.T) {
|
||||
android.GroupFixturePreparers(
|
||||
prepareForJavaTest,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
FixtureWithPrebuiltApis(map[string][]string{
|
||||
"28": {"foo"},
|
||||
}),
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.Platform_version_active_codenames = []string{"Tiramisu", "U", "V"}
|
||||
}),
|
||||
).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(
|
||||
[]string{
|
||||
regexp.QuoteMeta("min_device_sdk: Can't be less than module's min sdk (V)"),
|
||||
regexp.QuoteMeta("max_device_sdk: Can't be less than module's min sdk (V)"),
|
||||
},
|
||||
)).RunTestWithBp(t,
|
||||
`
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
api_packages: ["foo"],
|
||||
min_device_sdk: "U",
|
||||
max_device_sdk: "U",
|
||||
min_sdk_version: "V",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_UpdatableLibrary_usesNewTag(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForJavaTest,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
FixtureWithPrebuiltApis(map[string][]string{
|
||||
"30": {"foo"},
|
||||
}),
|
||||
).RunTestWithBp(t,
|
||||
`
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.java"],
|
||||
min_device_sdk: "Tiramisu",
|
||||
min_sdk_version: "S",
|
||||
}
|
||||
`)
|
||||
// test that updatability attributes are passed on correctly
|
||||
fooUpdatable := result.ModuleForTests("foo.xml", "android_common").Rule("java_sdk_xml")
|
||||
android.AssertStringDoesContain(t, "foo.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `<updatable-library`)
|
||||
android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `<library`)
|
||||
}
|
||||
|
||||
func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForJavaTest,
|
||||
|
Reference in New Issue
Block a user