Auto-generate test config from template
This change fixes the way the test configs for CTS/VTS/GTS variants are
generated. Instead of using a custom genrule, we now use the
test_config_template and tradefed_options properties to instantiate test
configs from the template.
Also add a new variant for GTS.
Bug: 380801348
Test: build
Change-Id: I1a3a335ec340ac05da0f8cbc962879c25b3cabd4
Merged-In: I1a3a335ec340ac05da0f8cbc962879c25b3cabd4
diff --git a/tests/hostside/Android.bp b/tests/hostside/Android.bp
index f83b293..f78f41a 100644
--- a/tests/hostside/Android.bp
+++ b/tests/hostside/Android.bp
@@ -57,7 +57,8 @@
java_test_host {
name: "MicrodroidHostTestCases",
defaults: ["MicrodroidHostTestCases.default"],
- test_config: "AndroidTest.xml",
+ test_config_template: "AndroidTestTemplate.xml",
+ auto_gen_config: true,
test_suites: [
"general-tests",
"pts",
@@ -69,8 +70,21 @@
java_test_host {
name: "MicrodroidHostTestCases.CTS",
defaults: ["MicrodroidHostTestCases.default"],
- test_config: ":MicrodroidHostTestCases.CTS.config",
+ test_config_template: "AndroidTestTemplate.xml",
test_suites: ["cts"],
+ auto_gen_config: true,
+ test_options: {
+ tradefed_options: [
+ {
+ name: "include-annotation",
+ value: "com.android.compatibility.common.util.CddTest",
+ },
+ {
+ name: "test-suite-tag",
+ value: "cts",
+ },
+ ],
+ },
data: DEVICE_DATA,
data_native_bins: BINS,
}
@@ -78,8 +92,21 @@
java_test_host {
name: "MicrodroidHostTestCases.VTS",
defaults: ["MicrodroidHostTestCases.default"],
- test_config: ":MicrodroidHostTestCases.VTS.config",
+ test_config_template: "AndroidTestTemplate.xml",
test_suites: ["vts"],
+ auto_gen_config: true,
+ test_options: {
+ tradefed_options: [
+ {
+ name: "include-annotation",
+ value: "com.android.compatibility.common.util.VsrTest",
+ },
+ {
+ name: "test-suite-tag",
+ value: "vts",
+ },
+ ],
+ },
data: DEVICE_DATA,
data_native_bins: BINS,
}
@@ -87,41 +114,21 @@
java_test_host {
name: "MicrodroidHostTestCases.GTS",
defaults: ["MicrodroidHostTestCases.default"],
- test_config: ":MicrodroidHostTestCases.GTS.config",
+ test_config_template: "AndroidTestTemplate.xml",
test_suites: ["gts"],
+ auto_gen_config: true,
+ test_options: {
+ tradefed_options: [
+ {
+ name: "include-annotation",
+ value: "com.android.compatibility.common.util.GmsTest",
+ },
+ {
+ name: "test-suite-tag",
+ value: "gts",
+ },
+ ],
+ },
data: DEVICE_DATA,
data_native_bins: BINS,
}
-
-genrule {
- name: "MicrodroidHostTestCases.CTS.config",
- srcs: ["AndroidTest.xml"],
- out: ["out.xml"],
- cmd: "sed " +
- "-e 's/<!-- PLACEHOLDER_FOR_ANNOTATION -->/" +
- "<option name=\"include-annotation\" value=\"com.android.compatibility.common.util.CddTest\" \\/>/' " +
- "-e 's/MicrodroidHostTestCases.jar/MicrodroidHostTestCases.CTS.jar/' " +
- "$(in) > $(out)",
-}
-
-genrule {
- name: "MicrodroidHostTestCases.VTS.config",
- srcs: ["AndroidTest.xml"],
- out: ["out.xml"],
- cmd: "sed " +
- "-e 's/<!-- PLACEHOLDER_FOR_ANNOTATION -->/" +
- "<option name=\"include-annotation\" value=\"com.android.compatibility.common.util.VsrTest\" \\/>/' " +
- "-e 's/MicrodroidHostTestCases.jar/MicrodroidHostTestCases.VTS.jar/' " +
- "$(in) > $(out)",
-}
-
-genrule {
- name: "MicrodroidHostTestCases.GTS.config",
- srcs: ["AndroidTest.xml"],
- out: ["out.xml"],
- cmd: "sed " +
- "-e 's/<!-- PLACEHOLDER_FOR_ANNOTATION -->/" +
- "<option name=\"include-annotation\" value=\"com.android.compatibility.common.util.GmsTest\" \\/>/' " +
- "-e 's/MicrodroidHostTestCases.jar/MicrodroidHostTestCases.GTS.jar/' " +
- "$(in) > $(out)",
-}
diff --git a/tests/hostside/AndroidTest.xml b/tests/hostside/AndroidTestTemplate.xml
similarity index 89%
rename from tests/hostside/AndroidTest.xml
rename to tests/hostside/AndroidTestTemplate.xml
index 3659564..fb81c90 100644
--- a/tests/hostside/AndroidTest.xml
+++ b/tests/hostside/AndroidTestTemplate.xml
@@ -14,7 +14,6 @@
limitations under the License.
-->
<configuration description="Host driven tests for Microdroid">
- <option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="security" />
<option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
<option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
@@ -26,8 +25,8 @@
</target_preparer>
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
- <option name="jar" value="MicrodroidHostTestCases.jar" />
+ <option name="jar" value="{MODULE}.jar" />
</test>
- <!-- PLACEHOLDER_FOR_ANNOTATION -->
+ {EXTRA_CONFIGS}
</configuration>
diff --git a/tests/testapk/Android.bp b/tests/testapk/Android.bp
index e495d10..35a2197 100644
--- a/tests/testapk/Android.bp
+++ b/tests/testapk/Android.bp
@@ -71,7 +71,8 @@
defaults: ["MicrodroidVersionsTestAppDefaults"],
manifest: "AndroidManifestV5.xml",
test_suites: ["general-tests"],
- test_config: "AndroidTest.xml",
+ test_config_template: "AndroidTestTemplate.xml",
+ auto_gen_config: true,
data: DATA,
}
@@ -79,8 +80,21 @@
name: "MicrodroidTestApp.CTS",
defaults: ["MicrodroidVersionsTestAppDefaults"],
manifest: "AndroidManifestV5.xml",
+ test_config_template: "AndroidTestTemplate.xml",
test_suites: ["cts"],
- test_config: ":MicrodroidTestApp.CTS.config",
+ auto_gen_config: true,
+ test_options: {
+ tradefed_options: [
+ {
+ name: "include-annotation",
+ value: "com.android.compatibility.common.util.CddTest",
+ },
+ {
+ name: "test-suite-tag",
+ value: "cts",
+ },
+ ],
+ },
data: DATA,
}
@@ -88,8 +102,21 @@
name: "MicrodroidTestApp.VTS",
defaults: ["MicrodroidVersionsTestAppDefaults"],
manifest: "AndroidManifestV5.xml",
+ test_config_template: "AndroidTestTemplate.xml",
test_suites: ["vts"],
- test_config: ":MicrodroidTestApp.VTS.config",
+ auto_gen_config: true,
+ test_options: {
+ tradefed_options: [
+ {
+ name: "include-annotation",
+ value: "com.android.compatibility.common.util.VsrTest",
+ },
+ {
+ name: "test-suite-tag",
+ value: "vts",
+ },
+ ],
+ },
data: DATA,
}
@@ -97,44 +124,24 @@
name: "MicrodroidTestApp.GTS",
defaults: ["MicrodroidVersionsTestAppDefaults"],
manifest: "AndroidManifestV5.xml",
+ test_config_template: "AndroidTestTemplate.xml",
test_suites: ["gts"],
- test_config: ":MicrodroidTestApp.GTS.config",
+ auto_gen_config: true,
+ test_options: {
+ tradefed_options: [
+ {
+ name: "include-annotation",
+ value: "com.android.compatibility.common.util.GmsTest",
+ },
+ {
+ name: "test-suite-tag",
+ value: "gts",
+ },
+ ],
+ },
data: DATA,
}
-genrule {
- name: "MicrodroidTestApp.CTS.config",
- srcs: ["AndroidTest.xml"],
- out: ["out.xml"],
- cmd: "sed " +
- "-e 's/<!-- PLACEHOLDER_FOR_ANNOTATION -->/" +
- "<option name=\"include-annotation\" value=\"com.android.compatibility.common.util.CddTest\" \\/>/' " +
- "-e 's/MicrodroidTestApp.apk/MicrodroidTestApp.CTS.apk/' " +
- "$(in) > $(out)",
-}
-
-genrule {
- name: "MicrodroidTestApp.VTS.config",
- srcs: ["AndroidTest.xml"],
- out: ["out.xml"],
- cmd: "sed " +
- "-e 's/<!-- PLACEHOLDER_FOR_ANNOTATION -->/" +
- "<option name=\"include-annotation\" value=\"com.android.compatibility.common.util.VsrTest\" \\/>/' " +
- "-e 's/MicrodroidTestApp.apk/MicrodroidTestApp.VTS.apk/' " +
- "$(in) > $(out)",
-}
-
-genrule {
- name: "MicrodroidTestApp.GTS.config",
- srcs: ["AndroidTest.xml"],
- out: ["out.xml"],
- cmd: "sed " +
- "-e 's/<!-- PLACEHOLDER_FOR_ANNOTATION -->/" +
- "<option name=\"include-annotation\" value=\"com.android.compatibility.common.util.GmsTest\" \\/>/' " +
- "-e 's/MicrodroidTestApp.apk/MicrodroidTestApp.GTS.apk/' " +
- "$(in) > $(out)",
-}
-
android_test_helper_app {
name: "MicrodroidTestAppUpdated",
defaults: ["MicrodroidVersionsTestAppDefaults"],
diff --git a/tests/testapk/AndroidTest.xml b/tests/testapk/AndroidTestTemplate.xml
similarity index 91%
rename from tests/testapk/AndroidTest.xml
rename to tests/testapk/AndroidTestTemplate.xml
index 58f2c4a..bbcf58d 100644
--- a/tests/testapk/AndroidTest.xml
+++ b/tests/testapk/AndroidTestTemplate.xml
@@ -14,14 +14,12 @@
limitations under the License.
-->
<configuration description="Runs Microdroid device-side tests.">
- <option name="test-suite-tag" value="cts" />
- <option name="test-suite-tag" value="vts" />
<option name="config-descriptor:metadata" key="component" value="security" />
<option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
<option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
<option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
- <option name="test-file-name" value="MicrodroidTestApp.apk" />
+ <option name="test-file-name" value="{MODULE}.apk" />
<option name="test-file-name" value="MicrodroidVmShareApp.apk" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
@@ -40,5 +38,5 @@
<option name="test-timeout" value="300000" />
</test>
- <!-- PLACEHOLDER_FOR_ANNOTATION -->
+ {EXTRA_CONFIGS}
</configuration>