Generate ATS 2.0 config for Mobly test.
- Support test_config and test_config_template - The `config` file extension is widly used by TF. Use `configv2` for ATS 2.0 tests to avoid configuration errors in TF. - Add `mobly` tag to support atest Test: m CtsBluetoothMultiDevicesTestCases (with `runner = "mobly"`) Bug: 299850687 Change-Id: Idbed90ab30e35aeed8cdeeb0aa0aa7adb75a3cd9
This commit is contained in:
parent
f166df7efd
commit
3dfec5a2c6
1 changed files with 22 additions and 26 deletions
|
@ -158,35 +158,25 @@ func (p *PythonTestModule) GenerateAndroidBuildActions(ctx android.ModuleContext
|
|||
}
|
||||
|
||||
runner := proptools.StringDefault(p.testProperties.Test_options.Runner, "tradefed")
|
||||
if runner == "tradefed" {
|
||||
template := "${PythonBinaryHostTestConfigTemplate}"
|
||||
if runner == "mobly" {
|
||||
// Add tag to enable Atest mobly runner
|
||||
if !android.InList("mobly", p.testProperties.Test_options.Tags) {
|
||||
p.testProperties.Test_options.Tags = append(p.testProperties.Test_options.Tags, "mobly")
|
||||
}
|
||||
template = "${PythonBinaryHostMoblyTestConfigTemplate}"
|
||||
} else if runner != "tradefed" {
|
||||
panic(fmt.Errorf("unknown python test runner '%s', should be 'tradefed' or 'mobly'", runner))
|
||||
}
|
||||
p.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
|
||||
TestConfigProp: p.testProperties.Test_config,
|
||||
TestConfigTemplateProp: p.testProperties.Test_config_template,
|
||||
TestSuites: p.binaryProperties.Test_suites,
|
||||
OptionsForAutogenerated: configs,
|
||||
AutoGenConfig: p.binaryProperties.Auto_gen_config,
|
||||
DeviceTemplate: "${PythonBinaryHostTestConfigTemplate}",
|
||||
HostTemplate: "${PythonBinaryHostTestConfigTemplate}",
|
||||
DeviceTemplate: template,
|
||||
HostTemplate: template,
|
||||
})
|
||||
} 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))
|
||||
}
|
||||
|
||||
for _, dataSrcPath := range android.PathsForModuleSrc(ctx, p.testProperties.Data) {
|
||||
p.data = append(p.data, android.DataPath{SrcPath: dataSrcPath})
|
||||
|
@ -228,6 +218,12 @@ func (p *PythonTestModule) AndroidMkEntries() []android.AndroidMkEntries {
|
|||
entries.SetString("LOCAL_FULL_TEST_CONFIG", p.testConfig.String())
|
||||
}
|
||||
|
||||
// ATS 2.0 is the test harness for mobly tests and the test config is for ATS 2.0.
|
||||
// Add "v2" suffix to test config name to distinguish it from the config for TF.
|
||||
if proptools.String(p.testProperties.Test_options.Runner) == "mobly" {
|
||||
entries.SetString("LOCAL_TEST_CONFIG_SUFFIX", "v2")
|
||||
}
|
||||
|
||||
entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true))
|
||||
android.SetAconfigFileMkEntries(&p.ModuleBase, entries, p.mergedAconfigFiles)
|
||||
|
||||
|
|
Loading…
Reference in a new issue