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:
parent
01178ed7d1
commit
ede57ae812
5 changed files with 26 additions and 12 deletions
|
@ -90,11 +90,7 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr
|
||||||
func (test *testDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
func (test *testDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
test.binaryDecorator.AndroidMk(ctx, ret)
|
test.binaryDecorator.AndroidMk(ctx, ret)
|
||||||
ret.Class = "NATIVE_TESTS"
|
ret.Class = "NATIVE_TESTS"
|
||||||
stem := String(test.baseCompiler.Properties.Stem)
|
ret.SubName = test.getMutatedModuleSubName(ctx.Name())
|
||||||
if stem != "" && !strings.HasSuffix(ctx.Name(), "_"+stem) {
|
|
||||||
// Avoid repeated suffix in the module name.
|
|
||||||
ret.SubName = "_" + stem
|
|
||||||
}
|
|
||||||
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
|
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
|
||||||
if len(test.Properties.Test_suites) > 0 {
|
if len(test.Properties.Test_suites) > 0 {
|
||||||
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
|
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
|
||||||
|
|
25
rust/test.go
25
rust/test.go
|
@ -69,15 +69,28 @@ func (test *testDecorator) compilerProps() []interface{} {
|
||||||
return append(test.binaryDecorator.compilerProps(), &test.Properties)
|
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) {
|
func (test *testDecorator) install(ctx ModuleContext, file android.Path) {
|
||||||
name := ctx.ModuleName() // default executable name
|
name := ctx.ModuleName() // default executable name
|
||||||
if stem := String(test.baseCompiler.Properties.Stem); stem != "" {
|
if ctx.Device() { // on device, use mutated module name
|
||||||
name = stem
|
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 != "" {
|
test.testConfig = tradefed.AutoGenRustTestConfig(ctx, name,
|
||||||
name = path + "/" + name
|
|
||||||
}
|
|
||||||
test.testConfig = tradefed.AutoGenRustHostTestConfig(ctx, name,
|
|
||||||
test.Properties.Test_config,
|
test.Properties.Test_config,
|
||||||
test.Properties.Test_config_template,
|
test.Properties.Test_config_template,
|
||||||
test.Properties.Test_suites,
|
test.Properties.Test_suites,
|
||||||
|
|
|
@ -197,11 +197,14 @@ func AutoGenPythonBinaryHostTestConfig(ctx android.ModuleContext, testConfigProp
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
func AutoGenRustHostTestConfig(ctx android.ModuleContext, name string, testConfigProp *string,
|
func AutoGenRustTestConfig(ctx android.ModuleContext, name string, testConfigProp *string,
|
||||||
testConfigTemplateProp *string, testSuites []string, autoGenConfig *bool) android.Path {
|
testConfigTemplateProp *string, testSuites []string, autoGenConfig *bool) android.Path {
|
||||||
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig)
|
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig)
|
||||||
if autogenPath != nil {
|
if autogenPath != nil {
|
||||||
templatePathString := "${RustHostTestConfigTemplate}"
|
templatePathString := "${RustHostTestConfigTemplate}"
|
||||||
|
if ctx.Device() {
|
||||||
|
templatePathString = "${RustDeviceTestConfigTemplate}"
|
||||||
|
}
|
||||||
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
|
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
|
||||||
if templatePath.Valid() {
|
if templatePath.Valid() {
|
||||||
templatePathString = templatePath.String()
|
templatePathString = templatePath.String()
|
||||||
|
|
|
@ -31,6 +31,7 @@ func init() {
|
||||||
pctx.SourcePathVariable("NativeHostTestConfigTemplate", "build/make/core/native_host_test_config_template.xml")
|
pctx.SourcePathVariable("NativeHostTestConfigTemplate", "build/make/core/native_host_test_config_template.xml")
|
||||||
pctx.SourcePathVariable("NativeTestConfigTemplate", "build/make/core/native_test_config_template.xml")
|
pctx.SourcePathVariable("NativeTestConfigTemplate", "build/make/core/native_test_config_template.xml")
|
||||||
pctx.SourcePathVariable("PythonBinaryHostTestConfigTemplate", "build/make/core/python_binary_host_test_config_template.xml")
|
pctx.SourcePathVariable("PythonBinaryHostTestConfigTemplate", "build/make/core/python_binary_host_test_config_template.xml")
|
||||||
|
pctx.SourcePathVariable("RustDeviceTestConfigTemplate", "build/make/core/rust_device_test_config_template.xml")
|
||||||
pctx.SourcePathVariable("RustHostTestConfigTemplate", "build/make/core/rust_host_test_config_template.xml")
|
pctx.SourcePathVariable("RustHostTestConfigTemplate", "build/make/core/rust_host_test_config_template.xml")
|
||||||
|
|
||||||
pctx.SourcePathVariable("EmptyTestConfig", "build/make/core/empty_test_config.xml")
|
pctx.SourcePathVariable("EmptyTestConfig", "build/make/core/empty_test_config.xml")
|
||||||
|
|
|
@ -31,6 +31,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
||||||
ctx.Strict("NATIVE_HOST_TEST_CONFIG_TEMPLATE", "${NativeHostTestConfigTemplate}")
|
ctx.Strict("NATIVE_HOST_TEST_CONFIG_TEMPLATE", "${NativeHostTestConfigTemplate}")
|
||||||
ctx.Strict("NATIVE_TEST_CONFIG_TEMPLATE", "${NativeTestConfigTemplate}")
|
ctx.Strict("NATIVE_TEST_CONFIG_TEMPLATE", "${NativeTestConfigTemplate}")
|
||||||
ctx.Strict("PYTHON_BINARY_HOST_TEST_CONFIG_TEMPLATE", "${PythonBinaryHostTestConfigTemplate}")
|
ctx.Strict("PYTHON_BINARY_HOST_TEST_CONFIG_TEMPLATE", "${PythonBinaryHostTestConfigTemplate}")
|
||||||
|
ctx.Strict("RUST_DEVICE_TEST_CONFIG_TEMPLATE", "${RustDeviceTestConfigTemplate}")
|
||||||
ctx.Strict("RUST_HOST_TEST_CONFIG_TEMPLATE", "${RustHostTestConfigTemplate}")
|
ctx.Strict("RUST_HOST_TEST_CONFIG_TEMPLATE", "${RustHostTestConfigTemplate}")
|
||||||
|
|
||||||
ctx.Strict("EMPTY_TEST_CONFIG", "${EmptyTestConfig}")
|
ctx.Strict("EMPTY_TEST_CONFIG", "${EmptyTestConfig}")
|
||||||
|
|
Loading…
Reference in a new issue