Autogen python test config.
Feature request from developer, autogen python test config.
Bug:118442443
Test: $source build/envsetup.sh ; lunch
$sed -i '/test_config/d' tools/acloud/Android.bp
$make acloud_test
$[ -f $ANDROID_HOST_OUT_TESTCASES/acloud_test/acloud_test.config ] && echo "Found" || echo "Not found"
Change-Id: I196230581b456afe03e67f9cd84c028d18ba08d9
diff --git a/Android.bp b/Android.bp
index d5f052e..b4a9d30 100644
--- a/Android.bp
+++ b/Android.bp
@@ -285,6 +285,7 @@
deps: [
"blueprint",
"soong-android",
+ "soong-tradefed",
],
srcs: [
"python/androidmk.go",
diff --git a/python/androidmk.go b/python/androidmk.go
index 20861cb..c1eaa5e 100644
--- a/python/androidmk.go
+++ b/python/androidmk.go
@@ -70,6 +70,11 @@
if p.testProperties.Test_config != nil {
fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=",
*p.testProperties.Test_config)
+ } else {
+ if p.testConfig != nil {
+ fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=",
+ p.testConfig.String())
+ }
}
})
base.subAndroidMk(ret, p.binaryDecorator.pythonInstaller)
diff --git a/python/test.go b/python/test.go
index 39326f0..43ee54c 100644
--- a/python/test.go
+++ b/python/test.go
@@ -16,6 +16,7 @@
import (
"android/soong/android"
+ "android/soong/tradefed"
)
// This file contains the module types for building Python test.
@@ -29,12 +30,18 @@
// the name of the test configuration (for example "AndroidTest.xml") that should be
// installed with the module.
Test_config *string `android:"arch_variant"`
+
+ // the name of the test configuration template (for example "AndroidTestTemplate.xml") that
+ // should be installed with the module.
+ Test_config_template *string `android:"arch_variant"`
}
type testDecorator struct {
*binaryDecorator
testProperties TestProperties
+
+ testConfig android.Path
}
func (test *testDecorator) bootstrapperProps() []interface{} {
@@ -42,6 +49,9 @@
}
func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) {
+ test.testConfig = tradefed.AutoGenPythonBinaryHostTestConfig(ctx, test.testProperties.Test_config,
+ test.testProperties.Test_config_template)
+
test.binaryDecorator.pythonInstaller.dir = "nativetest"
test.binaryDecorator.pythonInstaller.dir64 = "nativetest64"
diff --git a/tradefed/autogen.go b/tradefed/autogen.go
index 131fdc4..e6a1b48 100644
--- a/tradefed/autogen.go
+++ b/tradefed/autogen.go
@@ -118,6 +118,22 @@
return path
}
+func AutoGenPythonBinaryHostTestConfig(ctx android.ModuleContext, testConfigProp *string,
+ testConfigTemplateProp *string) android.Path {
+
+ path, autogenPath := testConfigPath(ctx, testConfigProp)
+ if autogenPath != nil {
+ templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
+ if templatePath.Valid() {
+ autogenTemplate(ctx, autogenPath, templatePath.String())
+ } else {
+ autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}")
+ }
+ return autogenPath
+ }
+ return path
+}
+
var autogenInstrumentationTest = pctx.StaticRule("autogenInstrumentationTest", blueprint.RuleParams{
Command: "${AutoGenTestConfigScript} $out $in ${EmptyTestConfig} $template",
CommandDeps: []string{
diff --git a/tradefed/config.go b/tradefed/config.go
index 2c432d0..141e0c5 100644
--- a/tradefed/config.go
+++ b/tradefed/config.go
@@ -30,6 +30,7 @@
pctx.SourcePathVariable("NativeBenchmarkTestConfigTemplate", "build/make/core/native_benchmark_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("PythonBinaryHostTestConfigTemplate", "build/make/core/python_binary_host_test_config_template.xml")
pctx.SourcePathVariable("EmptyTestConfig", "build/make/core/empty_test_config.xml")
}
diff --git a/tradefed/makevars.go b/tradefed/makevars.go
index 3ec7997..aad7273 100644
--- a/tradefed/makevars.go
+++ b/tradefed/makevars.go
@@ -30,6 +30,7 @@
ctx.Strict("NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE", "${NativeBenchmarkTestConfigTemplate}")
ctx.Strict("NATIVE_HOST_TEST_CONFIG_TEMPLATE", "${NativeHostTestConfigTemplate}")
ctx.Strict("NATIVE_TEST_CONFIG_TEMPLATE", "${NativeTestConfigTemplate}")
+ ctx.Strict("PYTHON_BINARY_HOST_TEST_CONFIG_TEMPLATE", "${PythonBinaryHostTestConfigTemplate}")
ctx.Strict("EMPTY_TEST_CONFIG", "${EmptyTestConfig}")
}