Add option test_min_api_level and test_min_sdk_version for auto-generated test config

The new option will allow the auto-generated test config for cc_test to
include MinApiLevelModuleController and check the api-level before test.

Bug: 140912549
Test: 1. $vi platform_testing/tests/example/native/Android.bp
      2. add
          test_min_api_level: 29,
          or
          test_min_sdk_version: 29,
      3. $m -j hello_world_test
      4. check hello_world_test.config

Change-Id: Ic742d41898928df1637890bec87796d90e886516
This commit is contained in:
nelsonli
2019-09-17 16:35:23 +08:00
parent 362e9ce427
commit 0d7111ec0f
2 changed files with 44 additions and 10 deletions

View File

@@ -73,26 +73,34 @@ func (o Option) Config() string {
return fmt.Sprintf(`<option name="%s" value="%s" />`, o.Name, o.Value)
}
type Preparer struct {
// It can be a template of object or target_preparer.
type Object struct {
// Set it as a target_preparer if object type == "target_preparer".
Type string
Class string
Options []Option
}
var _ Config = Preparer{}
var _ Config = Object{}
func (p Preparer) Config() string {
func (ob Object) Config() string {
var optionStrings []string
for _, option := range p.Options {
for _, option := range ob.Options {
optionStrings = append(optionStrings, option.Config())
}
var options string
if len(p.Options) == 0 {
if len(ob.Options) == 0 {
options = ""
} else {
optionDelimiter := fmt.Sprintf("\\n%s%s", test_xml_indent, test_xml_indent)
options = optionDelimiter + strings.Join(optionStrings, optionDelimiter)
}
return fmt.Sprintf(`<target_preparer class="%s">%s\n%s</target_preparer>`, p.Class, options, test_xml_indent)
if ob.Type == "target_preparer" {
return fmt.Sprintf(`<target_preparer class="%s">%s\n%s</target_preparer>`, ob.Class, options, test_xml_indent)
} else {
return fmt.Sprintf(`<object type="%s" class="%s">%s\n%s</object>`, ob.Type, ob.Class, options, test_xml_indent)
}
}
func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config) {