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
This commit is contained in:
Chih-Hung Hsieh
2019-11-22 20:22:35 -08:00
committed by Chih-hung Hsieh
parent 01178ed7d1
commit ede57ae812
5 changed files with 26 additions and 12 deletions

View File

@@ -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 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
}
}
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,