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
Ignore-AOSP-First: CPing test_spec rule to udc-mainline-prod to support migration of test targets. Cherry pick of: aosp/2836758
Change-Id: Ib9887d0546690355d40facdd3721d7905f5a55df
Merged-In: I815680529bcbecacb3a2bdb8f3746053afdee48c
diff --git a/cc/Android.bp b/cc/Android.bp
index f49dc1a..b12bdce 100644
--- a/cc/Android.bp
+++ b/cc/Android.bp
@@ -18,6 +18,7 @@
"soong-genrule",
"soong-multitree",
"soong-snapshot",
+ "soong-testing",
"soong-tradefed",
],
srcs: [
diff --git a/cc/cc.go b/cc/cc.go
index 307441d..7c0b0c5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -24,6 +24,7 @@
"strconv"
"strings"
+ "android/soong/testing"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -835,9 +836,10 @@
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
@@ -2104,6 +2106,9 @@
}
}
}
+ if c.testModule {
+ ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ }
c.maybeInstall(ctx, apexInfo)
}
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 7aa8b91..452cf35 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -95,6 +95,7 @@
// 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()
}
diff --git a/cc/test.go b/cc/test.go
index 27de06b..e239133 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -137,6 +137,7 @@
func TestFactory() android.Module {
module := NewTest(android.HostAndDeviceSupported, true)
module.bazelHandler = &ccTestBazelHandler{module: module}
+ module.testModule = true
return module.Init()
}
@@ -154,12 +155,14 @@
// 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()
}
diff --git a/rust/Android.bp b/rust/Android.bp
index b01a94a..c5b2000 100644
--- a/rust/Android.bp
+++ b/rust/Android.bp
@@ -12,6 +12,7 @@
"soong-cc",
"soong-rust-config",
"soong-snapshot",
+ "soong-testing",
],
srcs: [
"afdo.go",
diff --git a/rust/rust.go b/rust/rust.go
index 7b520cd..77bb8b6 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -19,6 +19,7 @@
"fmt"
"strings"
+ "android/soong/testing"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -139,8 +140,9 @@
Properties BaseProperties
- hod android.HostOrDeviceSupported
- multilib android.Multilib
+ hod android.HostOrDeviceSupported
+ multilib android.Multilib
+ testModule bool
makeLinkType string
@@ -1007,6 +1009,9 @@
ctx.Phony("rust", ctx.RustModule().OutputFile().Path())
}
+ if mod.testModule {
+ ctx.SetProvider(testing.TestModuleProviderKey, testing.TestModuleProviderData{})
+ }
}
func (mod *Module) deps(ctx DepsContext) Deps {
diff --git a/rust/test.go b/rust/test.go
index 4b5296e..7ffc367 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -222,11 +222,13 @@
// 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()
}