diff options
author | 2021-01-15 15:57:27 +0100 | |
---|---|---|
committer | 2021-04-06 12:40:34 +0200 | |
commit | 546ccd5614553b35730c3b7b1778e337b0ba24ce (patch) | |
tree | 6e94ee839905e6256f58c0f9dcec983c783e055d /rust/benchmark.go | |
parent | 1d640d0521c7b266bb4b44726305ba2b9971f01d (diff) |
Attach rust_benchmark to atest and tradefed.
Automatically generate required tradefed configs for rust benchmarks so
that they're available in atest.
Test: atest <module with rust_benchmark defined>
Bug: 155309706
Change-Id: I6002100367a66b6b0555614acc6cebb00dbf435d
Diffstat (limited to 'rust/benchmark.go')
-rw-r--r-- | rust/benchmark.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/rust/benchmark.go b/rust/benchmark.go index 6e4fb85c1..b89f5cd9b 100644 --- a/rust/benchmark.go +++ b/rust/benchmark.go @@ -16,9 +16,31 @@ package rust import ( "android/soong/android" + "android/soong/tradefed" ) type BenchmarkProperties struct { + // Disables the creation of a test-specific directory when used with + // relative_install_path. Useful if several tests need to be in the same + // directory, but test_per_src doesn't work. + No_named_install_directory *bool + + // the name of the test configuration (for example "AndroidBenchmark.xml") that should be + // installed with the module. + Test_config *string `android:"path,arch_variant"` + + // the name of the test configuration template (for example "AndroidBenchmarkTemplate.xml") that + // should be installed with the module. + Test_config_template *string `android:"path,arch_variant"` + + // list of compatibility suites (for example "cts", "vts") that the module should be + // installed into. + Test_suites []string `android:"arch_variant"` + + // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml + // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true + // explicitly. + Auto_gen_config *bool } type benchmarkDecorator struct { @@ -87,3 +109,21 @@ func (benchmark *benchmarkDecorator) compilerDeps(ctx DepsContext, deps Deps) De func (benchmark *benchmarkDecorator) compilerProps() []interface{} { return append(benchmark.binaryDecorator.compilerProps(), &benchmark.Properties) } + +func (benchmark *benchmarkDecorator) install(ctx ModuleContext) { + benchmark.testConfig = tradefed.AutoGenRustBenchmarkConfig(ctx, + benchmark.Properties.Test_config, + benchmark.Properties.Test_config_template, + benchmark.Properties.Test_suites, + nil, + benchmark.Properties.Auto_gen_config) + + // default relative install path is module name + if !Bool(benchmark.Properties.No_named_install_directory) { + benchmark.baseCompiler.relative = ctx.ModuleName() + } else if String(benchmark.baseCompiler.Properties.Relative_install_path) == "" { + ctx.PropertyErrorf("no_named_install_directory", "Module install directory may only be disabled if relative_install_path is set") + } + + benchmark.binaryDecorator.install(ctx) +} |