summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2016-02-18 15:39:40 +0000
committerPaul Duffin <paulduffin@google.com>2016-02-24 15:12:26 +0000
commit6ed400700839884e36a1fb14e762bba528a613f2 (patch)
treea4579da734c25f6ab9946a2f959f4a0edce0c849 /libs
parent6b548d68a1357e3c568d805688134ab7fbe4e509 (diff)
downloadplatform_cts-6ed400700839884e36a1fb14e762bba528a613f2.tar.gz
platform_cts-6ed400700839884e36a1fb14e762bba528a613f2.tar.bz2
platform_cts-6ed400700839884e36a1fb14e762bba528a613f2.zip
Run ICU CTS tests using JUnit
The plan is for the ICU tests to be ported over to standard JUnit at some time in future and given that and a couple of other benefits below it makes sense to do the work to make them runnable within JUnit now. Running them as JUnit will allow us to reuse code across various CTS projects, e.g. libcore; this is a future piece of work. It integrates well with ExpectationStore which will enable us to disable tests that are not expected to work. The ICU team could potentially take this code and integrate it into their test framework allowing them to run their tests with JUnit very quickly and allow them to migrate their tests to standard JUnit gradually rather than have to do it in one go. Apart from the changes to the IcuTestRunner and related classes this also: 1) Adds a vogarexpect target to the libs/vogar-expect/Android.mk and a json target to the libs/json/Android.mk to allow the ExpectationStore to be used on the target. Refactored ExpectationStore to allow the expectations to be parsed from Reader instances and not just File instances. That is needed because the expectations are embedded within the CtsIcuTestCases.apk. 2) Added a icu-known-failures.txt expectations file that contains a list of the tests that are currently failing. A couple of them have had some investigation performed and bugs have been raised but most have not yet been triaged. As it stands all the tests that are run will pass, i.e. those not listed in this file. However, the failures in this file need to be investigated. 3) Made the build automatically generate an XML file for CTSv1 appropriate for the TARGET_ARCH from a flat list of tests held in the test-list.txt file. There is a tools/update-test-list.sh script that will update the list from a host_log.zip file created by CTSv2 when it runs the tests. That ensures that when up to date both CTSv1 and CTSv2 will both run the same set of tests. Change-Id: I603b0be6e905368bbc8beff0fabb162e7069f123
Diffstat (limited to 'libs')
-rw-r--r--libs/json/Android.mk13
-rw-r--r--libs/vogar-expect/Android.mk13
-rw-r--r--libs/vogar-expect/src/vogar/ExpectationStore.java70
3 files changed, 78 insertions, 18 deletions
diff --git a/libs/json/Android.mk b/libs/json/Android.mk
index 7ec9e7984a9..231f63531f4 100644
--- a/libs/json/Android.mk
+++ b/libs/json/Android.mk
@@ -15,6 +15,9 @@
#
LOCAL_PATH:= $(call my-dir)
+
+# Build the host library
+# ======================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
@@ -23,3 +26,13 @@ LOCAL_MODULE_TAGS := optional
include $(BUILD_HOST_JAVA_LIBRARY)
+# Build the target library
+# =======================
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE := json
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
diff --git a/libs/vogar-expect/Android.mk b/libs/vogar-expect/Android.mk
index 075bb43ddf2..2b5e07410bd 100644
--- a/libs/vogar-expect/Android.mk
+++ b/libs/vogar-expect/Android.mk
@@ -15,6 +15,9 @@
#
LOCAL_PATH:= $(call my-dir)
+
+# Build the host library
+# ======================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_MODULE := vogarexpectlib
@@ -23,3 +26,13 @@ LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := guavalib jsonlib
include $(BUILD_HOST_JAVA_LIBRARY)
+# Build the target library
+# =======================
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_MODULE := vogarexpect
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_STATIC_JAVA_LIBRARIES := guava json
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
diff --git a/libs/vogar-expect/src/vogar/ExpectationStore.java b/libs/vogar-expect/src/vogar/ExpectationStore.java
index b7b8d5a2b52..bf87b46f28d 100644
--- a/libs/vogar-expect/src/vogar/ExpectationStore.java
+++ b/libs/vogar-expect/src/vogar/ExpectationStore.java
@@ -16,25 +16,24 @@
package vogar;
-//import com.google.caliper.internal.gson.stream.JsonReader;
-
import com.android.json.stream.JsonReader;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
-
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
import java.util.Collections;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
-
import vogar.commands.Command;
import vogar.util.Log;
@@ -129,26 +128,61 @@ public final class ExpectationStore {
return result;
}
+ /**
+ * Create an {@link ExpectationStore} that is populated from expectation resources.
+ * @param owningClass the class from which the resources are loaded.
+ * @param expectationResources the set of paths to the expectation resources; the paths are
+ * either relative to the owning class, or absolute (starting with a /).
+ * @param mode the mode within which the tests are to be run.
+ * @return the populated {@link ExpectationStore}.
+ * @throws IOException if there was a problem loading
+ */
+ public static ExpectationStore parseResources(
+ Class<?> owningClass, Set<String> expectationResources, ModeId mode)
+ throws IOException {
+ ExpectationStore result = new ExpectationStore();
+ for (String expectationsPath : expectationResources) {
+ URL url = owningClass.getResource(expectationsPath);
+ if (url == null) {
+ Log.warn("Could not find resource '" + expectationsPath
+ + "' relative to " + owningClass);
+ } else {
+ result.parse(url, mode);
+ }
+ }
+ return result;
+ }
+
+ private void parse(URL url, ModeId mode) throws IOException {
+ Log.verbose("loading expectations from " + url);
+
+ try (InputStream is = url.openStream();
+ Reader reader = new InputStreamReader(is)) {
+ parse(reader, url.toString(), mode);
+ }
+ }
+
public void parse(File expectationsFile, ModeId mode) throws IOException {
Log.verbose("loading expectations file " + expectationsFile);
+ try (Reader fileReader = new FileReader(expectationsFile)) {
+ String source = expectationsFile.toString();
+ parse(fileReader, source, mode);
+ }
+ }
+
+ private void parse(Reader reader, String source, ModeId mode) throws IOException {
int count = 0;
- JsonReader reader = null;
- try {
- reader = new JsonReader(new FileReader(expectationsFile));
- reader.setLenient(true);
- reader.beginArray();
- while (reader.hasNext()) {
- readExpectation(reader, mode);
+ try (JsonReader jsonReader = new JsonReader(reader)) {
+ jsonReader.setLenient(true);
+ jsonReader.beginArray();
+ while (jsonReader.hasNext()) {
+ readExpectation(jsonReader, mode);
count++;
}
- reader.endArray();
+ jsonReader.endArray();
- Log.verbose("loaded " + count + " expectations from " + expectationsFile);
- } finally {
- if (reader != null) {
- reader.close();
- }
+ Log.verbose("loaded " + count + " expectations from " + source);
}
}