AI 146710: Splitting android.core.tests.apk into several smaller
apks. Each libcore module gets one apk and luni gets 4.
BUG=1789657
Automated import of CL 146710
diff --git a/tools/utils/CollectAllTests.java b/tools/utils/CollectAllTests.java
index e2b6ad1..76f7332 100644
--- a/tools/utils/CollectAllTests.java
+++ b/tools/utils/CollectAllTests.java
@@ -14,19 +14,18 @@
* limitations under the License.
*/
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.BufferedReader;
-import java.io.FileReader;
-
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
@@ -36,6 +35,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;
+import junit.textui.ResultPrinter;
import junit.textui.TestRunner;
import org.w3c.dom.Document;
@@ -43,10 +43,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import java.lang.annotation.Annotation;
-import java.lang.ClassNotFoundException;
-import java.lang.NoSuchMethodException;
-
public class CollectAllTests extends DescriptionGenerator {
static final String ATTRIBUTE_RUNNER = "runner";
@@ -115,7 +111,7 @@
} else {
System.out.println("usage: \n" +
"\t... CollectAllTests <output-file> <manifest-file> <testsuite-class-name> <makefile-file>");
- return;
+ System.exit(1);
}
if (ANDROID_MAKE_FILE.length() > 0) {
@@ -128,7 +124,7 @@
} catch (Exception e) {
System.err.println("cannot open manifest");
e.printStackTrace();
- return;
+ System.exit(1);;
}
Element documentElement = manifest.getDocumentElement();
@@ -146,7 +142,7 @@
} catch (ClassNotFoundException e) {
System.err.println("test class not found");
e.printStackTrace();
- return;
+ System.exit(1);;
}
Method method = null;
@@ -155,11 +151,11 @@
} catch (SecurityException e) {
System.err.println("failed to get suite method");
e.printStackTrace();
- return;
+ System.exit(1);;
} catch (NoSuchMethodException e) {
System.err.println("failed to get suite method");
e.printStackTrace();
- return;
+ System.exit(1);;
}
try {
@@ -167,21 +163,22 @@
} catch (IllegalArgumentException e) {
System.err.println("failed to get suite method");
e.printStackTrace();
- return;
+ System.exit(1);;
} catch (IllegalAccessException e) {
System.err.println("failed to get suite method");
e.printStackTrace();
- return;
+ System.exit(1);;
} catch (InvocationTargetException e) {
System.err.println("failed to get suite method");
e.printStackTrace();
- return;
+ System.exit(1);;
}
try {
xmlGenerator = new MyXMLGenerator(OUTPUTFILE + ".xml");
} catch (ParserConfigurationException e) {
System.err.println("Can't initialize XML Generator");
+ System.exit(1);
}
testCases = new LinkedHashMap<String, TestClass>();
@@ -194,6 +191,7 @@
String type = iterator.next();
System.err.println(type);
}
+ System.exit(1);
}
for (Iterator<TestClass> iterator = testCases.values().iterator(); iterator.hasNext();) {
@@ -206,6 +204,7 @@
} catch (Exception e) {
System.err.println("cannot dump xml");
e.printStackTrace();
+ System.exit(1);
}
}
@@ -249,8 +248,7 @@
}
public void compose() {
- System.out.println("Collecting all junit tests...");
- new TestRunner() {
+ TestRunner runner = new TestRunner() {
@Override
protected TestResult createTestResult() {
return new TestResult() {
@@ -265,22 +263,47 @@
public TestResult doRun(Test test) {
return super.doRun(test);
}
- }.doRun(TESTSUITE);
+
+
+
+ };
+
+ runner.setPrinter(new ResultPrinter(System.out) {
+ @Override
+ protected void printFooter(TestResult result) {
+ }
+
+ @Override
+ protected void printHeader(long runTime) {
+ }
+ });
+ runner.doRun(TESTSUITE);
}
-
- private String getKnownFailure(final String testClassName, final String testName) {
+
+ private String getKnownFailure(final Class<? extends TestCase> testClass,
+ final String testName) {
+ return getAnnotation(testClass, testName, KNOWN_FAILURE);
+ }
+
+ private boolean isBrokenTest(final Class<? extends TestCase> testClass,
+ final String testName) {
+ return getAnnotation(testClass, testName, BROKEN_TEST) != null;
+ }
+
+ private String getAnnotation(final Class<? extends TestCase> testClass,
+ final String testName, final String annotationName) {
try {
- Class<?> testClass = Class.forName(testClassName);
- Method testMethod = testClass.getMethod(testName, null);
+ Method testMethod = testClass.getMethod(testName, (Class[])null);
Annotation[] annotations = testMethod.getAnnotations();
for (Annotation annot : annotations) {
- if (annot.annotationType().getName().equals(KNOWN_FAILURE)) {
+ if (annot.annotationType().getName().equals(annotationName)) {
String annotStr = annot.toString();
String knownFailure = null;
if (annotStr.contains("(value=")) {
knownFailure =
- annotStr.substring(annotStr.indexOf("=") + 1, annotStr.length() - 1);
+ annotStr.substring(annotStr.indexOf("=") + 1,
+ annotStr.length() - 1);
}
@@ -293,22 +316,23 @@
}
- } catch (java.lang.ClassNotFoundException e) {
} catch (java.lang.NoSuchMethodException e) {
}
return null;
}
- private void println(final String message) {
- System.out.println(message);
- }
-
private void addToTests(TestCase test) {
String testClassName = test.getClass().getName();
String testName = test.getName();
- String knownFailure = getKnownFailure(testClassName, testName);
+ String knownFailure = getKnownFailure(test.getClass(), testName);
+
+ if (isBrokenTest(test.getClass(), testName)) {
+ System.out.println("ignoring broken test: " + test);
+ return;
+ }
+
if (!testName.startsWith("test")) {
try {
diff --git a/tools/utils/DescriptionGenerator.java b/tools/utils/DescriptionGenerator.java
index 8a21c83..e81e6d6 100644
--- a/tools/utils/DescriptionGenerator.java
+++ b/tools/utils/DescriptionGenerator.java
@@ -64,6 +64,7 @@
public class DescriptionGenerator extends Doclet {
static final String HOST_CONTROLLER = "dalvik.annotation.HostController";
static final String KNOWN_FAILURE = "dalvik.annotation.KnownFailure";
+ static final String BROKEN_TEST = "dalvik.annotation.BrokenTest";
static final String JUNIT_TEST_CASE_CLASS_NAME = "junit.framework.testcase";
static final String TAG_PACKAGE = "TestPackage";
diff --git a/tools/utils/genDefaultTestPlan.sh b/tools/utils/genDefaultTestPlan.sh
index ebfa914..dc170af 100644
--- a/tools/utils/genDefaultTestPlan.sh
+++ b/tools/utils/genDefaultTestPlan.sh
@@ -271,7 +271,7 @@
SIGNATURE_TESTS="android.tests.sigtest"
SIGNATURE_CHECK_PATH="${CASE_REPOSITORY}/${SIGNATURE_TEST_NAME}.xml"
-ANDROID_CORE_TESTS="android.core.tests"
+ANDROID_CORE_TESTS="android.core.tests.annotation android.core.tests.archive android.core.tests.concurrent android.core.tests.crypto android.core.tests.dom android.core.tests.logging android.core.tests.luni android.core.tests.luni.io android.core.tests.luni.lang android.core.tests.luni.net android.core.tests.luni.util android.core.tests.math android.core.tests.nio android.core.tests.nio_char android.core.tests.prefs android.core.tests.regex android.core.tests.security android.core.tests.sql android.core.tests.text android.core.tests.xml android.core.tests.xnet"
ANDROID_CORE_VM_TESTS="android.core.vm-tests"
#Creating Signature check description xml file, if not existed.