Support per-testcase directories in all test suites

There are cases where two modules try to install the same test data
into CTS, which results in collisions when CTS puts the data for all
tests in the same directory.  Add a flag that allows enabling a
per-testcase directory for an individual test for all test suites.

Bug: 193168159
Test: cts-tradefed run commandAndExit CtsBionicTestCases
Change-Id: If034723e8fe937ca71d3e2d39b7d46702e41bc8c
This commit is contained in:
Colin Cross 2021-09-24 15:47:17 -07:00
parent f3bfd02aa9
commit cfb0f5e102
5 changed files with 21 additions and 6 deletions

View file

@ -394,6 +394,8 @@ func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.
if Bool(test.Properties.Test_options.Unit_test) {
entries.SetBool("LOCAL_IS_UNIT_TEST", true)
}
entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(test.Properties.Per_testcase_directory))
})
AndroidMkWriteTestData(test.data, entries)

View file

@ -115,6 +115,9 @@ type TestBinaryProperties struct {
// Add parameterized mainline modules to auto generated test config. The options will be
// handled by TradeFed to download and install the specified modules on the device.
Test_mainline_modules []string
// Install the test into a folder named for the module in all test suites.
Per_testcase_directory *bool
}
func init() {

View file

@ -147,20 +147,21 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
}
// Called for modules that are a component of a test suite.
func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
entries.SetString("LOCAL_MODULE_TAGS", "tests")
if len(test_suites) > 0 {
entries.AddCompatibilityTestSuites(test_suites...)
} else {
entries.AddCompatibilityTestSuites("null-suite")
}
entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
}
func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := j.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
testSuiteComponent(entries, j.testProperties.Test_suites)
testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
if j.testConfig != nil {
entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
}
@ -188,7 +189,7 @@ func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := j.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
})
return entriesList
@ -450,7 +451,7 @@ func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := a.AndroidApp.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.testProperties.Test_suites)
testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
if a.testConfig != nil {
entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
}
@ -466,7 +467,7 @@ func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := a.AndroidApp.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
// introduce a flag variable to control the generation of the .config file
entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
})
@ -677,7 +678,7 @@ func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := a.AndroidAppImport.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.testProperties.Test_suites)
testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
androidMkWriteTestData(a.data, entries)
})
return entriesList

View file

@ -1070,6 +1070,9 @@ type appTestHelperAppProperties struct {
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
// explicitly.
Auto_gen_config *bool
// Install the test into a folder named for the module in all test suites.
Per_testcase_directory *bool
}
type AndroidTestHelperApp struct {

View file

@ -749,6 +749,9 @@ type testProperties struct {
// Names of modules containing JNI libraries that should be installed alongside the test.
Jni_libs []string
// Install the test into a folder named for the module in all test suites.
Per_testcase_directory *bool
}
type hostTestProperties struct {
@ -760,6 +763,9 @@ type testHelperLibraryProperties struct {
// list of compatibility suites (for example "cts", "vts") that the module should be
// installed into.
Test_suites []string `android:"arch_variant"`
// Install the test into a folder named for the module in all test suites.
Per_testcase_directory *bool
}
type prebuiltTestProperties struct {