Merge "Add python template for mobly tests."
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
package python
|
package python
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -63,7 +65,22 @@ type TestProperties struct {
|
|||||||
Java_data []string
|
Java_data []string
|
||||||
|
|
||||||
// Test options.
|
// Test options.
|
||||||
Test_options android.CommonTestOptions
|
Test_options TestOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestOptions struct {
|
||||||
|
android.CommonTestOptions
|
||||||
|
|
||||||
|
// Runner for the test. Supports "tradefed" and "mobly" (for multi-device tests). Default is "tradefed".
|
||||||
|
Runner *string
|
||||||
|
|
||||||
|
// Metadata to describe the test configuration.
|
||||||
|
Metadata []Metadata
|
||||||
|
}
|
||||||
|
|
||||||
|
type Metadata struct {
|
||||||
|
Name string
|
||||||
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PythonTestModule struct {
|
type PythonTestModule struct {
|
||||||
@@ -94,14 +111,41 @@ func (p *PythonTestModule) GenerateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
p.PythonLibraryModule.GenerateAndroidBuildActions(ctx)
|
p.PythonLibraryModule.GenerateAndroidBuildActions(ctx)
|
||||||
p.buildBinary(ctx)
|
p.buildBinary(ctx)
|
||||||
|
|
||||||
|
var configs []tradefed.Option
|
||||||
|
for _, metadata := range p.testProperties.Test_options.Metadata {
|
||||||
|
configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: metadata.Name, Value: metadata.Value})
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := proptools.StringDefault(p.testProperties.Test_options.Runner, "tradefed")
|
||||||
|
if runner == "tradefed" {
|
||||||
p.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
|
p.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
|
||||||
TestConfigProp: p.testProperties.Test_config,
|
TestConfigProp: p.testProperties.Test_config,
|
||||||
TestConfigTemplateProp: p.testProperties.Test_config_template,
|
TestConfigTemplateProp: p.testProperties.Test_config_template,
|
||||||
TestSuites: p.binaryProperties.Test_suites,
|
TestSuites: p.binaryProperties.Test_suites,
|
||||||
|
OptionsForAutogenerated: configs,
|
||||||
AutoGenConfig: p.binaryProperties.Auto_gen_config,
|
AutoGenConfig: p.binaryProperties.Auto_gen_config,
|
||||||
DeviceTemplate: "${PythonBinaryHostTestConfigTemplate}",
|
DeviceTemplate: "${PythonBinaryHostTestConfigTemplate}",
|
||||||
HostTemplate: "${PythonBinaryHostTestConfigTemplate}",
|
HostTemplate: "${PythonBinaryHostTestConfigTemplate}",
|
||||||
})
|
})
|
||||||
|
} else if runner == "mobly" {
|
||||||
|
if p.testProperties.Test_config != nil || p.testProperties.Test_config_template != nil || p.binaryProperties.Auto_gen_config != nil {
|
||||||
|
panic(fmt.Errorf("cannot set test_config, test_config_template or auto_gen_config for mobly test"))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testSuite := range p.binaryProperties.Test_suites {
|
||||||
|
if testSuite == "cts" {
|
||||||
|
configs = append(configs, tradefed.Option{Name: "test-suite-tag", Value: "cts"})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
|
||||||
|
OptionsForAutogenerated: configs,
|
||||||
|
DeviceTemplate: "${PythonBinaryHostMoblyTestConfigTemplate}",
|
||||||
|
HostTemplate: "${PythonBinaryHostMoblyTestConfigTemplate}",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
panic(fmt.Errorf("unknown python test runner '%s', should be 'tradefed' or 'mobly'", runner))
|
||||||
|
}
|
||||||
|
|
||||||
p.installedDest = ctx.InstallFile(installDir(ctx, "nativetest", "nativetest64", ctx.ModuleName()), p.installSource.Base(), p.installSource)
|
p.installedDest = ctx.InstallFile(installDir(ctx, "nativetest", "nativetest64", ctx.ModuleName()), p.installSource.Base(), p.installSource)
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ func init() {
|
|||||||
pctx.SourcePathVariable("NativeBenchmarkTestConfigTemplate", "build/make/core/native_benchmark_test_config_template.xml")
|
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("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("PythonBinaryHostMoblyTestConfigTemplate", "build/make/core/python_binary_host_mobly_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("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")
|
||||||
|
Reference in New Issue
Block a user