Add a tradefed config for ahat's unit tests.
And a minor unrelated style cleanup.
Bug: 38219110
Test: m ahat-test
Test: tradefed.sh run AndroidTest.xml, without devices attached.
Change-Id: Ifcb99ee08a43925ae79bb223a948522ab21c99c6
diff --git a/tools/ahat/Android.mk b/tools/ahat/Android.mk
index ad33233..9f423ba 100644
--- a/tools/ahat/Android.mk
+++ b/tools/ahat/Android.mk
@@ -147,6 +147,7 @@
LOCAL_IS_HOST_MODULE := true
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE := ahat-tests
+LOCAL_COMPATIBILITY_SUITE := general-tests
include $(BUILD_HOST_JAVA_LIBRARY)
AHAT_TEST_JAR := $(LOCAL_BUILT_MODULE)
diff --git a/tools/ahat/AndroidTest.xml b/tools/ahat/AndroidTest.xml
new file mode 100644
index 0000000..867658c
--- /dev/null
+++ b/tools/ahat/AndroidTest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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="Runs the ahat unit tests">
+ <option name="null-device" value="true" />
+ <test class="com.android.tradefed.testtype.HostTest" >
+ <option name="class" value="com.android.ahat.AhatTestSuite" />
+ </test>
+</configuration>
diff --git a/tools/ahat/etc/ahat-tests.mf b/tools/ahat/etc/ahat-tests.mf
index af17fad..48fdeb3 100644
--- a/tools/ahat/etc/ahat-tests.mf
+++ b/tools/ahat/etc/ahat-tests.mf
@@ -1 +1 @@
-Main-Class: com.android.ahat.Tests
+Main-Class: com.android.ahat.AhatTestSuite
diff --git a/tools/ahat/src/main/com/android/ahat/Main.java b/tools/ahat/src/main/com/android/ahat/Main.java
index 04a6012..af197d4 100644
--- a/tools/ahat/src/main/com/android/ahat/Main.java
+++ b/tools/ahat/src/main/com/android/ahat/Main.java
@@ -102,7 +102,7 @@
i++;
try {
map.readFromFile(new File(args[i]));
- } catch (IOException|ParseException ex) {
+ } catch (IOException | ParseException ex) {
System.out.println("Unable to read proguard map: " + ex);
System.out.println("The proguard map will not be used.");
}
@@ -110,7 +110,7 @@
i++;
try {
mapbase.readFromFile(new File(args[i]));
- } catch (IOException|ParseException ex) {
+ } catch (IOException | ParseException ex) {
System.out.println("Unable to read baseline proguard map: " + ex);
System.out.println("The proguard map will not be used.");
}
diff --git a/tools/ahat/src/test/com/android/ahat/AhatTestSuite.java b/tools/ahat/src/test/com/android/ahat/AhatTestSuite.java
new file mode 100644
index 0000000..bce1f05
--- /dev/null
+++ b/tools/ahat/src/test/com/android/ahat/AhatTestSuite.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package com.android.ahat;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ DiffFieldsTest.class,
+ DiffTest.class,
+ DominatorsTest.class,
+ HtmlEscaperTest.class,
+ InstanceTest.class,
+ NativeAllocationTest.class,
+ ObjectHandlerTest.class,
+ OverviewHandlerTest.class,
+ PerformanceTest.class,
+ ProguardMapTest.class,
+ RootedHandlerTest.class,
+ QueryTest.class,
+ SiteHandlerTest.class,
+ SiteTest.class
+})
+
+public class AhatTestSuite {
+ public static void main(String[] args) {
+ if (args.length == 0) {
+ args = new String[]{"com.android.ahat.AhatTestSuite"};
+ }
+ JUnitCore.main(args);
+ }
+}
diff --git a/tools/ahat/src/test/com/android/ahat/Tests.java b/tools/ahat/src/test/com/android/ahat/Tests.java
deleted file mode 100644
index 0e70432..0000000
--- a/tools/ahat/src/test/com/android/ahat/Tests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.ahat;
-
-import org.junit.runner.JUnitCore;
-
-public class Tests {
- public static void main(String[] args) {
- if (args.length == 0) {
- args = new String[]{
- "com.android.ahat.DiffFieldsTest",
- "com.android.ahat.DiffTest",
- "com.android.ahat.DominatorsTest",
- "com.android.ahat.HtmlEscaperTest",
- "com.android.ahat.InstanceTest",
- "com.android.ahat.NativeAllocationTest",
- "com.android.ahat.ObjectHandlerTest",
- "com.android.ahat.OverviewHandlerTest",
- "com.android.ahat.PerformanceTest",
- "com.android.ahat.ProguardMapTest",
- "com.android.ahat.RootedHandlerTest",
- "com.android.ahat.QueryTest",
- "com.android.ahat.SiteHandlerTest",
- "com.android.ahat.SiteTest",
- };
- }
- JUnitCore.main(args);
- }
-}
-