Merge "Skip device test only configs for auto gen test config" into main

This commit is contained in:
Treehugger Robot 2023-09-02 08:46:56 +00:00 committed by Gerrit Code Review
commit e56803d74d

View file

@ -395,7 +395,7 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
useVendor := ctx.inVendor() || ctx.useVndk() useVendor := ctx.inVendor() || ctx.useVndk()
testInstallBase := getTestInstallBase(useVendor) testInstallBase := getTestInstallBase(useVendor)
configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx)) configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device())
test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{ test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
TestConfigProp: test.Properties.Test_config, TestConfigProp: test.Properties.Test_config,
@ -435,22 +435,24 @@ func getTestInstallBase(useVendor bool) string {
return testInstallBase return testInstallBase
} }
func getTradefedConfigOptions(ctx android.EarlyModuleContext, properties *TestBinaryProperties, isolated bool) []tradefed.Config { func getTradefedConfigOptions(ctx android.EarlyModuleContext, properties *TestBinaryProperties, isolated bool, device bool) []tradefed.Config {
var configs []tradefed.Config var configs []tradefed.Config
for _, module := range properties.Test_mainline_modules { for _, module := range properties.Test_mainline_modules {
configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module}) configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module})
} }
if Bool(properties.Require_root) { if device {
configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil}) if Bool(properties.Require_root) {
} else { configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
var options []tradefed.Option } else {
options = append(options, tradefed.Option{Name: "force-root", Value: "false"}) var options []tradefed.Option
configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options}) options = append(options, tradefed.Option{Name: "force-root", Value: "false"})
} configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options})
if Bool(properties.Disable_framework) { }
var options []tradefed.Option if Bool(properties.Disable_framework) {
configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.StopServicesSetup", options}) var options []tradefed.Option
configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.StopServicesSetup", options})
}
} }
if isolated { if isolated {
configs = append(configs, tradefed.Option{Name: "not-shardable", Value: "true"}) configs = append(configs, tradefed.Option{Name: "not-shardable", Value: "true"})
@ -760,7 +762,7 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
p.Auto_gen_config, p.Auto_gen_config,
p.Test_options.Test_suite_tag, p.Test_options.Test_suite_tag,
p.Test_config_template, p.Test_config_template,
getTradefedConfigOptions(ctx, p, gtestIsolated), getTradefedConfigOptions(ctx, p, gtestIsolated, true),
&testInstallBase, &testInstallBase,
) )
testBinaryAttrs.TestConfigAttributes = testConfigAttributes testBinaryAttrs.TestConfigAttributes = testConfigAttributes