From cfb0f5e102e2a4a946c4f6e38d429b132ed11fc5 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 24 Sep 2021 15:47:17 -0700 Subject: [PATCH] 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 --- cc/androidmk.go | 2 ++ cc/test.go | 3 +++ java/androidmk.go | 13 +++++++------ java/app.go | 3 +++ java/java.go | 6 ++++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/cc/androidmk.go b/cc/androidmk.go index cd52363e8..243efe60c 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -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) diff --git a/cc/test.go b/cc/test.go index 047a69e3e..4328628d4 100644 --- a/cc/test.go +++ b/cc/test.go @@ -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() { diff --git a/java/androidmk.go b/java/androidmk.go index 1914595dc..0f1a1ec14 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -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 diff --git a/java/app.go b/java/app.go index 2fd646322..bc0f488d0 100755 --- a/java/app.go +++ b/java/app.go @@ -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 { diff --git a/java/java.go b/java/java.go index 94c12bdbb..655d51f94 100644 --- a/java/java.go +++ b/java/java.go @@ -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 {