diff options
author | 2021-09-21 10:49:13 -0400 | |
---|---|---|
committer | 2021-09-21 11:01:11 -0400 | |
commit | ba2226164c9479afd1a0dae290fb2b0535aa8e97 (patch) | |
tree | 6ed07d8965e5feea111fcab8e509ae25aa24867f /rust/test.go | |
parent | 1b15345ac932793054a5d8e65cf4862ae7c12e49 (diff) |
rust: Add require_root and vendor install base
Adds the require_root property to rust_test modules so that tests can
run as root. Also adds an install base to allow vendor tests to install
to a different path, otherwise installs to 'unrestricted' like cc_test.
Bug: 200602232
Test: test with require_root: true runs as root
Test: test installed to new base directory
Change-Id: Ifa716871ff87471f0c0caff7af558d47db85ccd1
Diffstat (limited to 'rust/test.go')
-rw-r--r-- | rust/test.go | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/rust/test.go b/rust/test.go index e95b47cff..56da509b5 100644 --- a/rust/test.go +++ b/rust/test.go @@ -59,6 +59,10 @@ type TestProperties 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 } // A test module is a binary module with extra --test compiler flag @@ -109,12 +113,27 @@ func (test *testDecorator) compilerProps() []interface{} { } func (test *testDecorator) install(ctx ModuleContext) { + testInstallBase := "/data/local/tests/unrestricted" + if ctx.RustModule().InVendor() || ctx.RustModule().UseVndk() { + testInstallBase = "/data/local/tests/vendor" + } + + var configs []tradefed.Config + if Bool(test.Properties.Require_root) { + configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil}) + } else { + var options []tradefed.Option + options = append(options, tradefed.Option{Name: "force-root", Value: "false"}) + configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options}) + } + test.testConfig = tradefed.AutoGenRustTestConfig(ctx, test.Properties.Test_config, test.Properties.Test_config_template, test.Properties.Test_suites, - nil, - test.Properties.Auto_gen_config) + configs, + test.Properties.Auto_gen_config, + testInstallBase) dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data) |