diff options
| author | Chih-Hung Hsieh <chh@google.com> | 2019-11-22 20:22:35 -0800 |
|---|---|---|
| committer | Chih-hung Hsieh <chh@google.com> | 2019-12-02 17:44:53 +0000 |
| commit | ede57ae8122992e788be7977803926e76e35b466 (patch) | |
| tree | 69072fa345ac192c934e30db151ff9fcffb406c3 /rust | |
| parent | 01178ed7d15f995e19d441964deee6ba6e1eac7e (diff) | |
| download | build_soong-ede57ae8122992e788be7977803926e76e35b466.tar.gz build_soong-ede57ae8122992e788be7977803926e76e35b466.tar.bz2 build_soong-ede57ae8122992e788be7977803926e76e35b466.zip | |
Generate tradefed config for rust device tests.
* The RustBinaryTest runner and device test config template
are derived from GTest. Device tests are pushed to /data/local/tmp.
Bug: 140938178
Test: make unicode-xid projects; run atest
Change-Id: Idb4cab7872b48c6e25bc59b85aa6d9dece4383ec
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/androidmk.go | 6 | ||||
| -rw-r--r-- | rust/test.go | 25 |
2 files changed, 20 insertions, 11 deletions
diff --git a/rust/androidmk.go b/rust/androidmk.go index edd5c5f8..2636d97f 100644 --- a/rust/androidmk.go +++ b/rust/androidmk.go @@ -90,11 +90,7 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr func (test *testDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { test.binaryDecorator.AndroidMk(ctx, ret) ret.Class = "NATIVE_TESTS" - stem := String(test.baseCompiler.Properties.Stem) - if stem != "" && !strings.HasSuffix(ctx.Name(), "_"+stem) { - // Avoid repeated suffix in the module name. - ret.SubName = "_" + stem - } + ret.SubName = test.getMutatedModuleSubName(ctx.Name()) ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { if len(test.Properties.Test_suites) > 0 { fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", diff --git a/rust/test.go b/rust/test.go index cb64e8f8..b3911036 100644 --- a/rust/test.go +++ b/rust/test.go @@ -69,15 +69,28 @@ func (test *testDecorator) compilerProps() []interface{} { return append(test.binaryDecorator.compilerProps(), &test.Properties) } +func (test *testDecorator) getMutatedModuleSubName(moduleName string) string { + stem := String(test.baseCompiler.Properties.Stem) + if stem != "" && !strings.HasSuffix(moduleName, "_"+stem) { + // Avoid repeated suffix in the module name. + return "_" + stem + } + return "" +} + func (test *testDecorator) install(ctx ModuleContext, file android.Path) { name := ctx.ModuleName() // default executable name - if stem := String(test.baseCompiler.Properties.Stem); stem != "" { - name = stem - } - if path := test.baseCompiler.relativeInstallPath(); path != "" { - name = path + "/" + name + if ctx.Device() { // on device, use mutated module name + name = name + test.getMutatedModuleSubName(name) + } else { // on host, use stem name in relative_install_path + if stem := String(test.baseCompiler.Properties.Stem); stem != "" { + name = stem + } + if path := test.baseCompiler.relativeInstallPath(); path != "" { + name = path + "/" + name + } } - test.testConfig = tradefed.AutoGenRustHostTestConfig(ctx, name, + test.testConfig = tradefed.AutoGenRustTestConfig(ctx, name, test.Properties.Test_config, test.Properties.Test_config_template, test.Properties.Test_suites, |
