Make TestJavaSdkLibraryEnforce faster
TestJavaSdkLibraryEnforce is too slow because it tests all combinations of options. Change TestJavaSdkLibraryEnforce to run test on specific test cases, not all combinations. Bug: 177323052 Test: go test -timeout 10s -run ^TestJavaSdkLibraryEnforce$ android/soong/java Change-Id: Ie7fe4e22b570a3e25259a6ad4bd37936805c6604
This commit is contained in:
@@ -867,83 +867,43 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
isValidDependency := func(configInfo testConfigInfo) bool {
|
|
||||||
if configInfo.enforceVendorInterface == false {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if configInfo.enforceJavaSdkLibraryCheck == false {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if inList("bar", configInfo.allowList) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if configInfo.libraryType == "java_library" {
|
|
||||||
if configInfo.fromPartition != configInfo.toPartition {
|
|
||||||
if !configInfo.enforceProductInterface &&
|
|
||||||
((configInfo.fromPartition == "system" && configInfo.toPartition == "product") ||
|
|
||||||
(configInfo.fromPartition == "product" && configInfo.toPartition == "system")) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
errorMessage := "is not allowed across the partitions"
|
errorMessage := "is not allowed across the partitions"
|
||||||
|
|
||||||
allPartitionCombinations := func() [][2]string {
|
testJavaWithConfig(t, createTestConfig(testConfigInfo{
|
||||||
var result [][2]string
|
libraryType: "java_library",
|
||||||
partitions := []string{"system", "vendor", "product"}
|
fromPartition: "product",
|
||||||
|
toPartition: "system",
|
||||||
|
enforceVendorInterface: true,
|
||||||
|
enforceProductInterface: true,
|
||||||
|
enforceJavaSdkLibraryCheck: false,
|
||||||
|
}))
|
||||||
|
|
||||||
for _, fromPartition := range partitions {
|
testJavaWithConfig(t, createTestConfig(testConfigInfo{
|
||||||
for _, toPartition := range partitions {
|
libraryType: "java_library",
|
||||||
result = append(result, [2]string{fromPartition, toPartition})
|
fromPartition: "product",
|
||||||
}
|
toPartition: "system",
|
||||||
}
|
enforceVendorInterface: true,
|
||||||
|
enforceProductInterface: false,
|
||||||
|
enforceJavaSdkLibraryCheck: true,
|
||||||
|
}))
|
||||||
|
|
||||||
return result
|
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{
|
||||||
}
|
libraryType: "java_library",
|
||||||
|
fromPartition: "product",
|
||||||
|
toPartition: "system",
|
||||||
|
enforceVendorInterface: true,
|
||||||
|
enforceProductInterface: true,
|
||||||
|
enforceJavaSdkLibraryCheck: true,
|
||||||
|
}))
|
||||||
|
|
||||||
allFlagCombinations := func() [][3]bool {
|
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{
|
||||||
var result [][3]bool
|
libraryType: "java_library",
|
||||||
flagValues := [2]bool{false, true}
|
fromPartition: "vendor",
|
||||||
|
toPartition: "system",
|
||||||
for _, vendorInterface := range flagValues {
|
enforceVendorInterface: true,
|
||||||
for _, productInterface := range flagValues {
|
enforceProductInterface: true,
|
||||||
for _, enableEnforce := range flagValues {
|
enforceJavaSdkLibraryCheck: true,
|
||||||
result = append(result, [3]bool{vendorInterface, productInterface, enableEnforce})
|
}))
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, libraryType := range []string{"java_library", "java_sdk_library"} {
|
|
||||||
for _, partitionValues := range allPartitionCombinations() {
|
|
||||||
for _, flagValues := range allFlagCombinations() {
|
|
||||||
testInfo := testConfigInfo{
|
|
||||||
libraryType: libraryType,
|
|
||||||
fromPartition: partitionValues[0],
|
|
||||||
toPartition: partitionValues[1],
|
|
||||||
enforceVendorInterface: flagValues[0],
|
|
||||||
enforceProductInterface: flagValues[1],
|
|
||||||
enforceJavaSdkLibraryCheck: flagValues[2],
|
|
||||||
}
|
|
||||||
|
|
||||||
if isValidDependency(testInfo) {
|
|
||||||
testJavaWithConfig(t, createTestConfig(testInfo))
|
|
||||||
} else {
|
|
||||||
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testInfo))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testJavaWithConfig(t, createTestConfig(testConfigInfo{
|
testJavaWithConfig(t, createTestConfig(testConfigInfo{
|
||||||
libraryType: "java_library",
|
libraryType: "java_library",
|
||||||
@@ -958,11 +918,37 @@ func TestJavaSdkLibraryEnforce(t *testing.T) {
|
|||||||
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{
|
testJavaErrorWithConfig(t, errorMessage, createTestConfig(testConfigInfo{
|
||||||
libraryType: "java_library",
|
libraryType: "java_library",
|
||||||
fromPartition: "vendor",
|
fromPartition: "vendor",
|
||||||
|
toPartition: "product",
|
||||||
|
enforceVendorInterface: true,
|
||||||
|
enforceProductInterface: true,
|
||||||
|
enforceJavaSdkLibraryCheck: true,
|
||||||
|
}))
|
||||||
|
|
||||||
|
testJavaWithConfig(t, createTestConfig(testConfigInfo{
|
||||||
|
libraryType: "java_sdk_library",
|
||||||
|
fromPartition: "product",
|
||||||
toPartition: "system",
|
toPartition: "system",
|
||||||
enforceVendorInterface: true,
|
enforceVendorInterface: true,
|
||||||
enforceProductInterface: true,
|
enforceProductInterface: true,
|
||||||
enforceJavaSdkLibraryCheck: true,
|
enforceJavaSdkLibraryCheck: true,
|
||||||
allowList: []string{"foo"},
|
}))
|
||||||
|
|
||||||
|
testJavaWithConfig(t, createTestConfig(testConfigInfo{
|
||||||
|
libraryType: "java_sdk_library",
|
||||||
|
fromPartition: "vendor",
|
||||||
|
toPartition: "system",
|
||||||
|
enforceVendorInterface: true,
|
||||||
|
enforceProductInterface: true,
|
||||||
|
enforceJavaSdkLibraryCheck: true,
|
||||||
|
}))
|
||||||
|
|
||||||
|
testJavaWithConfig(t, createTestConfig(testConfigInfo{
|
||||||
|
libraryType: "java_sdk_library",
|
||||||
|
fromPartition: "vendor",
|
||||||
|
toPartition: "product",
|
||||||
|
enforceVendorInterface: true,
|
||||||
|
enforceProductInterface: true,
|
||||||
|
enforceJavaSdkLibraryCheck: true,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user