Configure project to run tests using atest

Simplify running tests which prior to this change had to be run from the
Android source root dir and required typing in several commands. This
was unecessary as the tests are plain-old host-side JUnit tests that can
be run without the C-Suite TradeFed runner.

The plans were converted to top-level module test configs deprecating
the old method of running the tests via the runner. Note that, besides
being unecessarily versbose, certain configuration elements such as the
reporters were removed as they cause issues with the atest runner.

This change also adds the tests to the postsubmit test group which is a
prerequisite for eventual inclusion in presubmit. Postsubmit tests are
not automatically run and require passing the :postsubmit option.

Change-Id: Idcc121c299e65d32529c31bf17fd839b8ce9305e
Test: atest --include-subdir :postsubmit :-)
diff --git a/harness/Android.mk b/harness/Android.mk
index c057891..aad6044 100644
--- a/harness/Android.mk
+++ b/harness/Android.mk
@@ -36,8 +36,6 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_JAVA_RESOURCE_DIRS := src/test/resources
-
 LOCAL_SRC_FILES = $(call all-java-files-under, src/test/java)
 
 LOCAL_JAVA_LIBRARIES := tradefed csuite-harness
@@ -46,4 +44,6 @@
 
 LOCAL_MODULE := csuite-harness-tests
 
+LOCAL_COMPATIBILITY_SUITE := general-tests
+
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/harness/AndroidTest.xml b/harness/AndroidTest.xml
new file mode 100644
index 0000000..f3fb637
--- /dev/null
+++ b/harness/AndroidTest.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<configuration description="Executes the C-Suite harness unit tests">
+  <test class="com.android.tradefed.testtype.HostTest" >
+    <option name="class" value="com.android.compatibility.CSuiteUnitTests" />
+  </test>
+</configuration>
diff --git a/harness/TEST_MAPPING b/harness/TEST_MAPPING
new file mode 100644
index 0000000..50ed1cd
--- /dev/null
+++ b/harness/TEST_MAPPING
@@ -0,0 +1,8 @@
+{
+  "postsubmit": [
+    {
+      "name": "csuite-harness-tests",
+      "host": true
+    }
+  ]
+}
diff --git a/harness/src/test/resources/config/csuite-harness-tests.xml b/harness/src/test/resources/config/csuite-harness-tests.xml
deleted file mode 100644
index 10dc6dc..0000000
--- a/harness/src/test/resources/config/csuite-harness-tests.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<configuration description="Executes the C-Suite harness unit tests">
-  <option name="null-device" value="true" />
-  <build_provider class="com.android.tradefed.build.StubBuildProvider" />
-
-  <test class="com.android.tradefed.testtype.HostTest" >
-    <option name="class" value="com.android.compatibility.CSuiteUnitTests" />
-  </test>
-
-  <logger class="com.android.tradefed.log.FileLogger" />
-
-  <result_reporter class="com.android.tradefed.result.ConsoleResultReporter">
-    <option name="suppress-passed-tests" value="true" />
-  </result_reporter>
-  <template-include name="reporters" default="empty" />
-</configuration>
diff --git a/tools/csuite-tradefed/Android.mk b/tools/csuite-tradefed/Android.mk
index f91b65b..654fac7 100644
--- a/tools/csuite-tradefed/Android.mk
+++ b/tools/csuite-tradefed/Android.mk
@@ -21,7 +21,6 @@
 LOCAL_PREBUILT_EXECUTABLES := src/scripts/csuite-tradefed
 include $(BUILD_HOST_PREBUILT)
 
-
 ############################
 # csuite-tradefed
 ############################
@@ -39,20 +38,17 @@
 
 include $(BUILD_COMPATIBILITY_SUITE)
 
-
 ############################
 # csuite-tradefed-tests
 ############################
 
 include $(CLEAR_VARS)
 
-LOCAL_JAVA_RESOURCE_DIRS := src/test/resources
-
 LOCAL_SRC_FILES += $(call all-java-files-under, src/test/java)
 
 LOCAL_MODULE := csuite-tradefed-tests
 LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed csuite-tradefed
-LOCAL_STATIC_JAVA_LIBRARIES := csuite-harness-tests
+LOCAL_STATIC_JAVA_LIBRARIES := tradefed csuite-tradefed
+LOCAL_COMPATIBILITY_SUITE := general-tests
 
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/csuite-tradefed/AndroidTest.xml b/tools/csuite-tradefed/AndroidTest.xml
new file mode 100644
index 0000000..850750e
--- /dev/null
+++ b/tools/csuite-tradefed/AndroidTest.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<configuration>
+  <test class="com.android.tradefed.testtype.HostTest" >
+    <option name="class" value="com.android.compatibility.tradefed.CSuiteTradefedTest" />
+  </test>
+</configuration>
diff --git a/tools/csuite-tradefed/README b/tools/csuite-tradefed/README
index dbc09aa..32cf936 100644
--- a/tools/csuite-tradefed/README
+++ b/tools/csuite-tradefed/README
@@ -35,10 +35,11 @@
 The source for the tradefed framework can be found on the 'tradefed' branch.
 
 Perform these steps to build and run csuite from the development environment:
+
 cd <path to android source root>
 make csuite
 csuite-tradefed
-run csuite-unit-tests
+run <plan-name>
 
 More documentation and details on using and extending trade federation will
 be forthcoming in the near future.
diff --git a/tools/csuite-tradefed/TEST_MAPPING b/tools/csuite-tradefed/TEST_MAPPING
new file mode 100644
index 0000000..89c2072
--- /dev/null
+++ b/tools/csuite-tradefed/TEST_MAPPING
@@ -0,0 +1,8 @@
+{
+  "postsubmit": [
+    {
+      "name": "csuite-tradefed-tests",
+      "host": true
+    }
+  ]
+}
diff --git a/tools/csuite-tradefed/src/test/resources/config/csuite-unit-tests.xml b/tools/csuite-tradefed/src/test/resources/config/csuite-unit-tests.xml
deleted file mode 100644
index 20384d1..0000000
--- a/tools/csuite-tradefed/src/test/resources/config/csuite-unit-tests.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<configuration description="Executes the C-Suite unit tests">
-  <option name="null-device" value="true" />
-  <build_provider class="com.android.tradefed.build.StubBuildProvider" />
-
-  <test class="com.android.tradefed.testtype.HostTest" >
-    <option name="class" value="com.android.compatibility.tradefed.CSuiteTradefedTest" />
-  </test>
-
-  <logger class="com.android.tradefed.log.FileLogger" />
-
-  <result_reporter class="com.android.tradefed.result.ConsoleResultReporter">
-    <option name="suppress-passed-tests" value="true" />
-  </result_reporter>
-  <template-include name="reporters" default="empty" />
-</configuration>