summaryrefslogtreecommitdiffstats
path: root/testing/android
diff options
context:
space:
mode:
authorjbudorick <jbudorick@chromium.org>2015-01-13 15:49:28 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-13 23:50:14 +0000
commite6c56015219f5824bf0cad7f69d888f14e693e3e (patch)
treefbb44cb6dd5ba84044b3a2763e9a618151c29493 /testing/android
parent05b83de45a179f95fca6c4c1bf08142f93268451 (diff)
downloadchromium_src-e6c56015219f5824bf0cad7f69d888f14e693e3e.zip
chromium_src-e6c56015219f5824bf0cad7f69d888f14e693e3e.tar.gz
chromium_src-e6c56015219f5824bf0cad7f69d888f14e693e3e.tar.bz2
[Android] Add file-based gtest filtering for gtests on AMP.
BUG=428729 Review URL: https://codereview.chromium.org/810193007 Cr-Commit-Position: refs/heads/master@{#311363}
Diffstat (limited to 'testing/android')
-rw-r--r--testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java14
-rw-r--r--testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java28
2 files changed, 37 insertions, 5 deletions
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
index 42befe5..d476cbc 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
@@ -7,6 +7,7 @@ package org.chromium.native_test;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.util.Log;
@@ -16,6 +17,8 @@ import org.chromium.base.PowerMonitor;
import org.chromium.base.ResourceExtractor;
import org.chromium.base.library_loader.NativeLibraries;
+import java.io.File;
+
/**
* Android's NativeActivity is mostly useful for pure-native code.
* Our tests need to go up to our own java classes, which is not possible using
@@ -75,7 +78,16 @@ public class ChromeNativeTestActivity extends Activity {
if (commandLineFlags == null) commandLineFlags = "";
String commandLineFilePath = getIntent().getStringExtra(EXTRA_COMMAND_LINE_FILE);
- if (commandLineFilePath == null) commandLineFilePath = "";
+ if (commandLineFilePath == null) {
+ commandLineFilePath = "";
+ } else {
+ File commandLineFile = new File(commandLineFilePath);
+ if (!commandLineFile.isAbsolute()) {
+ commandLineFilePath = Environment.getExternalStorageDirectory() + "/"
+ + commandLineFilePath;
+ }
+ Log.i(TAG, "command line file path: " + commandLineFilePath);
+ }
// This directory is used by build/android/pylib/test_package_apk.py.
nativeRunTests(commandLineFlags, commandLineFilePath, getFilesDir().getAbsolutePath(),
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
index a5cf485..43135cc 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
@@ -27,9 +27,13 @@ import java.util.regex.Pattern;
* An Instrumentation that runs tests based on ChromeNativeTestActivity.
*/
public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
+ // TODO(jbudorick): Remove this extra when b/18981674 is fixed.
+ public static final String EXTRA_ONLY_OUTPUT_FAILURES =
+ "org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner."
+ + "OnlyOutputFailures";
private static final String TAG = "ChromeNativeTestInstrumentationTestRunner";
- private static final Pattern RE_TEST_OUTPUT = Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]*) .*");
+ private static final Pattern RE_TEST_OUTPUT = Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]+) .*");
private static interface ResultsBundleGenerator {
public Bundle generate(Map<String, TestResult> rawResults);
@@ -39,6 +43,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
private String mCommandLineFlags;
private Bundle mLogBundle;
private ResultsBundleGenerator mBundleGenerator;
+ private boolean mOnlyOutputFailures;
@Override
public void onCreate(Bundle arguments) {
@@ -46,6 +51,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
mCommandLineFlags = arguments.getString(ChromeNativeTestActivity.EXTRA_COMMAND_LINE_FLAGS);
mLogBundle = new Bundle();
mBundleGenerator = new RobotiumBundleGenerator();
+ mOnlyOutputFailures = arguments.containsKey(EXTRA_ONLY_OUTPUT_FAILURES);
start();
}
@@ -117,17 +123,27 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
for (String l = r.readLine(); l != null && !l.equals("<<ScopedMainEntryLogger");
l = r.readLine()) {
Matcher m = RE_TEST_OUTPUT.matcher(l);
+ boolean isFailure = false;
if (m.matches()) {
if (m.group(1).equals("RUN")) {
results.put(m.group(2), TestResult.UNKNOWN);
} else if (m.group(1).equals("FAILED")) {
results.put(m.group(2), TestResult.FAILED);
+ isFailure = true;
+ mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n");
+ sendStatus(0, mLogBundle);
} else if (m.group(1).equals("OK")) {
results.put(m.group(2), TestResult.PASSED);
}
}
- mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n");
- sendStatus(0, mLogBundle);
+
+ // TODO(jbudorick): mOnlyOutputFailures is a workaround for b/18981674. Remove it
+ // once that issue is fixed.
+ if (!mOnlyOutputFailures || isFailure) {
+ mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n");
+ sendStatus(0, mLogBundle);
+ }
+ Log.i(TAG, l);
}
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted while waiting for FIFO file creation: " + e.toString());
@@ -168,6 +184,9 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
++testsPassed;
break;
case FAILED:
+ // TODO(jbudorick): Remove this log message once AMP execution and
+ // results handling has been stabilized.
+ Log.d(TAG, "FAILED: " + entry.getKey());
++testsFailed;
break;
default:
@@ -178,11 +197,12 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
}
StringBuilder resultBuilder = new StringBuilder();
- resultBuilder.append("\nOK (" + Integer.toString(testsPassed) + " tests)");
if (testsFailed > 0) {
resultBuilder.append(
"\nFAILURES!!! Tests run: " + Integer.toString(rawResults.size())
+ ", Failures: " + Integer.toString(testsFailed) + ", Errors: 0");
+ } else {
+ resultBuilder.append("\nOK (" + Integer.toString(testsPassed) + " tests)");
}
resultsBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT,
resultBuilder.toString());