Give cc_test rule information to determine the test types

There are three types of tests, deviceless tests, device-driven tests
and host-driven device tests. But currently we don't have information
to get the type of a test and can't generate test targets on desired
types.

Test: b test //platform_testing/tests/example/native:hello_world_test
Test: b test //packages/modules/adb:adbd_test
Bug: 296312548
Change-Id: I3f022ef769636d508e055477623a4d1a6a1d9044
This commit is contained in:
yike
2023-08-17 01:03:37 +00:00
parent b0e1035417
commit fdca7fe03b
3 changed files with 47 additions and 0 deletions

View File

@@ -686,6 +686,8 @@ type testBinaryAttributes struct {
tidyAttributes
tradefed.TestConfigAttributes
Runs_on bazel.StringListAttribute
}
// testBinaryBp2build is the bp2build converter for cc_test modules. A cc_test's
@@ -730,6 +732,8 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
addImplicitGtestDeps(ctx, &testBinaryAttrs, gtest, gtestIsolated)
var unitTest *bool
for _, testProps := range m.GetProperties() {
if p, ok := testProps.(*TestBinaryProperties); ok {
useVendor := false // TODO Bug: 262914724
@@ -745,9 +749,15 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
&testInstallBase,
)
testBinaryAttrs.TestConfigAttributes = testConfigAttributes
unitTest = p.Test_options.Unit_test
}
}
testBinaryAttrs.Runs_on = bazel.MakeStringListAttribute(android.RunsOn(
m.ModuleBase.HostSupported(),
m.ModuleBase.DeviceSupported(),
gtest || (unitTest != nil && *unitTest)))
// TODO (b/262914724): convert to tradefed_cc_test and tradefed_cc_test_host
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{