Add `MainlineTestModuleController` support to ART run-tests and gtests.

This in order to run these tests only when APEX package
`com.google.android.art` is installed on the test device.

Test: m mts && mts-tradefed run commandAndExit mts-art
Bug: 167385698
Change-Id: Iad9c1d1584a5fcb53731a05d7f249aa049e3bb75
diff --git a/test/art-gtests-target-chroot.xml b/test/art-gtests-target-chroot.xml
index 99f66ce..c700f4c 100644
--- a/test/art-gtests-target-chroot.xml
+++ b/test/art-gtests-target-chroot.xml
@@ -15,13 +15,19 @@
 -->
 <configuration description="ART gtests for target (using chroot)">
     <option name="test-suite-tag" value="art-target-gtest-chroot" />
+
     <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
     <target_preparer class="com.android.tradefed.targetprep.DisableSELinuxTargetPreparer" />
     <target_preparer class="com.android.tradefed.targetprep.ArtChrootPreparer" />
+
     <test class="com.android.tradefed.testtype.ArtGTest" >
         <!-- TODO(b/147821328): These tests do not work since they need to write to /system -->
         <option name="exclude-filter" value="HiddenApiTest.DexDomain_System*:OatFileAssistantTest.SystemFrameworkDir" />
         <option name="native-test-timeout" value="600000" />
         <option name="native-test-device-path" value="/data/local/tmp/art-test-chroot/apex/com.android.art/bin/art" />
     </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.art" />
+    </object>
 </configuration>
diff --git a/test/art-gtests-target-install-apex.xml b/test/art-gtests-target-install-apex.xml
index 7ba0170..3320702 100644
--- a/test/art-gtests-target-install-apex.xml
+++ b/test/art-gtests-target-install-apex.xml
@@ -16,13 +16,19 @@
 <configuration description="ART gtests for target (using apex installation)">
     <option name="test-suite-tag" value="art" />
     <option name="test-suite-tag" value="art-target-gtest-install-apex" />
+
     <target_preparer class="com.android.tradefed.targetprep.InstallApexModuleTargetPreparer" >
         <option name="test-file-name" value="com.android.art.testing.apex" />
     </target_preparer>
+
     <test class="com.android.tradefed.testtype.GTest" >
         <!-- TODO(b/147821328): These tests do not work since they need to write to /system -->
         <option name="exclude-filter" value="HiddenApiTest.DexDomain_System*:OatFileAssistantTest.SystemFrameworkDir" />
         <option name="native-test-timeout" value="600000" /> <!-- 10 min -->
         <option name="native-test-device-path" value="/apex/com.android.art/bin/art" />
     </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.art" />
+    </object>
 </configuration>
diff --git a/test/art-run-test-target-no-test-suite-tag-template.xml b/test/art-run-test-target-no-test-suite-tag-template.xml
index cad7ace..475c5bc 100644
--- a/test/art-run-test-target-no-test-suite-tag-template.xml
+++ b/test/art-run-test-target-no-test-suite-tag-template.xml
@@ -21,8 +21,13 @@
              `push`. -->
         <option name="push" value="{MODULE}.jar->/data/local/tmp/{MODULE}/{MODULE}.jar" />
     </target_preparer>
+
     <test class="com.android.tradefed.testtype.ArtRunTest">
         <option name="run-test-name" value="{MODULE}" />
         <option name="classpath" value="/data/local/tmp/{MODULE}/{MODULE}.jar" />
     </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.art" />
+    </object>
 </configuration>
diff --git a/test/art-run-test-target-template.xml b/test/art-run-test-target-template.xml
index 320afa9..a601b56 100644
--- a/test/art-run-test-target-template.xml
+++ b/test/art-run-test-target-template.xml
@@ -16,14 +16,20 @@
 <!-- Note: This test config for {MODULE} is generated from a template. -->
 <configuration description="Test module config for {MODULE}">
     <option name="test-suite-tag" value="art-target-run-test" />
+
     <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
         <option name="cleanup" value="true" />
         <!-- TODO: Use option `push-file` instead of deprecated option
              `push`. -->
         <option name="push" value="{MODULE}.jar->/data/local/tmp/{MODULE}/{MODULE}.jar" />
     </target_preparer>
+
     <test class="com.android.tradefed.testtype.ArtRunTest">
         <option name="run-test-name" value="{MODULE}" />
         <option name="classpath" value="/data/local/tmp/{MODULE}/{MODULE}.jar" />
     </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.art" />
+    </object>
 </configuration>