| Index: testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
|
| 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 43135cc932b04c17f6719731f871406fce2c7e1f..5043932176cd01d7d121b99a4997cfa2a8d72e38 100644
|
| --- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
|
| +++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
|
| @@ -9,6 +9,7 @@ import android.app.Instrumentation;
|
| import android.content.ComponentName;
|
| import android.content.Intent;
|
| import android.os.Bundle;
|
| +import android.os.Environment;
|
| import android.util.Log;
|
|
|
| import java.io.BufferedInputStream;
|
| @@ -41,6 +42,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
|
|
|
| private String mCommandLineFile;
|
| private String mCommandLineFlags;
|
| + private File mStdoutFile;
|
| private Bundle mLogBundle;
|
| private ResultsBundleGenerator mBundleGenerator;
|
| private boolean mOnlyOutputFailures;
|
| @@ -49,6 +51,15 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
|
| public void onCreate(Bundle arguments) {
|
| mCommandLineFile = arguments.getString(ChromeNativeTestActivity.EXTRA_COMMAND_LINE_FILE);
|
| mCommandLineFlags = arguments.getString(ChromeNativeTestActivity.EXTRA_COMMAND_LINE_FLAGS);
|
| + try {
|
| + mStdoutFile = File.createTempFile(
|
| + ".temp_stdout_", ".txt", Environment.getExternalStorageDirectory());
|
| + Log.i(TAG, "stdout file created: " + mStdoutFile.getAbsolutePath());
|
| + } catch (IOException e) {
|
| + Log.e(TAG, "Unable to create temporary stdout file." + e.toString());
|
| + finish(Activity.RESULT_CANCELED, new Bundle());
|
| + return;
|
| + }
|
| mLogBundle = new Bundle();
|
| mBundleGenerator = new RobotiumBundleGenerator();
|
| mOnlyOutputFailures = arguments.containsKey(EXTRA_ONLY_OUTPUT_FAILURES);
|
| @@ -68,11 +79,17 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
|
| Log.i(TAG, "Creating activity.");
|
| Activity activityUnderTest = startNativeTestActivity();
|
|
|
| - Log.i(TAG, "Getting results from FIFO.");
|
| - Map<String, TestResult> results = parseResultsFromFifo(activityUnderTest);
|
| + Log.i(TAG, "Waiting for tests to finish.");
|
| + try {
|
| + while (!activityUnderTest.isFinishing()) {
|
| + Thread.sleep(100);
|
| + }
|
| + } catch (InterruptedException e) {
|
| + Log.e(TAG, "Interrupted while waiting for activity to be destroyed: " + e.toString());
|
| + }
|
|
|
| - Log.i(TAG, "Finishing activity.");
|
| - activityUnderTest.finish();
|
| + Log.i(TAG, "Getting results.");
|
| + Map<String, TestResult> results = parseResults(activityUnderTest);
|
|
|
| Log.i(TAG, "Parsing results and generating output.");
|
| return mBundleGenerator.generate(results);
|
| @@ -94,6 +111,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
|
| Log.i(TAG, "Passing command line flag extra: " + mCommandLineFlags);
|
| i.putExtra(ChromeNativeTestActivity.EXTRA_COMMAND_LINE_FLAGS, mCommandLineFlags);
|
| }
|
| + i.putExtra(ChromeNativeTestActivity.EXTRA_STDOUT_FILE, mStdoutFile.getAbsolutePath());
|
| return startActivitySync(i);
|
| }
|
|
|
| @@ -102,23 +120,22 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
|
| }
|
|
|
| /**
|
| - * Generates a map between test names and test results from the instrumented Activity's FIFO.
|
| + * Generates a map between test names and test results from the instrumented Activity's
|
| + * output.
|
| */
|
| - private Map<String, TestResult> parseResultsFromFifo(Activity activityUnderTest) {
|
| + private Map<String, TestResult> parseResults(Activity activityUnderTest) {
|
| Map<String, TestResult> results = new HashMap<String, TestResult>();
|
|
|
| - File fifo = null;
|
| BufferedReader r = null;
|
|
|
| try {
|
| - // Wait for the test to create the FIFO.
|
| - fifo = new File(getTargetContext().getFilesDir().getAbsolutePath(), "test.fifo");
|
| - while (!fifo.exists()) {
|
| - Thread.sleep(1000);
|
| + if (mStdoutFile == null || !mStdoutFile.exists()) {
|
| + Log.e(TAG, "Unable to find stdout file.");
|
| + return results;
|
| }
|
|
|
| - r = new BufferedReader(
|
| - new InputStreamReader(new BufferedInputStream(new FileInputStream(fifo))));
|
| + r = new BufferedReader(new InputStreamReader(
|
| + new BufferedInputStream(new FileInputStream(mStdoutFile))));
|
|
|
| for (String l = r.readLine(); l != null && !l.equals("<<ScopedMainEntryLogger");
|
| l = r.readLine()) {
|
| @@ -145,23 +162,21 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
|
| }
|
| Log.i(TAG, l);
|
| }
|
| - } catch (InterruptedException e) {
|
| - Log.e(TAG, "Interrupted while waiting for FIFO file creation: " + e.toString());
|
| } catch (FileNotFoundException e) {
|
| - Log.e(TAG, "Couldn't find FIFO file: " + e.toString());
|
| + Log.e(TAG, "Couldn't find stdout file file: " + e.toString());
|
| } catch (IOException e) {
|
| - Log.e(TAG, "Error handling FIFO file: " + e.toString());
|
| + Log.e(TAG, "Error handling stdout file: " + e.toString());
|
| } finally {
|
| if (r != null) {
|
| try {
|
| r.close();
|
| } catch (IOException e) {
|
| - Log.e(TAG, "Error while closing FIFO reader.");
|
| + Log.e(TAG, "Error while closing stdout reader.");
|
| }
|
| }
|
| - if (fifo != null) {
|
| - if (!fifo.delete()) {
|
| - Log.e(TAG, "Unable to delete " + fifo.getAbsolutePath());
|
| + if (mStdoutFile != null) {
|
| + if (!mStdoutFile.delete()) {
|
| + Log.e(TAG, "Unable to delete " + mStdoutFile.getAbsolutePath());
|
| }
|
| }
|
| }
|
|
|