Bug 1465480 - Clean up crash dumps in GeckoView tests r=jchen,esawin draft
authorJames Willcox <snorp@snorp.net>
Wed, 06 Jun 2018 12:49:17 -0500
changeset 804897 ee8c211b80548a8548941a0aa1a0d1c5f1fc518a
parent 804896 8326be23b1c7f1e222cded46bcac33ded8184e22
push id112488
push userbmo:snorp@snorp.net
push dateWed, 06 Jun 2018 17:59:13 +0000
reviewersjchen, esawin
bugs1465480
milestone62.0a1
Bug 1465480 - Clean up crash dumps in GeckoView tests r=jchen,esawin We have tests that intentionally crash the content process. This leaves crash dumps, but we don't want the harness to think that this is something unexpected, so delete those when necessary. MozReview-Commit-ID: 9CjmuvwOYwv
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java
@@ -48,16 +48,17 @@ import android.support.annotation.NonNul
 import android.support.annotation.Nullable;
 import android.support.test.InstrumentationRegistry;
 import android.support.test.rule.UiThreadTestRule;
 import android.util.Log;
 import android.util.Pair;
 import android.view.MotionEvent;
 import android.view.Surface;
 
+import java.io.File;
 import java.lang.annotation.Annotation;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
@@ -1401,16 +1402,23 @@ public class GeckoSessionTestRule extend
             session.close();
         }
     }
 
     protected boolean isUsingSession(final GeckoSession session) {
         return session.equals(mMainSession) || mSubSessions.contains(session);
     }
 
+    protected void deleteCrashes() {
+        File dumpDir = new File(sRuntime.getProfileDir(), "minidumps");
+        for (final File dump : dumpDir.listFiles()) {
+            dump.delete();
+        }
+    }
+
     protected void cleanupStatement() throws Throwable {
         mWaitScopeDelegates.clear();
         mTestScopeDelegates.clear();
 
         for (final GeckoSession session : mSubSessions) {
             cleanupSession(session);
         }
 
@@ -1420,16 +1428,20 @@ public class GeckoSessionTestRule extend
 
         if (mMainSession.isOpen() && mMainSession.equals(sCachedSession)) {
             // We have to detach the Promises object, but keep the Tab itself.
             sCachedRDPTab.getPromises().detach();
         } else {
             cleanupSession(mMainSession);
         }
 
+        if (mIgnoreCrash) {
+            deleteCrashes();
+        }
+
         if (mDisplay != null) {
             mDisplay.surfaceDestroyed();
             mMainSession.releaseDisplay(mDisplay);
             mDisplay = null;
             mDisplaySurface.release();
             mDisplaySurface = null;
             mDisplayTexture.release();
             mDisplayTexture = null;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
@@ -17,16 +17,18 @@ import org.mozilla.gecko.EventDispatcher
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoThread;
 import org.mozilla.gecko.PrefsHelper;
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
 import org.mozilla.gecko.util.ThreadUtils;
 
+import java.io.File;
+
 public final class GeckoRuntime implements Parcelable {
     private static final String LOGTAG = "GeckoRuntime";
     private static final boolean DEBUG = false;
 
     private static GeckoRuntime sDefaultRuntime;
 
     /**
      * Get the default runtime for the given context.
@@ -226,16 +228,24 @@ public final class GeckoRuntime implemen
 
         if (mTelemetry == null) {
             mTelemetry = new RuntimeTelemetry(this);
         }
         return mTelemetry;
 
     }
 
+    /**
+     * Get the profile directory for this runtime. This is where Gecko stores
+     * internal data.
+     */
+    public File getProfileDir() {
+        return GeckoThread.getActiveProfile().getDir();
+    }
+
     @Override // Parcelable
     public int describeContents() {
         return 0;
     }
 
     @Override // Parcelable
     public void writeToParcel(Parcel out, int flags) {
         out.writeParcelable(mSettings, flags);