aboutsummaryrefslogtreecommitdiffstats
path: root/tradefed
diff options
context:
space:
mode:
authorDan Shi <dshi@google.com>2019-08-27 10:37:24 -0700
committerDan Shi <dshi@google.com>2019-08-28 15:53:43 -0700
commit20ccd2125df5fe6fd54e7b247ec98193082ccbc9 (patch)
tree6bd529819e74577553814bdae1f2f745a5b5da56 /tradefed
parent20cf012ad1754f7366036723bbeb8d521dd6fec2 (diff)
downloadbuild_soong-20ccd2125df5fe6fd54e7b247ec98193082ccbc9.tar.gz
build_soong-20ccd2125df5fe6fd54e7b247ec98193082ccbc9.tar.bz2
build_soong-20ccd2125df5fe6fd54e7b247ec98193082ccbc9.zip
Add option disable_framework for auto-generated test config
The new option will allow the auto-generated test config for cc_test to include RunCommandTargetPreparer to disable framework before the test run and re-enable it after the test run. Bug: 140065309 Test: test hello_world_test with the new option. Change-Id: If2189e9474f5b11bd0d0471e231a2cae14155389
Diffstat (limited to 'tradefed')
-rw-r--r--tradefed/autogen.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/tradefed/autogen.go b/tradefed/autogen.go
index 952b0223..7cd7c5a3 100644
--- a/tradefed/autogen.go
+++ b/tradefed/autogen.go
@@ -24,6 +24,8 @@ import (
"android/soong/android"
)
+const test_xml_indent = " "
+
func getTestConfigTemplate(ctx android.ModuleContext, prop *string) android.OptionalPath {
return ctx.ExpandOptionalSource(prop, "test_config_template")
}
@@ -72,13 +74,25 @@ func (o Option) Config() string {
}
type Preparer struct {
- Class string
+ Class string
+ Options []Option
}
var _ Config = Preparer{}
func (p Preparer) Config() string {
- return fmt.Sprintf(`<target_preparer class="%s" />`, p.Class)
+ var optionStrings []string
+ for _, option := range p.Options {
+ optionStrings = append(optionStrings, option.Config())
+ }
+ var options string
+ if len(p.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)
}
func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config) {
@@ -86,7 +100,7 @@ func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, tem
for _, config := range configs {
configStrings = append(configStrings, config.Config())
}
- extraConfigs := strings.Join(configStrings, "\n ")
+ extraConfigs := strings.Join(configStrings, fmt.Sprintf("\\n%s", test_xml_indent))
extraConfigs = proptools.NinjaAndShellEscape(extraConfigs)
ctx.Build(pctx, android.BuildParams{