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:
Ronald Braunstein
2024-08-07 13:03:05 -07:00
parent d6358b6a9b
commit a186ac04bb
2 changed files with 45 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ const bp = `
name: "base",
sdk_version: "current",
data: [":HelperApp", "data/testfile"],
test_suites: ["general-tests"],
}
test_module_config {
@@ -160,7 +161,7 @@ func TestModuleConfigBadBaseShouldFailWithGeneralMessage(t *testing.T) {
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).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)
}
@@ -193,6 +194,7 @@ func TestModuleConfigNoFiltersOrAnnotationsShouldFail(t *testing.T) {
name: "base",
sdk_version: "current",
srcs: ["a.java"],
test_suites: ["general-tests"],
}
test_module_config {
@@ -218,6 +220,7 @@ func TestModuleConfigMultipleDerivedTestsWriteDistinctMakeEntries(t *testing.T)
sdk_version: "current",
srcs: ["a.java"],
data: [":HelperApp", "data/testfile"],
test_suites: ["general-tests"],
}
android_test_helper_app {
@@ -362,6 +365,31 @@ func TestModuleConfigHostNeedsATestSuite(t *testing.T) {
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) {
t.Parallel()
ctx := android.GroupFixturePreparers(
@@ -389,6 +417,7 @@ func TestTestOnlyProvider(t *testing.T) {
name: "base",
sdk_version: "current",
data: ["data/testfile"],
test_suites: ["general-tests"],
}
java_test_host {