Merge "Add test spec provider to test modules." into main am: bc34d495c9

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2836758

Change-Id: I98d9c51c8ffab2ec0e9a6451e0637eea07e23727
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Aditya Choudhary 2023-11-21 09:48:37 +00:00 committed by Automerger Merge Worker
commit 0c6c5f5431
7 changed files with 23 additions and 5 deletions

View file

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

View file

@ -24,6 +24,7 @@ import (
"strconv"
"strings"
"android/soong/testing"
"android/soong/ui/metrics/bp2build_metrics_proto"
"github.com/google/blueprint"
@ -862,9 +863,10 @@ type Module struct {
Properties BaseProperties
// initialize before calling Init
hod android.HostOrDeviceSupported
multilib android.Multilib
bazelable bool
hod android.HostOrDeviceSupported
multilib android.Multilib
bazelable bool
testModule bool
// Allowable SdkMemberTypes of this module type.
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)
}

View file

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

View file

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

View file

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

View file

@ -20,6 +20,7 @@ import (
"android/soong/bazel"
"android/soong/bloaty"
"android/soong/testing"
"android/soong/ui/metrics/bp2build_metrics_proto"
"github.com/google/blueprint"
@ -144,8 +145,9 @@ type Module struct {
Properties BaseProperties
hod android.HostOrDeviceSupported
multilib android.Multilib
hod android.HostOrDeviceSupported
multilib android.Multilib
testModule bool
makeLinkType string
@ -1038,6 +1040,9 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
ctx.Phony("rust", ctx.RustModule().OutputFile().Path())
}
if mod.testModule {
ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
}
}
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
// host target.
android.AddLoadHook(module, rustTestHostMultilib)
module.testModule = true
return module.Init()
}
func RustTestHostFactory() android.Module {
module, _ := NewRustTest(android.HostSupported)
module.testModule = true
return module.Init()
}