Merge "Add java_test_helper_library"
This commit is contained in:
@@ -95,16 +95,21 @@ func (library *Library) AndroidMk() android.AndroidMkData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called for modules that are a component of a test suite.
|
||||||
|
func testSuiteComponent(w io.Writer, test_suites []string) {
|
||||||
|
fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
|
||||||
|
if len(test_suites) > 0 {
|
||||||
|
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
|
||||||
|
strings.Join(test_suites, " "))
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (j *Test) AndroidMk() android.AndroidMkData {
|
func (j *Test) AndroidMk() android.AndroidMkData {
|
||||||
data := j.Library.AndroidMk()
|
data := j.Library.AndroidMk()
|
||||||
data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
|
data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
|
testSuiteComponent(w, j.testProperties.Test_suites)
|
||||||
if len(j.testProperties.Test_suites) > 0 {
|
|
||||||
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
|
|
||||||
strings.Join(j.testProperties.Test_suites, " "))
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
|
|
||||||
}
|
|
||||||
if j.testConfig != nil {
|
if j.testConfig != nil {
|
||||||
fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
|
fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
|
||||||
}
|
}
|
||||||
@@ -115,6 +120,15 @@ func (j *Test) AndroidMk() android.AndroidMkData {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData {
|
||||||
|
data := j.Library.AndroidMk()
|
||||||
|
data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
|
||||||
|
testSuiteComponent(w, j.testHelperLibraryProperties.Test_suites)
|
||||||
|
})
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
func (prebuilt *Import) AndroidMk() android.AndroidMkData {
|
func (prebuilt *Import) AndroidMk() android.AndroidMkData {
|
||||||
return android.AndroidMkData{
|
return android.AndroidMkData{
|
||||||
Class: "JAVA_LIBRARIES",
|
Class: "JAVA_LIBRARIES",
|
||||||
@@ -321,13 +335,7 @@ func (a *AndroidApp) getOverriddenPackages() []string {
|
|||||||
func (a *AndroidTest) AndroidMk() android.AndroidMkData {
|
func (a *AndroidTest) AndroidMk() android.AndroidMkData {
|
||||||
data := a.AndroidApp.AndroidMk()
|
data := a.AndroidApp.AndroidMk()
|
||||||
data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
|
data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
|
testSuiteComponent(w, a.testProperties.Test_suites)
|
||||||
if len(a.testProperties.Test_suites) > 0 {
|
|
||||||
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
|
|
||||||
strings.Join(a.testProperties.Test_suites, " "))
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
|
|
||||||
}
|
|
||||||
if a.testConfig != nil {
|
if a.testConfig != nil {
|
||||||
fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
|
fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
|
||||||
}
|
}
|
||||||
@@ -340,13 +348,7 @@ func (a *AndroidTest) AndroidMk() android.AndroidMkData {
|
|||||||
func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
|
func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
|
||||||
data := a.AndroidApp.AndroidMk()
|
data := a.AndroidApp.AndroidMk()
|
||||||
data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
|
data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
|
testSuiteComponent(w, a.appTestHelperAppProperties.Test_suites)
|
||||||
if len(a.appTestHelperAppProperties.Test_suites) > 0 {
|
|
||||||
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
|
|
||||||
strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
32
java/java.go
32
java/java.go
@@ -41,6 +41,7 @@ func init() {
|
|||||||
android.RegisterModuleType("java_binary", BinaryFactory)
|
android.RegisterModuleType("java_binary", BinaryFactory)
|
||||||
android.RegisterModuleType("java_binary_host", BinaryHostFactory)
|
android.RegisterModuleType("java_binary_host", BinaryHostFactory)
|
||||||
android.RegisterModuleType("java_test", TestFactory)
|
android.RegisterModuleType("java_test", TestFactory)
|
||||||
|
android.RegisterModuleType("java_test_helper_library", TestHelperLibraryFactory)
|
||||||
android.RegisterModuleType("java_test_host", TestHostFactory)
|
android.RegisterModuleType("java_test_host", TestHostFactory)
|
||||||
android.RegisterModuleType("java_import", ImportFactory)
|
android.RegisterModuleType("java_import", ImportFactory)
|
||||||
android.RegisterModuleType("java_import_host", ImportFactoryHost)
|
android.RegisterModuleType("java_import_host", ImportFactoryHost)
|
||||||
@@ -1536,6 +1537,12 @@ type testProperties struct {
|
|||||||
Data []string `android:"path"`
|
Data []string `android:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type testHelperLibraryProperties struct {
|
||||||
|
// list of compatibility suites (for example "cts", "vts") that the module should be
|
||||||
|
// installed into.
|
||||||
|
Test_suites []string `android:"arch_variant"`
|
||||||
|
}
|
||||||
|
|
||||||
type Test struct {
|
type Test struct {
|
||||||
Library
|
Library
|
||||||
|
|
||||||
@@ -1545,6 +1552,12 @@ type Test struct {
|
|||||||
data android.Paths
|
data android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TestHelperLibrary struct {
|
||||||
|
Library
|
||||||
|
|
||||||
|
testHelperLibraryProperties testHelperLibraryProperties
|
||||||
|
}
|
||||||
|
|
||||||
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.testProperties.Test_suites)
|
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, j.testProperties.Test_suites)
|
||||||
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
|
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
|
||||||
@@ -1552,6 +1565,10 @@ func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
j.Library.GenerateAndroidBuildActions(ctx)
|
j.Library.GenerateAndroidBuildActions(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
j.Library.GenerateAndroidBuildActions(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
// java_test builds a and links sources into a `.jar` file for the device, and possibly for the host as well, and
|
// java_test builds a and links sources into a `.jar` file for the device, and possibly for the host as well, and
|
||||||
// creates an `AndroidTest.xml` file to allow running the test with `atest` or a `TEST_MAPPING` file.
|
// creates an `AndroidTest.xml` file to allow running the test with `atest` or a `TEST_MAPPING` file.
|
||||||
//
|
//
|
||||||
@@ -1577,6 +1594,21 @@ func TestFactory() android.Module {
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// java_test_helper_library creates a java library and makes sure that it is added to the appropriate test suite.
|
||||||
|
func TestHelperLibraryFactory() android.Module {
|
||||||
|
module := &TestHelperLibrary{}
|
||||||
|
|
||||||
|
module.AddProperties(
|
||||||
|
&module.Module.properties,
|
||||||
|
&module.Module.deviceProperties,
|
||||||
|
&module.Module.dexpreoptProperties,
|
||||||
|
&module.Module.protoProperties,
|
||||||
|
&module.testHelperLibraryProperties)
|
||||||
|
|
||||||
|
InitJavaModule(module, android.HostAndDeviceSupported)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
// java_test_host builds a and links sources into a `.jar` file for the host, and creates an `AndroidTest.xml` file to
|
// java_test_host builds a and links sources into a `.jar` file for the host, and creates an `AndroidTest.xml` file to
|
||||||
// allow running the test with `atest` or a `TEST_MAPPING` file.
|
// allow running the test with `atest` or a `TEST_MAPPING` file.
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user