summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2025-03-11 15:55:59 -0700
committer Cole Faust <colefaust@google.com> 2025-03-11 15:55:59 -0700
commit5e1454aef7f1e97890b11db5c85b7655ce8f7380 (patch)
tree9feac0470368a38e98ebec8ec9a7475594353c0c
parent7ed094ef25e59df953b422f011eaac8bb1c1eba1 (diff)
Expand TestSuiteInfoProvider to all test modules
Test suites have been historically only defined in the AndroidMk functions. But in soong-only builds, we don't run AndroidMk. It appears Colin already started making a TestSuiteInfo provider, but hadn't set it on all test modules yet. Expand it to all the test modules, and add export it to make so that make can check that it matches LOCAL_COMPATIBILITY_SUITES. Bug: 388850000 Test: m nothing Change-Id: Iee8959742117604fd560c95be60f3cb7cf3d9ae4
-rw-r--r--android/androidmk.go21
-rw-r--r--cc/binary.go4
-rw-r--r--cc/cc.go4
-rw-r--r--cc/library.go4
-rw-r--r--cc/object.go4
-rw-r--r--cc/test.go20
-rw-r--r--java/app.go8
-rw-r--r--java/app_import.go4
-rw-r--r--java/java.go8
-rw-r--r--python/binary.go4
-rw-r--r--rust/benchmark.go4
-rw-r--r--rust/test.go4
-rw-r--r--sh/sh_binary.go4
-rw-r--r--tradefed_modules/test_module_config.go4
14 files changed, 93 insertions, 4 deletions
diff --git a/android/androidmk.go b/android/androidmk.go
index 84eef62ba..694f5d66b 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -528,6 +528,14 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod Module) {
fmt.Fprintf(&a.header, "\ninclude $(CLEAR_VARS) # type: %s, name: %s, variant: %s\n", ctx.ModuleType(mod), base.BaseModuleName(), ctx.ModuleSubDir(mod))
+ // Add the TestSuites from the provider to LOCAL_SOONG_PROVIDER_TEST_SUITES.
+ // LOCAL_SOONG_PROVIDER_TEST_SUITES will be compared against LOCAL_COMPATIBILITY_SUITES
+ // in make and enforced they're the same, to ensure we've successfully translated all
+ // LOCAL_COMPATIBILITY_SUITES usages to the provider.
+ if testSuiteInfo, ok := OtherModuleProvider(ctx, mod, TestSuiteInfoProvider); ok {
+ a.AddStrings("LOCAL_SOONG_PROVIDER_TEST_SUITES", testSuiteInfo.TestSuites...)
+ }
+
// Collect make variable assignment entries.
a.SetString("LOCAL_PATH", ctx.ModuleDir(mod))
a.SetString("LOCAL_MODULE", name+a.SubName)
@@ -1476,12 +1484,17 @@ func (a *AndroidMkInfo) fillInEntries(ctx fillInEntriesContext, mod Module, comm
a.Host_required = append(a.Host_required, commonInfo.HostRequiredModuleNames...)
a.Target_required = append(a.Target_required, commonInfo.TargetRequiredModuleNames...)
- for _, distString := range a.GetDistForGoals(ctx, mod, commonInfo) {
- a.HeaderStrings = append(a.HeaderStrings, distString)
- }
-
+ a.HeaderStrings = append(a.HeaderStrings, a.GetDistForGoals(ctx, mod, commonInfo)...)
a.HeaderStrings = append(a.HeaderStrings, fmt.Sprintf("\ninclude $(CLEAR_VARS) # type: %s, name: %s, variant: %s", ctx.ModuleType(mod), commonInfo.BaseModuleName, ctx.ModuleSubDir(mod)))
+ // Add the TestSuites from the provider to LOCAL_SOONG_PROVIDER_TEST_SUITES.
+ // LOCAL_SOONG_PROVIDER_TEST_SUITES will be compared against LOCAL_COMPATIBILITY_SUITES
+ // in make and enforced they're the same, to ensure we've successfully translated all
+ // LOCAL_COMPATIBILITY_SUITES usages to the provider.
+ if testSuiteInfo, ok := OtherModuleProvider(ctx, mod, TestSuiteInfoProvider); ok {
+ helperInfo.AddStrings("LOCAL_SOONG_PROVIDER_TEST_SUITES", testSuiteInfo.TestSuites...)
+ }
+
// Collect make variable assignment entries.
helperInfo.SetString("LOCAL_PATH", ctx.ModuleDir(mod))
helperInfo.SetString("LOCAL_MODULE", name+a.SubName)
diff --git a/cc/binary.go b/cc/binary.go
index 627d5e560..608251afc 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -551,6 +551,10 @@ func (binary *binaryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON
binary.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
}
+func (binary *binaryDecorator) testSuiteInfo(ctx ModuleContext) {
+ // not a test
+}
+
var _ overridable = (*binaryDecorator)(nil)
func init() {
diff --git a/cc/cc.go b/cc/cc.go
index 16e8df7e2..ae6f3b068 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -797,6 +797,8 @@ type linker interface {
defaultDistFiles() []android.Path
moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON)
+
+ testSuiteInfo(ctx ModuleContext)
}
// specifiedDeps is a tuple struct representing dependencies of a linked binary owned by the linker.
@@ -2408,6 +2410,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
name := v.ImplementationModuleName(ctx.OtherModuleName(c))
ccInfo.LinkerInfo.ImplementationModuleName = &name
}
+
+ c.linker.testSuiteInfo(ctx)
}
if c.library != nil {
ccInfo.LibraryInfo = &LibraryInfo{
diff --git a/cc/library.go b/cc/library.go
index b248224bd..5299771ca 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1078,6 +1078,10 @@ func (library *libraryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSO
library.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
}
+func (library *libraryDecorator) testSuiteInfo(ctx ModuleContext) {
+ // not a test
+}
+
func (library *libraryDecorator) linkStatic(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
diff --git a/cc/object.go b/cc/object.go
index 95a8beb52..ea3ed6151 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -250,3 +250,7 @@ func (object *objectLinker) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *an
object.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"}
}
+
+func (object *objectLinker) testSuiteInfo(ctx ModuleContext) {
+ // not a test
+}
diff --git a/cc/test.go b/cc/test.go
index 8b68c5563..9c276b81a 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -274,6 +274,12 @@ func (test *testDecorator) moduleInfoJSON(ctx android.ModuleContext, moduleInfoJ
}
}
+func (test *testDecorator) testSuiteInfo(ctx ModuleContext) {
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: test.InstallerProperties.Test_suites,
+ })
+}
+
func NewTestInstaller() *baseInstaller {
return NewBaseInstaller("nativetest", "nativetest64", InstallInData)
}
@@ -342,6 +348,10 @@ func (test *testBinary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *androi
}
+func (test *testBinary) testSuiteInfo(ctx ModuleContext) {
+ test.testDecorator.testSuiteInfo(ctx)
+}
+
func (test *testBinary) installerProps() []interface{} {
return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
}
@@ -578,6 +588,10 @@ func (test *testLibrary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *andro
test.testDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
}
+func (test *testLibrary) testSuiteInfo(ctx ModuleContext) {
+ test.testDecorator.testSuiteInfo(ctx)
+}
+
func (test *testLibrary) installerProps() []interface{} {
return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
}
@@ -695,6 +709,12 @@ func (benchmark *benchmarkDecorator) moduleInfoJSON(ctx ModuleContext, moduleInf
}
}
+func (benchmark *benchmarkDecorator) testSuiteInfo(ctx ModuleContext) {
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: benchmark.Properties.Test_suites,
+ })
+}
+
func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
module, binary := newBinary(hod)
module.multilib = android.MultilibBoth
diff --git a/java/app.go b/java/app.go
index f1dcf4176..560129b64 100644
--- a/java/app.go
+++ b/java/app.go
@@ -425,6 +425,10 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon
} else {
moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
}
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: a.appTestHelperAppProperties.Test_suites,
+ })
}
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -1703,6 +1707,10 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
moduleInfoJSON.AutoTestConfig = []string{"true"}
}
moduleInfoJSON.TestMainlineModules = append(moduleInfoJSON.TestMainlineModules, a.testProperties.Test_mainline_modules...)
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: a.testProperties.Test_suites,
+ })
}
func testcaseRel(paths android.Paths) []string {
diff --git a/java/app_import.go b/java/app_import.go
index 37c673ca0..b9e91cd62 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -787,6 +787,10 @@ func (a *AndroidTestImport) GenerateAndroidBuildActions(ctx android.ModuleContex
a.updateModuleInfoJSON(ctx)
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: a.testProperties.Test_suites,
+ })
}
func (a *AndroidTestImport) updateModuleInfoJSON(ctx android.ModuleContext) {
diff --git a/java/java.go b/java/java.go
index 235a27d4c..92de1c1ff 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1954,6 +1954,10 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext,
ctx.InstallFile(pathInTestCases, ctx.ModuleName()+".jar", j.outputFile)
}
}
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: j.testProperties.Test_suites,
+ })
}
func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -1970,6 +1974,10 @@ func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContex
if optionalConfig.Valid() {
moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, optionalConfig.String())
}
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: j.testHelperLibraryProperties.Test_suites,
+ })
}
func (j *JavaTestImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
diff --git a/python/binary.go b/python/binary.go
index feac72a26..af7d30faa 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -159,6 +159,10 @@ func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
}
p.androidMkSharedLibs = sharedLibs
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: p.binaryProperties.Test_suites,
+ })
}
func (p *PythonBinaryModule) AndroidMkEntries() []android.AndroidMkEntries {
diff --git a/rust/benchmark.go b/rust/benchmark.go
index daba9642e..3aa2f1779 100644
--- a/rust/benchmark.go
+++ b/rust/benchmark.go
@@ -146,4 +146,8 @@ func (benchmark *benchmarkDecorator) moduleInfoJSON(ctx ModuleContext, moduleInf
} else {
moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
}
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: benchmark.Properties.Test_suites,
+ })
}
diff --git a/rust/test.go b/rust/test.go
index 9cbc9f414..2fed0d62e 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -320,6 +320,10 @@ func (test *testDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *and
} else {
moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
}
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: test.Properties.Test_suites,
+ })
}
func rustTestHostMultilib(ctx android.LoadHookContext) {
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 894b17f25..7041642e0 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -574,6 +574,10 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, s.testConfig.String())
}
moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, s.extraTestConfigs.Strings()...)
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: s.testProperties.Test_suites,
+ })
}
func addArch(archType string, paths android.Paths) []string {
diff --git a/tradefed_modules/test_module_config.go b/tradefed_modules/test_module_config.go
index 6dd48eb5a..2b341288a 100644
--- a/tradefed_modules/test_module_config.go
+++ b/tradefed_modules/test_module_config.go
@@ -426,6 +426,10 @@ func (m *testModuleConfigModule) generateManifestAndConfig(ctx android.ModuleCon
LocalCertificate: m.provider.LocalCertificate,
IsUnitTest: m.provider.IsUnitTest,
})
+
+ android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{
+ TestSuites: m.tradefedProperties.Test_suites,
+ })
}
var _ android.AndroidMkEntriesProvider = (*testModuleConfigHostModule)(nil)