Merge "AutoGen: Support NativeTest with vendor namespace."

This commit is contained in:
Treehugger Robot 2020-09-03 02:26:11 +00:00 committed by Gerrit Code Review
commit 52ddbe25f9
2 changed files with 38 additions and 30 deletions

View File

@ -344,6 +344,12 @@ func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
} }
func (test *testBinary) install(ctx ModuleContext, file android.Path) { func (test *testBinary) install(ctx ModuleContext, file android.Path) {
// TODO: (b/167308193) Switch to /data/local/tests/unrestricted as the default install base.
testInstallBase := "/data/local/tmp"
if ctx.inVendor() || ctx.useVndk() {
testInstallBase = "/data/local/tests/vendor"
}
dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data) dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data)
for _, dataSrcPath := range dataSrcPaths { for _, dataSrcPath := range dataSrcPaths {
@ -411,7 +417,7 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
} }
test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config, test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config) test.Properties.Test_config_template, test.Properties.Test_suites, configs, test.Properties.Auto_gen_config, testInstallBase)
test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs) test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs)

View File

@ -40,9 +40,9 @@ func getTestConfig(ctx android.ModuleContext, prop *string) android.Path {
} }
var autogenTestConfig = pctx.StaticRule("autogenTestConfig", blueprint.RuleParams{ var autogenTestConfig = pctx.StaticRule("autogenTestConfig", blueprint.RuleParams{
Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_CONFIGS}&'${extraConfigs}'&g;s&{OUTPUT_FILENAME}&'${outputFileName}'&g' $template > $out", Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_CONFIGS}&'${extraConfigs}'&g;s&{OUTPUT_FILENAME}&'${outputFileName}'&g;s&{TEST_INSTALL_BASE}&'${testInstallBase}'&g' $template > $out",
CommandDeps: []string{"$template"}, CommandDeps: []string{"$template"},
}, "name", "template", "extraConfigs", "outputFileName") }, "name", "template", "extraConfigs", "outputFileName", "testInstallBase")
func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string, autoGenConfig *bool, testConfigTemplateProp *string) (path android.Path, autogenPath android.WritablePath) { func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string, autoGenConfig *bool, testConfigTemplateProp *string) (path android.Path, autogenPath android.WritablePath) {
p := getTestConfig(ctx, prop) p := getTestConfig(ctx, prop)
@ -107,15 +107,15 @@ func (ob Object) Config() string {
} }
func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config) { func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config, testInstallBase string) {
autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), output, template, configs, "") autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), output, template, configs, "", testInstallBase)
} }
func autogenTemplateWithName(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config) { func autogenTemplateWithName(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, testInstallBase string) {
autogenTemplateWithNameAndOutputFile(ctx, name, output, template, configs, "") autogenTemplateWithNameAndOutputFile(ctx, name, output, template, configs, "", testInstallBase)
} }
func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string) { func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string, testInstallBase string) {
var configStrings []string var configStrings []string
for _, config := range configs { for _, config := range configs {
configStrings = append(configStrings, config.Config()) configStrings = append(configStrings, config.Config())
@ -128,26 +128,28 @@ func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string
Description: "test config", Description: "test config",
Output: output, Output: output,
Args: map[string]string{ Args: map[string]string{
"name": name, "name": name,
"template": template, "template": template,
"extraConfigs": extraConfigs, "extraConfigs": extraConfigs,
"outputFileName": outputFileName, "outputFileName": outputFileName,
"testInstallBase": testInstallBase,
}, },
}) })
} }
func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string, func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool) android.Path { testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool, testInstallBase string) android.Path {
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp) path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
if autogenPath != nil { if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() { if templatePath.Valid() {
autogenTemplate(ctx, autogenPath, templatePath.String(), config) autogenTemplate(ctx, autogenPath, templatePath.String(), config, testInstallBase)
} else { } else {
if ctx.Device() { if ctx.Device() {
autogenTemplate(ctx, autogenPath, "${NativeTestConfigTemplate}", config) autogenTemplate(ctx, autogenPath, "${NativeTestConfigTemplate}", config, testInstallBase)
} else { } else {
autogenTemplate(ctx, autogenPath, "${NativeHostTestConfigTemplate}", config) autogenTemplate(ctx, autogenPath, "${NativeHostTestConfigTemplate}", config, testInstallBase)
} }
} }
return autogenPath return autogenPath
@ -161,9 +163,9 @@ func AutoGenShellTestConfig(ctx android.ModuleContext, testConfigProp *string,
if autogenPath != nil { if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() { if templatePath.Valid() {
autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, templatePath.String(), config, outputFileName) autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, templatePath.String(), config, outputFileName, "")
} else { } else {
autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, "${ShellTestConfigTemplate}", config, outputFileName) autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, "${ShellTestConfigTemplate}", config, outputFileName, "")
} }
return autogenPath return autogenPath
} }
@ -176,9 +178,9 @@ func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp
if autogenPath != nil { if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() { if templatePath.Valid() {
autogenTemplate(ctx, autogenPath, templatePath.String(), configs) autogenTemplate(ctx, autogenPath, templatePath.String(), configs, "")
} else { } else {
autogenTemplate(ctx, autogenPath, "${NativeBenchmarkTestConfigTemplate}", configs) autogenTemplate(ctx, autogenPath, "${NativeBenchmarkTestConfigTemplate}", configs, "")
} }
return autogenPath return autogenPath
} }
@ -191,12 +193,12 @@ func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, te
if autogenPath != nil { if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() { if templatePath.Valid() {
autogenTemplate(ctx, autogenPath, templatePath.String(), nil) autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
} else { } else {
if ctx.Device() { if ctx.Device() {
autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}", nil) autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}", nil, "")
} else { } else {
autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", nil) autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", nil, "")
} }
} }
return autogenPath return autogenPath
@ -211,9 +213,9 @@ func AutoGenPythonBinaryHostTestConfig(ctx android.ModuleContext, testConfigProp
if autogenPath != nil { if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() { if templatePath.Valid() {
autogenTemplate(ctx, autogenPath, templatePath.String(), nil) autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
} else { } else {
autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}", nil) autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}", nil, "")
} }
return autogenPath return autogenPath
} }
@ -226,12 +228,12 @@ func AutoGenRustTestConfig(ctx android.ModuleContext, testConfigProp *string,
if autogenPath != nil { if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() { if templatePath.Valid() {
autogenTemplate(ctx, autogenPath, templatePath.String(), config) autogenTemplate(ctx, autogenPath, templatePath.String(), config, "")
} else { } else {
if ctx.Device() { if ctx.Device() {
autogenTemplate(ctx, autogenPath, "${RustDeviceTestConfigTemplate}", config) autogenTemplate(ctx, autogenPath, "${RustDeviceTestConfigTemplate}", config, "")
} else { } else {
autogenTemplate(ctx, autogenPath, "${RustHostTestConfigTemplate}", config) autogenTemplate(ctx, autogenPath, "${RustHostTestConfigTemplate}", config, "")
} }
} }
return autogenPath return autogenPath
@ -245,9 +247,9 @@ func AutoGenRobolectricTestConfig(ctx android.ModuleContext, testConfigProp *str
if autogenPath != nil { if autogenPath != nil {
templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
if templatePath.Valid() { if templatePath.Valid() {
autogenTemplate(ctx, autogenPath, templatePath.String(), nil) autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
} else { } else {
autogenTemplate(ctx, autogenPath, "${RobolectricTestConfigTemplate}", nil) autogenTemplate(ctx, autogenPath, "${RobolectricTestConfigTemplate}", nil, "")
} }
return autogenPath return autogenPath
} }