Allow test_suite to nest

This is useful for creating a suite of suites, or for creating a suite that includes all tests in a directory.

Bug: 372945132
Change-Id: Ifa21a69b3798f0dccf80eca0a31e5e8701a17e12
diff --git a/tradefed_modules/test_suite.go b/tradefed_modules/test_suite.go
index cc35ce7..00585f5 100644
--- a/tradefed_modules/test_suite.go
+++ b/tradefed_modules/test_suite.go
@@ -24,6 +24,8 @@
 	"github.com/google/blueprint"
 )
 
+const testSuiteModuleType = "test_suite"
+
 type testSuiteTag struct{
 	blueprint.BaseDependencyTag
 }
@@ -38,7 +40,7 @@
 }
 
 func RegisterTestSuiteBuildComponents(ctx android.RegistrationContext) {
-	ctx.RegisterModuleType("test_suite", TestSuiteFactory)
+	ctx.RegisterModuleType(testSuiteModuleType, TestSuiteFactory)
 }
 
 var PrepareForTestWithTestSuiteBuildComponents = android.GroupFixturePreparers(
@@ -69,8 +71,15 @@
 }
 
 func (t *testSuiteModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+	suiteName := ctx.ModuleName()
 	modulesByName := make(map[string]android.Module)
 	ctx.WalkDeps(func(child, parent android.Module) bool {
+		// Recurse into test_suite dependencies.
+		if ctx.OtherModuleType(child) == testSuiteModuleType {
+			ctx.Phony(suiteName, android.PathForPhony(ctx, child.Name()))
+			return true
+		}
+
 		// Only write out top level test suite dependencies here.
 		if _, ok := ctx.OtherModuleDependencyTag(child).(testSuiteTag); !ok {
 			return false
@@ -85,7 +94,6 @@
 		return false
 	})
 
-	suiteName := ctx.ModuleName()
 	var files []string
 	for name, module := range modulesByName {
 		// Get the test provider data from the child.
@@ -115,7 +123,7 @@
 	module := &testSuiteModule{}
 	module.AddProperties(&module.testSuiteProperties)
 
-	android.InitAndroidModule(module)
+	android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
 	android.InitDefaultableModule(module)
 
 	return module