Loading cc/test.go +11 −2 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ type TestBinaryProperties struct { // Add RootTargetPreparer to auto generated test config. This guarantees the test to run // with root permission. Require_root *bool // Add RunCommandTargetPreparer to stop framework before the test and start it after the test. Disable_framework *bool } func init() { Loading Loading @@ -313,7 +316,13 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) { test.data = android.PathsForModuleSrc(ctx, test.Properties.Data) var configs []tradefed.Config if Bool(test.Properties.Require_root) { configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer"}) configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer", nil}) } if Bool(test.Properties.Disable_framework) { var options []tradefed.Option options = append(options, tradefed.Option{"run-command", "stop"}) options = append(options, tradefed.Option{"teardown-command", "start"}) configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RunCommandTargetPreparer", options}) } if Bool(test.testDecorator.Properties.Isolated) { configs = append(configs, tradefed.Option{"not-shardable", "true"}) Loading Loading @@ -448,7 +457,7 @@ func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Pat benchmark.data = android.PathsForModuleSrc(ctx, benchmark.Properties.Data) var configs []tradefed.Config if Bool(benchmark.Properties.Require_root) { configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer"}) configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer", nil}) } benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config, benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites, configs) Loading tradefed/autogen.go +17 −3 Original line number Diff line number Diff line Loading @@ -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") } Loading Loading @@ -73,12 +75,24 @@ func (o Option) Config() string { type Preparer struct { 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) { Loading @@ -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{ Loading Loading
cc/test.go +11 −2 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ type TestBinaryProperties struct { // Add RootTargetPreparer to auto generated test config. This guarantees the test to run // with root permission. Require_root *bool // Add RunCommandTargetPreparer to stop framework before the test and start it after the test. Disable_framework *bool } func init() { Loading Loading @@ -313,7 +316,13 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) { test.data = android.PathsForModuleSrc(ctx, test.Properties.Data) var configs []tradefed.Config if Bool(test.Properties.Require_root) { configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer"}) configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer", nil}) } if Bool(test.Properties.Disable_framework) { var options []tradefed.Option options = append(options, tradefed.Option{"run-command", "stop"}) options = append(options, tradefed.Option{"teardown-command", "start"}) configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RunCommandTargetPreparer", options}) } if Bool(test.testDecorator.Properties.Isolated) { configs = append(configs, tradefed.Option{"not-shardable", "true"}) Loading Loading @@ -448,7 +457,7 @@ func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Pat benchmark.data = android.PathsForModuleSrc(ctx, benchmark.Properties.Data) var configs []tradefed.Config if Bool(benchmark.Properties.Require_root) { configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer"}) configs = append(configs, tradefed.Preparer{"com.android.tradefed.targetprep.RootTargetPreparer", nil}) } benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config, benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites, configs) Loading
tradefed/autogen.go +17 −3 Original line number Diff line number Diff line Loading @@ -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") } Loading Loading @@ -73,12 +75,24 @@ func (o Option) Config() string { type Preparer struct { 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) { Loading @@ -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{ Loading