Support test runnner option in auto generated test configs
Bug: 284179405 Bug: 236980335 Test: unittest Change-Id: Ifae3d556ff79153ca6c3067347fc259b665fb2e1
This commit is contained in:
@@ -40,9 +40,9 @@ func getTestConfig(ctx android.ModuleContext, prop *string) android.Path {
|
||||
}
|
||||
|
||||
var autogenTestConfig = pctx.StaticRule("autogenTestConfig", blueprint.RuleParams{
|
||||
Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_CONFIGS}&'${extraConfigs}'&g;s&{OUTPUT_FILENAME}&'${outputFileName}'&g;s&{TEST_INSTALL_BASE}&'${testInstallBase}'&g' $template > $out",
|
||||
Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_CONFIGS}&'${extraConfigs}'&g;s&{EXTRA_TEST_RUNNER_CONFIGS}&'${extraTestRunnerConfigs}'&g;s&{OUTPUT_FILENAME}&'${outputFileName}'&g;s&{TEST_INSTALL_BASE}&'${testInstallBase}'&g' $template > $out",
|
||||
CommandDeps: []string{"$template"},
|
||||
}, "name", "template", "extraConfigs", "outputFileName", "testInstallBase")
|
||||
}, "name", "template", "extraConfigs", "outputFileName", "testInstallBase", "extraTestRunnerConfigs")
|
||||
|
||||
func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string, autoGenConfig *bool, testConfigTemplateProp *string) (path android.Path, autogenPath android.WritablePath) {
|
||||
p := getTestConfig(ctx, prop)
|
||||
@@ -107,7 +107,7 @@ func (ob Object) Config() string {
|
||||
|
||||
}
|
||||
|
||||
func autogenTemplate(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string, testInstallBase string) {
|
||||
func autogenTemplate(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, testRunnerConfigs []Option, outputFileName string, testInstallBase string) {
|
||||
if template == "" {
|
||||
ctx.ModuleErrorf("Empty template")
|
||||
}
|
||||
@@ -118,16 +118,27 @@ func autogenTemplate(ctx android.ModuleContext, name string, output android.Writ
|
||||
extraConfigs := strings.Join(configStrings, fmt.Sprintf("\\n%s", test_xml_indent))
|
||||
extraConfigs = proptools.NinjaAndShellEscape(extraConfigs)
|
||||
|
||||
var testRunnerConfigStrings []string
|
||||
for _, config := range testRunnerConfigs {
|
||||
testRunnerConfigStrings = append(testRunnerConfigStrings, config.Config())
|
||||
}
|
||||
extraTestRunnerConfigs := strings.Join(testRunnerConfigStrings, fmt.Sprintf("\\n%s%s", test_xml_indent, test_xml_indent))
|
||||
if len(extraTestRunnerConfigs) > 0 {
|
||||
extraTestRunnerConfigs += fmt.Sprintf("\\n%s%s", test_xml_indent, test_xml_indent)
|
||||
}
|
||||
extraTestRunnerConfigs = proptools.NinjaAndShellEscape(extraTestRunnerConfigs)
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: autogenTestConfig,
|
||||
Description: "test config",
|
||||
Output: output,
|
||||
Args: map[string]string{
|
||||
"name": name,
|
||||
"template": template,
|
||||
"extraConfigs": extraConfigs,
|
||||
"outputFileName": outputFileName,
|
||||
"testInstallBase": testInstallBase,
|
||||
"name": name,
|
||||
"template": template,
|
||||
"extraConfigs": extraConfigs,
|
||||
"outputFileName": outputFileName,
|
||||
"testInstallBase": testInstallBase,
|
||||
"extraTestRunnerConfigs": extraTestRunnerConfigs,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -142,6 +153,7 @@ type AutoGenTestConfigOptions struct {
|
||||
TestSuites []string
|
||||
Config []Config
|
||||
OptionsForAutogenerated []Option
|
||||
TestRunnerOptions []Option
|
||||
AutoGenConfig *bool
|
||||
UnitTest *bool
|
||||
TestInstallBase string
|
||||
@@ -155,6 +167,7 @@ func AutoGenTestConfig(ctx android.ModuleContext, options AutoGenTestConfigOptio
|
||||
for _, c := range options.OptionsForAutogenerated {
|
||||
configs = append(configs, c)
|
||||
}
|
||||
testRunnerConfigs := append([]Option{}, options.TestRunnerOptions...)
|
||||
name := options.Name
|
||||
if name == "" {
|
||||
name = ctx.ModuleName()
|
||||
@@ -163,15 +176,15 @@ func AutoGenTestConfig(ctx android.ModuleContext, options AutoGenTestConfigOptio
|
||||
if autogenPath != nil {
|
||||
templatePath := getTestConfigTemplate(ctx, options.TestConfigTemplateProp)
|
||||
if templatePath.Valid() {
|
||||
autogenTemplate(ctx, name, autogenPath, templatePath.String(), configs, options.OutputFileName, options.TestInstallBase)
|
||||
autogenTemplate(ctx, name, autogenPath, templatePath.String(), configs, testRunnerConfigs, options.OutputFileName, options.TestInstallBase)
|
||||
} else {
|
||||
if ctx.Device() {
|
||||
autogenTemplate(ctx, name, autogenPath, options.DeviceTemplate, configs, options.OutputFileName, options.TestInstallBase)
|
||||
autogenTemplate(ctx, name, autogenPath, options.DeviceTemplate, configs, testRunnerConfigs, options.OutputFileName, options.TestInstallBase)
|
||||
} else {
|
||||
if Bool(options.UnitTest) {
|
||||
autogenTemplate(ctx, name, autogenPath, options.HostUnitTestTemplate, configs, options.OutputFileName, options.TestInstallBase)
|
||||
autogenTemplate(ctx, name, autogenPath, options.HostUnitTestTemplate, configs, testRunnerConfigs, options.OutputFileName, options.TestInstallBase)
|
||||
} else {
|
||||
autogenTemplate(ctx, name, autogenPath, options.HostTemplate, configs, options.OutputFileName, options.TestInstallBase)
|
||||
autogenTemplate(ctx, name, autogenPath, options.HostTemplate, configs, testRunnerConfigs, options.OutputFileName, options.TestInstallBase)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user