Add some verification on test_suite for test_module_config
During some migration, I created some modules where the derived module and base module were in different suites (one was in general-tests, one was in base-tests). This had the potential to create dangling symlinks for partial downloads from the test suites in tradefed. Bug: b/357880359 Test: go test ./ Test: m nothing Test: modified a Android.bp with test_module_config to change the suite to "device-tests" from "general-tests" and got the error as expected: error: cts/tests/libcore/luni/Android.bp:70:1: module "CtsLibcoreTestCases_dalvik_system" variant "android_common": Suite: [device-tests] listed but does not exist in base module: CtsLibcoreTestCases Change-Id: Ia8fa991914a47336fc2d0148f066824433db2ecd
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
@@ -174,6 +175,20 @@ func (m *testModuleConfigModule) validateTestSuites(ctx android.ModuleContext) b
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var extra_derived_suites []string
|
||||||
|
// Ensure all suites listed are also in base.
|
||||||
|
for _, s := range m.tradefedProperties.Test_suites {
|
||||||
|
if !slices.Contains(m.provider.TestSuites, s) {
|
||||||
|
extra_derived_suites = append(extra_derived_suites, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(extra_derived_suites) != 0 {
|
||||||
|
ctx.ModuleErrorf("Suites: [%s] listed but do not exist in base module: %s",
|
||||||
|
strings.Join(extra_derived_suites, ", "),
|
||||||
|
*m.tradefedProperties.Base)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,7 @@ const bp = `
|
|||||||
name: "base",
|
name: "base",
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
data: [":HelperApp", "data/testfile"],
|
data: [":HelperApp", "data/testfile"],
|
||||||
|
test_suites: ["general-tests"],
|
||||||
}
|
}
|
||||||
|
|
||||||
test_module_config {
|
test_module_config {
|
||||||
@@ -160,7 +161,7 @@ func TestModuleConfigBadBaseShouldFailWithGeneralMessage(t *testing.T) {
|
|||||||
java.PrepareForTestWithJavaDefaultModules,
|
java.PrepareForTestWithJavaDefaultModules,
|
||||||
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
|
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
|
||||||
).ExtendWithErrorHandler(
|
).ExtendWithErrorHandler(
|
||||||
android.FixtureExpectsOneErrorPattern("'base' module used as base but it is not a 'android_test' module.")).
|
android.FixtureExpectsAtLeastOneErrorMatchingPattern("'base' module used as base but it is not a 'android_test' module.")).
|
||||||
RunTestWithBp(t, badBp)
|
RunTestWithBp(t, badBp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +194,7 @@ func TestModuleConfigNoFiltersOrAnnotationsShouldFail(t *testing.T) {
|
|||||||
name: "base",
|
name: "base",
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
|
test_suites: ["general-tests"],
|
||||||
}
|
}
|
||||||
|
|
||||||
test_module_config {
|
test_module_config {
|
||||||
@@ -218,6 +220,7 @@ func TestModuleConfigMultipleDerivedTestsWriteDistinctMakeEntries(t *testing.T)
|
|||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
data: [":HelperApp", "data/testfile"],
|
data: [":HelperApp", "data/testfile"],
|
||||||
|
test_suites: ["general-tests"],
|
||||||
}
|
}
|
||||||
|
|
||||||
android_test_helper_app {
|
android_test_helper_app {
|
||||||
@@ -362,6 +365,31 @@ func TestModuleConfigHostNeedsATestSuite(t *testing.T) {
|
|||||||
RunTestWithBp(t, badBp)
|
RunTestWithBp(t, badBp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestModuleConfigNonMatchingTestSuitesGiveErrors(t *testing.T) {
|
||||||
|
badBp := `
|
||||||
|
java_test_host {
|
||||||
|
name: "base",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
test_suites: ["general-tests", "some-compat"],
|
||||||
|
}
|
||||||
|
|
||||||
|
test_module_config_host {
|
||||||
|
name: "derived_test",
|
||||||
|
base: "base",
|
||||||
|
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
|
||||||
|
include_annotations: ["android.platform.test.annotations.LargeTest"],
|
||||||
|
test_suites: ["device-tests", "random-suite"],
|
||||||
|
}`
|
||||||
|
|
||||||
|
android.GroupFixturePreparers(
|
||||||
|
java.PrepareForTestWithJavaDefaultModules,
|
||||||
|
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
|
||||||
|
).ExtendWithErrorHandler(
|
||||||
|
// Use \\ to escape bracket so it isn't used as [] set for regex.
|
||||||
|
android.FixtureExpectsAtLeastOneErrorMatchingPattern("Suites: \\[device-tests, random-suite] listed but do not exist in base module")).
|
||||||
|
RunTestWithBp(t, badBp)
|
||||||
|
}
|
||||||
|
|
||||||
func TestTestOnlyProvider(t *testing.T) {
|
func TestTestOnlyProvider(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := android.GroupFixturePreparers(
|
ctx := android.GroupFixturePreparers(
|
||||||
@@ -389,6 +417,7 @@ func TestTestOnlyProvider(t *testing.T) {
|
|||||||
name: "base",
|
name: "base",
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
data: ["data/testfile"],
|
data: ["data/testfile"],
|
||||||
|
test_suites: ["general-tests"],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_test_host {
|
java_test_host {
|
||||||
|
Reference in New Issue
Block a user