Autogenerate some extra_options based on some build properties
If an Android.bp specifies Isolated=true, make sure it's tagged as not-shardable, since b/126376458 is not resolved. Test: make bionic-benchmarks-tests (with and without isolated=true) Bug: 124024827 Change-Id: I2210c15b84f9b30e1cc23b426d463b34cf9ef94f
This commit is contained in:
@@ -243,8 +243,13 @@ 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) {
|
||||||
test.data = ctx.ExpandSources(test.Properties.Data, nil)
|
test.data = ctx.ExpandSources(test.Properties.Data, nil)
|
||||||
|
optionsMap := map[string]string{}
|
||||||
|
if Bool(test.testDecorator.Properties.Isolated) {
|
||||||
|
optionsMap["not-shardable"] = "true"
|
||||||
|
}
|
||||||
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)
|
test.Properties.Test_config_template,
|
||||||
|
test.Properties.Test_suites, optionsMap)
|
||||||
|
|
||||||
test.binaryDecorator.baseInstaller.dir = "nativetest"
|
test.binaryDecorator.baseInstaller.dir = "nativetest"
|
||||||
test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
|
test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
|
||||||
|
@@ -15,7 +15,12 @@
|
|||||||
package tradefed
|
package tradefed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
@@ -34,9 +39,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' $template > $out",
|
Command: "sed 's&{MODULE}&${name}&g;s&{EXTRA_OPTIONS}&'${extraOptions}'&g' $template > $out",
|
||||||
CommandDeps: []string{"$template"},
|
CommandDeps: []string{"$template"},
|
||||||
}, "name", "template")
|
}, "name", "template", "extraOptions")
|
||||||
|
|
||||||
func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string) (path android.Path, autogenPath android.WritablePath) {
|
func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string) (path android.Path, autogenPath android.WritablePath) {
|
||||||
if p := getTestConfig(ctx, prop); p != nil {
|
if p := getTestConfig(ctx, prop); p != nil {
|
||||||
@@ -52,7 +57,18 @@ func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string) {
|
func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, optionsMap map[string]string) {
|
||||||
|
// If no test option found, delete {EXTRA_OPTIONS} line.
|
||||||
|
var options []string
|
||||||
|
for optionName, value := range optionsMap {
|
||||||
|
if value != "" {
|
||||||
|
options = append(options, fmt.Sprintf(`<option name="%s" value="%s" />`, optionName, value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort.Strings(options)
|
||||||
|
extraOptions := strings.Join(options, "\n ")
|
||||||
|
extraOptions = proptools.NinjaAndShellEscape([]string{extraOptions})[0]
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: autogenTestConfig,
|
Rule: autogenTestConfig,
|
||||||
Description: "test config",
|
Description: "test config",
|
||||||
@@ -60,22 +76,26 @@ func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, tem
|
|||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"name": ctx.ModuleName(),
|
"name": ctx.ModuleName(),
|
||||||
"template": template,
|
"template": template,
|
||||||
|
"extraOptions": extraOptions,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
|
func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
|
||||||
testConfigTemplateProp *string, testSuites []string) android.Path {
|
testConfigTemplateProp *string, testSuites []string,
|
||||||
|
optionsMap map[string]string) android.Path {
|
||||||
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
|
path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
|
||||||
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())
|
autogenTemplate(ctx, autogenPath, templatePath.String(), optionsMap)
|
||||||
} else {
|
} else {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
autogenTemplate(ctx, autogenPath, "${NativeTestConfigTemplate}")
|
autogenTemplate(ctx, autogenPath, "${NativeTestConfigTemplate}",
|
||||||
|
optionsMap)
|
||||||
} else {
|
} else {
|
||||||
autogenTemplate(ctx, autogenPath, "${NativeHostTestConfigTemplate}")
|
autogenTemplate(ctx, autogenPath, "${NativeHostTestConfigTemplate}",
|
||||||
|
optionsMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return autogenPath
|
return autogenPath
|
||||||
@@ -89,9 +109,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())
|
autogenTemplate(ctx, autogenPath, templatePath.String(), nil)
|
||||||
} else {
|
} else {
|
||||||
autogenTemplate(ctx, autogenPath, "${NativeBenchmarkTestConfigTemplate}")
|
autogenTemplate(ctx, autogenPath, "${NativeBenchmarkTestConfigTemplate}", nil)
|
||||||
}
|
}
|
||||||
return autogenPath
|
return autogenPath
|
||||||
}
|
}
|
||||||
@@ -103,12 +123,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())
|
autogenTemplate(ctx, autogenPath, templatePath.String(), nil)
|
||||||
} else {
|
} else {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}")
|
autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}", nil)
|
||||||
} else {
|
} else {
|
||||||
autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}")
|
autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return autogenPath
|
return autogenPath
|
||||||
@@ -123,9 +143,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())
|
autogenTemplate(ctx, autogenPath, templatePath.String(), nil)
|
||||||
} else {
|
} else {
|
||||||
autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}")
|
autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}", nil)
|
||||||
}
|
}
|
||||||
return autogenPath
|
return autogenPath
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user