Add test spec provider to test modules.

Provider added for the following test modules in this change: art_cc_test, cc_benchmark, cc_fuzz, cc_test, cc_test_host, rust_test,and rust_test_host.

Bug: 296873595
Test: Manual test
Change-Id: I815680529bcbecacb3a2bdb8f3746053afdee48c
This commit is contained in:
Aditya Choudhary
2023-11-17 15:27:06 +00:00
parent b91108c9c0
commit 87b2ab28a8
7 changed files with 23 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ bootstrap_go_package {
"soong-multitree", "soong-multitree",
"soong-snapshot", "soong-snapshot",
"soong-sysprop-bp2build", "soong-sysprop-bp2build",
"soong-testing",
"soong-tradefed", "soong-tradefed",
], ],
srcs: [ srcs: [

View File

@@ -24,6 +24,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"android/soong/testing"
"android/soong/ui/metrics/bp2build_metrics_proto" "android/soong/ui/metrics/bp2build_metrics_proto"
"github.com/google/blueprint" "github.com/google/blueprint"
@@ -865,6 +866,7 @@ type Module struct {
hod android.HostOrDeviceSupported hod android.HostOrDeviceSupported
multilib android.Multilib multilib android.Multilib
bazelable bool bazelable bool
testModule bool
// Allowable SdkMemberTypes of this module type. // Allowable SdkMemberTypes of this module type.
sdkMemberTypes []android.SdkMemberType sdkMemberTypes []android.SdkMemberType
@@ -2329,6 +2331,9 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
} }
} }
} }
if c.testModule {
ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
c.maybeInstall(ctx, apexInfo) c.maybeInstall(ctx, apexInfo)
} }

View File

@@ -96,6 +96,7 @@ func fuzzMutatorDeps(mctx android.TopDownMutatorContext) {
// your device, or $ANDROID_PRODUCT_OUT/data/fuzz in your build tree. // your device, or $ANDROID_PRODUCT_OUT/data/fuzz in your build tree.
func LibFuzzFactory() android.Module { func LibFuzzFactory() android.Module {
module := NewFuzzer(android.HostAndDeviceSupported) module := NewFuzzer(android.HostAndDeviceSupported)
module.testModule = true
return module.Init() return module.Init()
} }

View File

@@ -141,6 +141,7 @@ func init() {
func TestFactory() android.Module { func TestFactory() android.Module {
module := NewTest(android.HostAndDeviceSupported, true) module := NewTest(android.HostAndDeviceSupported, true)
module.bazelHandler = &ccTestBazelHandler{module: module} module.bazelHandler = &ccTestBazelHandler{module: module}
module.testModule = true
return module.Init() return module.Init()
} }
@@ -158,12 +159,14 @@ func TestLibraryFactory() android.Module {
// binary. // binary.
func BenchmarkFactory() android.Module { func BenchmarkFactory() android.Module {
module := NewBenchmark(android.HostAndDeviceSupported) module := NewBenchmark(android.HostAndDeviceSupported)
module.testModule = true
return module.Init() return module.Init()
} }
// cc_test_host compiles a test host binary. // cc_test_host compiles a test host binary.
func TestHostFactory() android.Module { func TestHostFactory() android.Module {
module := NewTest(android.HostSupported, true) module := NewTest(android.HostSupported, true)
module.testModule = true
return module.Init() return module.Init()
} }

View File

@@ -12,6 +12,7 @@ bootstrap_go_package {
"soong-cc", "soong-cc",
"soong-rust-config", "soong-rust-config",
"soong-snapshot", "soong-snapshot",
"soong-testing",
], ],
srcs: [ srcs: [
"afdo.go", "afdo.go",

View File

@@ -20,6 +20,7 @@ import (
"android/soong/bazel" "android/soong/bazel"
"android/soong/bloaty" "android/soong/bloaty"
"android/soong/testing"
"android/soong/ui/metrics/bp2build_metrics_proto" "android/soong/ui/metrics/bp2build_metrics_proto"
"github.com/google/blueprint" "github.com/google/blueprint"
@@ -146,6 +147,7 @@ type Module struct {
hod android.HostOrDeviceSupported hod android.HostOrDeviceSupported
multilib android.Multilib multilib android.Multilib
testModule bool
makeLinkType string makeLinkType string
@@ -1038,6 +1040,9 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
ctx.Phony("rust", ctx.RustModule().OutputFile().Path()) ctx.Phony("rust", ctx.RustModule().OutputFile().Path())
} }
if mod.testModule {
ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
} }
func (mod *Module) deps(ctx DepsContext) Deps { func (mod *Module) deps(ctx DepsContext) Deps {

View File

@@ -222,11 +222,13 @@ func RustTestFactory() android.Module {
// rustTestHostMultilib load hook to set MultilibFirst for the // rustTestHostMultilib load hook to set MultilibFirst for the
// host target. // host target.
android.AddLoadHook(module, rustTestHostMultilib) android.AddLoadHook(module, rustTestHostMultilib)
module.testModule = true
return module.Init() return module.Init()
} }
func RustTestHostFactory() android.Module { func RustTestHostFactory() android.Module {
module, _ := NewRustTest(android.HostSupported) module, _ := NewRustTest(android.HostSupported)
module.testModule = true
return module.Init() return module.Init()
} }