From eb7398ea79b5a480c46ae0c3bba87ba3e1953fdc Mon Sep 17 00:00:00 2001 From: Julien Desprez Date: Thu, 28 Feb 2019 08:45:28 -0800 Subject: [PATCH] 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 --- cc/test.go | 7 +++++- tradefed/autogen.go | 52 +++++++++++++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/cc/test.go b/cc/test.go index e9f0944ca..8e49fac4e 100644 --- a/cc/test.go +++ b/cc/test.go @@ -243,8 +243,13 @@ func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags { func (test *testBinary) install(ctx ModuleContext, file android.Path) { 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.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.dir64 = "nativetest64" diff --git a/tradefed/autogen.go b/tradefed/autogen.go index cfa7164bb..6d9c2003e 100644 --- a/tradefed/autogen.go +++ b/tradefed/autogen.go @@ -15,7 +15,12 @@ package tradefed import ( + "fmt" + "sort" + "strings" + "github.com/google/blueprint" + "github.com/google/blueprint/proptools" "android/soong/android" ) @@ -34,9 +39,9 @@ func getTestConfig(ctx android.ModuleContext, prop *string) android.Path { } 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"}, -}, "name", "template") +}, "name", "template", "extraOptions") func testConfigPath(ctx android.ModuleContext, prop *string, testSuites []string) (path android.Path, autogenPath android.WritablePath) { if p := getTestConfig(ctx, prop); p != nil { @@ -52,30 +57,45 @@ 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(`