From e146e39fa6852d66f20c6140784086ce23858e84 Mon Sep 17 00:00:00 2001 From: Julien Desprez Date: Thu, 2 Aug 2018 15:00:46 -0700 Subject: [PATCH] Support 'test_config' into soong modules Test: make general-tests Bug: 110982517 Change-Id: Ib2eab2653fdfce6f699b85c9fbc64558b6d40363 --- cc/androidmk.go | 8 ++++++++ cc/test.go | 10 +++++++++- java/androidmk.go | 8 ++++++++ java/java.go | 4 ++++ python/androidmk.go | 5 +++++ python/test.go | 12 ++++++++++++ 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/cc/androidmk.go b/cc/androidmk.go index 263f0f3b9..228b64af7 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -248,6 +248,10 @@ func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *androi fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", strings.Join(benchmark.Properties.Test_suites, " ")) } + if benchmark.Properties.Test_config != nil { + fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=", + benchmark.Properties.Test_config) + } fmt.Fprintln(w, "LOCAL_NATIVE_BENCHMARK := true") }) @@ -266,6 +270,10 @@ func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", strings.Join(test.Properties.Test_suites, " ")) } + if test.Properties.Test_config != nil { + fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=", + test.Properties.Test_config) + } }) androidMkWriteTestData(test.data, ctx, ret) diff --git a/cc/test.go b/cc/test.go index 5d0ef20b7..49fc57b58 100644 --- a/cc/test.go +++ b/cc/test.go @@ -44,6 +44,10 @@ type TestBinaryProperties struct { // list of compatibility suites (for example "cts", "vts") that the module should be // installed into. Test_suites []string `android:"arch_variant"` + + // the name of the test configuration (for example "AndroidTest.xml") that should be + // installed with the module. + Test_config *string `android:"arch_variant"` } func init() { @@ -304,7 +308,11 @@ type BenchmarkProperties struct { // list of compatibility suites (for example "cts", "vts") that the module should be // installed into. - Test_suites []string + Test_suites []string `android:"arch_variant"` + + // the name of the test configuration (for example "AndroidTest.xml") that should be + // installed with the module. + Test_config *string `android:"arch_variant"` } type benchmarkDecorator struct { diff --git a/java/androidmk.go b/java/androidmk.go index 40711f627..14e9fec92 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -107,6 +107,10 @@ func (j *Test) AndroidMk() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", strings.Join(j.testProperties.Test_suites, " ")) } + if j.testProperties.Test_config != nil { + fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=", + *j.testProperties.Test_config) + } }) return data @@ -241,6 +245,10 @@ func (a *AndroidTest) AndroidMk() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", strings.Join(a.testProperties.Test_suites, " ")) } + if a.testProperties.Test_config != nil { + fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=", + *a.testProperties.Test_config) + } }) return data diff --git a/java/java.go b/java/java.go index 38c89f4c8..700b91748 100644 --- a/java/java.go +++ b/java/java.go @@ -1352,6 +1352,10 @@ type testProperties struct { // list of compatibility suites (for example "cts", "vts") that the module should be // installed into. Test_suites []string `android:"arch_variant"` + + // the name of the test configuration (for example "AndroidTest.xml") that should be + // installed with the module. + Test_config *string `android:"arch_variant"` } type Test struct { diff --git a/python/androidmk.go b/python/androidmk.go index 365b422f5..20861cb8e 100644 --- a/python/androidmk.go +++ b/python/androidmk.go @@ -66,6 +66,11 @@ func (p *testDecorator) AndroidMk(base *Module, ret *android.AndroidMkData) { fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", strings.Join(p.binaryDecorator.binaryProperties.Test_suites, " ")) } + // If the test config has an explicit config specified use it. + if p.testProperties.Test_config != nil { + fmt.Fprintln(w, "LOCAL_TEST_CONFIG :=", + *p.testProperties.Test_config) + } }) base.subAndroidMk(ret, p.binaryDecorator.pythonInstaller) } diff --git a/python/test.go b/python/test.go index 825e63cc4..39326f06e 100644 --- a/python/test.go +++ b/python/test.go @@ -25,8 +25,20 @@ func init() { android.RegisterModuleType("python_test", PythonTestFactory) } +type TestProperties struct { + // the name of the test configuration (for example "AndroidTest.xml") that should be + // installed with the module. + Test_config *string `android:"arch_variant"` +} + type testDecorator struct { *binaryDecorator + + testProperties TestProperties +} + +func (test *testDecorator) bootstrapperProps() []interface{} { + return append(test.binaryDecorator.bootstrapperProps(), &test.testProperties) } func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) {