diff options
-rw-r--r-- | cc/test.go | 5 | ||||
-rw-r--r-- | java/java.go | 5 | ||||
-rw-r--r-- | java/java_test.go | 24 | ||||
-rw-r--r-- | tradefed/autogen.go | 37 |
4 files changed, 59 insertions, 12 deletions
diff --git a/cc/test.go b/cc/test.go index 27de06b07..3f5f71007 100644 --- a/cc/test.go +++ b/cc/test.go @@ -70,6 +70,10 @@ type TestOptions struct { // Add MinApiLevelModuleController with ro.vndk.version property. If ro.vndk.version has an // integer value and the value is less than the min_vndk_version, skip this module. Min_vndk_version *int64 + + // Extra <option> tags to add to the auto generated test xml file under the test runner, e.g., GTest. + // The "key" is optional in each of these. + Test_runner_options []tradefed.Option } type TestBinaryProperties struct { @@ -398,6 +402,7 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) { TestConfigTemplateProp: test.Properties.Test_config_template, TestSuites: test.testDecorator.InstallerProperties.Test_suites, Config: configs, + TestRunnerOptions: test.Properties.Test_options.Test_runner_options, AutoGenConfig: test.Properties.Auto_gen_config, TestInstallBase: testInstallBase, DeviceTemplate: "${NativeTestConfigTemplate}", diff --git a/java/java.go b/java/java.go index 683e54682..0eb251815 100644 --- a/java/java.go +++ b/java/java.go @@ -931,6 +931,10 @@ type TestOptions struct { // Extra <option> tags to add to the auto generated test xml file. The "key" // is optional in each of these. Tradefed_options []tradefed.Option + + // Extra <option> tags to add to the auto generated test xml file under the test runner, e.g., AndroidJunitTest. + // The "key" is optional in each of these. + Test_runner_options []tradefed.Option } type testProperties struct { @@ -1213,6 +1217,7 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, TestSuites: j.testProperties.Test_suites, Config: configs, OptionsForAutogenerated: j.testProperties.Test_options.Tradefed_options, + TestRunnerOptions: j.testProperties.Test_options.Test_runner_options, AutoGenConfig: j.testProperties.Auto_gen_config, UnitTest: j.testProperties.Test_options.Unit_test, DeviceTemplate: "${JavaTestConfigTemplate}", diff --git a/java/java_test.go b/java/java_test.go index 2a4913ecd..0c002f385 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2275,3 +2275,27 @@ java_test_host { t.Errorf("Expected args[\"extraConfigs\"] to equal %q, was %q", expected, args["extraConfigs"]) } } + +func TestTestRunnerOptions(t *testing.T) { + result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, ` +java_test_host { + name: "foo", + test_options: { + test_runner_options: [ + { + name: "test-timeout", + value: "10m" + } + ] + } +} +`) + + buildOS := result.Config.BuildOS.String() + args := result.ModuleForTests("foo", buildOS+"_common"). + Output("out/soong/.intermediates/foo/" + buildOS + "_common/foo.config").Args + expected := proptools.NinjaAndShellEscape("<option name=\"test-timeout\" value=\"10m\" />\\n ") + if args["extraTestRunnerConfigs"] != expected { + t.Errorf("Expected args[\"extraTestRunnerConfigs\"] to equal %q, was %q", expected, args["extraTestRunnerConfigs"]) + } +} diff --git a/tradefed/autogen.go b/tradefed/autogen.go index 49b09afea..3c55c51e1 100644 --- a/tradefed/autogen.go +++ b/tradefed/autogen.go @@ -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) } } } |