From 70898c4006c89c1fe67251a0a4f2aa9c0eede22f Mon Sep 17 00:00:00 2001 From: Julien Desprez Date: Thu, 19 Nov 2020 09:43:45 -0800 Subject: [PATCH] Use java host unit tests template for unit tests Test: make aoa-helper-tests Bug: 172961860 Change-Id: I2eaee277961f29adfd22e7c65248c9403bd69b81 --- java/java.go | 4 ++-- tradefed/autogen.go | 8 ++++++-- tradefed/config.go | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/java/java.go b/java/java.go index a23c649c1..76f9ba2a6 100644 --- a/java/java.go +++ b/java/java.go @@ -2325,7 +2325,7 @@ func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) { func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, - j.testProperties.Test_suites, j.testProperties.Auto_gen_config) + j.testProperties.Test_suites, j.testProperties.Auto_gen_config, j.testProperties.Test_options.Unit_test) j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data) @@ -2344,7 +2344,7 @@ func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContex func (j *JavaTestImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.prebuiltTestProperties.Test_config, nil, - j.prebuiltTestProperties.Test_suites, nil) + j.prebuiltTestProperties.Test_suites, nil, nil) j.Import.GenerateAndroidBuildActions(ctx) } diff --git a/tradefed/autogen.go b/tradefed/autogen.go index b35f831c7..27d71e828 100644 --- a/tradefed/autogen.go +++ b/tradefed/autogen.go @@ -188,7 +188,7 @@ func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp } func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string, - testSuites []string, autoGenConfig *bool) android.Path { + testSuites []string, autoGenConfig *bool, unitTest *bool) android.Path { path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp) if autogenPath != nil { templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp) @@ -198,7 +198,11 @@ func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, te if ctx.Device() { autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}", nil, "") } else { - autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", nil, "") + if Bool(unitTest) { + autogenTemplate(ctx, autogenPath, "${JavaHostUnitTestConfigTemplate}", nil, "") + } else { + autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", nil, "") + } } } return autogenPath diff --git a/tradefed/config.go b/tradefed/config.go index f7e834988..f3566a80d 100644 --- a/tradefed/config.go +++ b/tradefed/config.go @@ -27,6 +27,7 @@ func init() { pctx.SourcePathVariable("InstrumentationTestConfigTemplate", "build/make/core/instrumentation_test_config_template.xml") pctx.SourcePathVariable("JavaTestConfigTemplate", "build/make/core/java_test_config_template.xml") pctx.SourcePathVariable("JavaHostTestConfigTemplate", "build/make/core/java_host_test_config_template.xml") + pctx.SourcePathVariable("JavaHostUnitTestConfigTemplate", "build/make/core/java_host_unit_test_config_template.xml") pctx.SourcePathVariable("NativeBenchmarkTestConfigTemplate", "build/make/core/native_benchmark_test_config_template.xml") pctx.SourcePathVariable("NativeHostTestConfigTemplate", "build/make/core/native_host_test_config_template.xml") pctx.SourcePathVariable("NativeTestConfigTemplate", "build/make/core/native_test_config_template.xml")