[SOONG] Not auto-generate test config if test_suite is cts

Current soong use source code's under cts as the rule for judgement.
Should change to use test_suites define instead.

Bug: 124313692
Test: m hello_world_test, make sure test config be auog-enerated.
      Modified platform_testing/tests/example/native/Android.bp
      m hello_world_test, make sure test config not be auto-generatetd.

Change-Id: I1bc5216f73329d2a82d9ff29ccbede436dd2976c
This commit is contained in:
yangbill
2019-02-13 21:45:47 +08:00
parent 1f9e90a304
commit 4f41bc2bed
5 changed files with 17 additions and 19 deletions

View File

@@ -244,7 +244,7 @@ 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)
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_config_template, test.Properties.Test_suites)
test.binaryDecorator.baseInstaller.dir = "nativetest" test.binaryDecorator.baseInstaller.dir = "nativetest"
test.binaryDecorator.baseInstaller.dir64 = "nativetest64" test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
@@ -368,7 +368,7 @@ func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps
func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) { func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
benchmark.data = ctx.ExpandSources(benchmark.Properties.Data, nil) benchmark.data = ctx.ExpandSources(benchmark.Properties.Data, nil)
benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config, benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config,
benchmark.Properties.Test_config_template) benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites)
benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName()) benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName())
benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName()) benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName())

View File

@@ -443,7 +443,7 @@ type AndroidTest struct {
func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.generateAndroidBuildActions(ctx) a.generateAndroidBuildActions(ctx)
a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath) a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config, a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites)
a.data = ctx.ExpandSources(a.testProperties.Data, nil) a.data = ctx.ExpandSources(a.testProperties.Data, nil)
} }

View File

@@ -1527,7 +1527,7 @@ type Test struct {
} }
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template) j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, j.testProperties.Test_suites)
j.data = ctx.ExpandSources(j.testProperties.Data, nil) j.data = ctx.ExpandSources(j.testProperties.Data, nil)
j.Library.GenerateAndroidBuildActions(ctx) j.Library.GenerateAndroidBuildActions(ctx)

View File

@@ -50,7 +50,7 @@ func (test *testDecorator) bootstrapperProps() []interface{} {
func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) { func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) {
test.testConfig = tradefed.AutoGenPythonBinaryHostTestConfig(ctx, test.testProperties.Test_config, test.testConfig = tradefed.AutoGenPythonBinaryHostTestConfig(ctx, test.testProperties.Test_config,
test.testProperties.Test_config_template) test.testProperties.Test_config_template, test.binaryDecorator.binaryProperties.Test_suites)
test.binaryDecorator.pythonInstaller.dir = "nativetest" test.binaryDecorator.pythonInstaller.dir = "nativetest"
test.binaryDecorator.pythonInstaller.dir64 = "nativetest64" test.binaryDecorator.pythonInstaller.dir64 = "nativetest64"

View File

@@ -15,8 +15,6 @@
package tradefed package tradefed
import ( import (
"strings"
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong/android" "android/soong/android"
@@ -40,10 +38,10 @@ var autogenTestConfig = pctx.StaticRule("autogenTestConfig", blueprint.RuleParam
CommandDeps: []string{"$template"}, CommandDeps: []string{"$template"},
}, "name", "template") }, "name", "template")
func testConfigPath(ctx android.ModuleContext, prop *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 {
return p, nil return p, nil
} else if !strings.HasPrefix(ctx.ModuleDir(), "cts/") { } else if !android.InList("cts", testSuites) {
outputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".config") outputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".config")
return nil, outputFile return nil, outputFile
} else { } else {
@@ -67,8 +65,8 @@ func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, tem
} }
func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string, func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
testConfigTemplateProp *string) android.Path { testConfigTemplateProp *string, testSuites []string) android.Path {
path, autogenPath := testConfigPath(ctx, testConfigProp) 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() {
@@ -86,8 +84,8 @@ func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
} }
func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp *string, func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp *string,
testConfigTemplateProp *string) android.Path { testConfigTemplateProp *string, testSuites []string) android.Path {
path, autogenPath := testConfigPath(ctx, testConfigProp) 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() {
@@ -100,8 +98,8 @@ func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp
return path return path
} }
func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string) android.Path { func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string, testSuites []string) android.Path {
path, autogenPath := testConfigPath(ctx, testConfigProp) 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() {
@@ -119,9 +117,9 @@ func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, te
} }
func AutoGenPythonBinaryHostTestConfig(ctx android.ModuleContext, testConfigProp *string, func AutoGenPythonBinaryHostTestConfig(ctx android.ModuleContext, testConfigProp *string,
testConfigTemplateProp *string) android.Path { testConfigTemplateProp *string, testSuites []string) android.Path {
path, autogenPath := testConfigPath(ctx, testConfigProp) 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() {
@@ -143,8 +141,8 @@ var autogenInstrumentationTest = pctx.StaticRule("autogenInstrumentationTest", b
}, },
}, "name", "template") }, "name", "template")
func AutoGenInstrumentationTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string, manifest android.Path) android.Path { func AutoGenInstrumentationTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string, manifest android.Path, testSuites []string) android.Path {
path, autogenPath := testConfigPath(ctx, testConfigProp) path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites)
if autogenPath != nil { if autogenPath != nil {
template := "${InstrumentationTestConfigTemplate}" template := "${InstrumentationTestConfigTemplate}"
moduleTemplate := getTestConfigTemplate(ctx, testConfigTemplateProp) moduleTemplate := getTestConfigTemplate(ctx, testConfigTemplateProp)