diff options
| author | 2019-06-06 16:23:32 -0700 | |
|---|---|---|
| committer | 2019-07-15 17:31:17 +0000 | |
| commit | 40c0afeb7c6606eeb74285f6cdaa956743f3a0cd (patch) | |
| tree | c3e6646addf36dbcf9d8ec4a7a23a2b6ddd60f80 /cc/test.go | |
| parent | 3b98a509f19cb25e9734bb62ba0b592663ed8e4e (diff) | |
Support require_root in auto-gen test configs
require_root is added to allow auto-generated test config to include
RootTargetPreparer so the test runs with root permission.
Bug: 134509111
Bug: 136633978
Test: add "require_root: true" to init_benchmarks and libpower_test
build the modules, confirm the extra target preparer is added in the
test configs.
Change-Id: Ia07503e338935d6aa92560e7cf7b18d2a4c51243
Merged-In: Ia07503e338935d6aa92560e7cf7b18d2a4c51243
Diffstat (limited to 'cc/test.go')
| -rw-r--r-- | cc/test.go | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/cc/test.go b/cc/test.go index dae2a3774..c735fd91f 100644 --- a/cc/test.go +++ b/cc/test.go @@ -64,6 +64,10 @@ type TestBinaryProperties struct { // Test options. Test_options TestOptions + + // Add RootTargetPreparer to auto generated test config. This guarantees the test to run + // with root permission. + Require_root *bool } func init() { @@ -273,18 +277,19 @@ func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags { func (test *testBinary) install(ctx ModuleContext, file android.Path) { test.data = android.PathsForModuleSrc(ctx, test.Properties.Data) - optionsMap := map[string]string{} + var configs []tradefed.Config + if Bool(test.Properties.Require_root) { + configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer"}) + } if Bool(test.testDecorator.Properties.Isolated) { - optionsMap["not-shardable"] = "true" + configs = append(configs, tradefed.Option{"not-shardable", "true"}) } - if test.Properties.Test_options.Run_test_as != nil { - optionsMap["run-test-as"] = String(test.Properties.Test_options.Run_test_as) + configs = append(configs, tradefed.Option{"run-test-as", String(test.Properties.Test_options.Run_test_as)}) } test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config, - test.Properties.Test_config_template, - test.Properties.Test_suites, optionsMap) + test.Properties.Test_config_template, test.Properties.Test_suites, configs) test.binaryDecorator.baseInstaller.dir = "nativetest" test.binaryDecorator.baseInstaller.dir64 = "nativetest64" @@ -371,6 +376,10 @@ type BenchmarkProperties struct { // the name of the test configuration template (for example "AndroidTestTemplate.xml") that // should be installed with the module. Test_config_template *string `android:"path,arch_variant"` + + // Add RootTargetPreparer to auto generated test config. This guarantees the test to run + // with root permission. + Require_root *bool } type benchmarkDecorator struct { @@ -403,8 +412,12 @@ func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) { benchmark.data = android.PathsForModuleSrc(ctx, benchmark.Properties.Data) + var configs []tradefed.Config + if Bool(benchmark.Properties.Require_root) { + configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer"}) + } benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config, - benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites) + benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites, configs) benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName()) benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName()) |