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
diff --git a/tradefed_modules/test_module_config_test.go b/tradefed_modules/test_module_config_test.go
index 97179f5..1510a03 100644
--- a/tradefed_modules/test_module_config_test.go
+++ b/tradefed_modules/test_module_config_test.go
@@ -40,6 +40,7 @@
name: "base",
sdk_version: "current",
data: [":HelperApp", "data/testfile"],
+ test_suites: ["general-tests"],
}
test_module_config {
@@ -160,7 +161,7 @@
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 @@
name: "base",
sdk_version: "current",
srcs: ["a.java"],
+ test_suites: ["general-tests"],
}
test_module_config {
@@ -218,6 +220,7 @@
sdk_version: "current",
srcs: ["a.java"],
data: [":HelperApp", "data/testfile"],
+ test_suites: ["general-tests"],
}
android_test_helper_app {
@@ -362,6 +365,31 @@
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 @@
name: "base",
sdk_version: "current",
data: ["data/testfile"],
+ test_suites: ["general-tests"],
}
java_test_host {