From 8ec823cba166a41eb0e9e5ff8fe679e691fec678 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Wed, 7 Dec 2022 18:18:37 -0800 Subject: [PATCH] Allow adding extra tradefed options in the Android.bp file Some tests need to add custom tradefed options, but still want to keep most of the soong autogenerated tradefed xml file. Expose a test_options: { tradefed_options: [...] } property that will allow tests to add more options to the autogenerated xml file. Fixes: 184895128 Test: go test, and verified that the ninja files did not change for aosp_arm64 Change-Id: I75f7eb002c8325ce7cdc76e12e76e16195320620 --- android/module.go | 1 - cc/test.go | 23 +++- java/java.go | 27 ++++- java/java_test.go | 22 ++++ java/robolectric.go | 11 +- python/test.go | 11 +- rust/benchmark.go | 14 ++- rust/test.go | 17 +-- sh/sh_binary.go | 12 +- tradefed/autogen.go | 271 ++++++++++++++++++++------------------------ 10 files changed, 232 insertions(+), 177 deletions(-) diff --git a/android/module.go b/android/module.go index 681f724b0..bf9737aa2 100644 --- a/android/module.go +++ b/android/module.go @@ -27,7 +27,6 @@ import ( "text/scanner" "android/soong/bazel" - "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) diff --git a/cc/test.go b/cc/test.go index 536210ba4..ed2a58a04 100644 --- a/cc/test.go +++ b/cc/test.go @@ -459,8 +459,16 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) { configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.MinApiLevelModuleController", options}) } - test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config, - test.Properties.Test_config_template, test.testDecorator.InstallerProperties.Test_suites, configs, test.Properties.Auto_gen_config, testInstallBase) + test.testConfig = tradefed.NewMaybeAutoGenTestConfigBuilder(ctx). + SetTestConfigProp(test.Properties.Test_config). + SetTestTemplateConfigProp(test.Properties.Test_config_template). + SetTestSuites(test.testDecorator.InstallerProperties.Test_suites). + SetConfig(configs). + SetAutoGenConfig(test.Properties.Auto_gen_config). + SetTestInstallBase(testInstallBase). + SetDeviceTemplate("${NativeTestConfigTemplate}"). + SetHostTemplate("${NativeHostTestConfigTemplate}"). + Build() test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs) @@ -616,8 +624,15 @@ func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Pat if Bool(benchmark.Properties.Require_root) { configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil}) } - benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config, - benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites, configs, benchmark.Properties.Auto_gen_config) + benchmark.testConfig = tradefed.NewMaybeAutoGenTestConfigBuilder(ctx). + SetTestConfigProp(benchmark.Properties.Test_config). + SetTestTemplateConfigProp(benchmark.Properties.Test_config_template). + SetTestSuites(benchmark.Properties.Test_suites). + SetConfig(configs). + SetAutoGenConfig(benchmark.Properties.Auto_gen_config). + SetDeviceTemplate("${NativeBenchmarkTestConfigTemplate}"). + SetHostTemplate("${NativeBenchmarkTestConfigTemplate}"). + Build() benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName()) benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName()) diff --git a/java/java.go b/java/java.go index 9dd585062..dd2437621 100644 --- a/java/java.go +++ b/java/java.go @@ -888,6 +888,10 @@ type TestOptions struct { // a list of extra test configuration files that should be installed with the module. Extra_test_configs []string `android:"path,arch_variant"` + + // Extra