Implement test config auto-gen for sh_test.
Supports the following properties: - Require_root - Test_config_template - Auto_gen_config Test config template is in a separate CL. Bug: 148805488 Bug: 151761373 Test: make Test: unit tests Test: verified with bc_test & toybox-tests Change-Id: I63d60a153a6abda4ce30b74d3eb915fbf6389cb8
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' $template > $out",
|
||||
Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_CONFIGS}&'${extraConfigs}'&g;s&{OUTPUT_FILENAME}&'${outputFileName}'&g' $template > $out",
|
||||
CommandDeps: []string{"$template"},
|
||||
}, "name", "template", "extraConfigs")
|
||||
}, "name", "template", "extraConfigs", "outputFileName")
|
||||
|
||||
func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string, autoGenConfig *bool, testConfigTemplateProp *string) (path android.Path, autogenPath android.WritablePath) {
|
||||
p := getTestConfig(ctx, prop)
|
||||
@@ -108,10 +108,14 @@ func (ob Object) Config() string {
|
||||
}
|
||||
|
||||
func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config) {
|
||||
autogenTemplateWithName(ctx, ctx.ModuleName(), output, template, configs)
|
||||
autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), output, template, configs, "")
|
||||
}
|
||||
|
||||
func autogenTemplateWithName(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config) {
|
||||
autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), output, template, configs, "")
|
||||
}
|
||||
|
||||
func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string) {
|
||||
var configStrings []string
|
||||
for _, config := range configs {
|
||||
configStrings = append(configStrings, config.Config())
|
||||
@@ -124,9 +128,10 @@ func autogenTemplateWithName(ctx android.ModuleContext, name string, output andr
|
||||
Description: "test config",
|
||||
Output: output,
|
||||
Args: map[string]string{
|
||||
"name": name,
|
||||
"template": template,
|
||||
"extraConfigs": extraConfigs,
|
||||
"name": name,
|
||||
"template": template,
|
||||
"extraConfigs": extraConfigs,
|
||||
"outputFileName": outputFileName,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -150,6 +155,21 @@ func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
|
||||
return path
|
||||
}
|
||||
|
||||
func AutoGenShellTestConfig(ctx android.ModuleContext, testConfigProp *string,
|
||||
testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool, outputFileName string) android.Path {
|
||||
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
|
||||
if autogenPath != nil {
|
||||
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
|
||||
if templatePath.Valid() {
|
||||
autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, templatePath.String(), config, outputFileName)
|
||||
} else {
|
||||
autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, "${ShellTestConfigTemplate}", config, outputFileName)
|
||||
}
|
||||
return autogenPath
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp *string,
|
||||
testConfigTemplateProp *string, testSuites []string, configs []Config, autoGenConfig *bool) android.Path {
|
||||
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
|
||||
|
Reference in New Issue
Block a user