Bug 1469683 - 1. Fix crash tests; r=esawin
authorJim Chen <nchen@mozilla.com>
Wed, 20 Jun 2018 16:46:20 -0400
changeset 479849 2806729c61eaac199ad4670788c4008079a99f34
parent 479848 ff8e661f8b074c558b70493034beed22e6213b93
child 479850 13ff68c7707d414ea98096933b322025a75ad871
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1469683
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1469683 - 1. Fix crash tests; r=esawin Specify individual sessions in crash tests (i.e. "mainSession.waitUntilCalled" instead of "sessionRule.waitUntilCalled"), so that the tests assert behavior on the correct session, and not inadvertently on the cached session. Also, under x86 debug builds, Gecko installs an "ah_crap_handler" for SIGSEGV that waits for a long time, which causes our crash tests to time out. Therefore, ignore crash tests under x86 debug. MozReview-Commit-ID: DdtmRBLmPGp
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt
@@ -60,53 +60,63 @@ class ContentDelegateTest : BaseSessionT
         })
     }
 
     @IgnoreCrash
     @ReuseSession(false)
     @Test fun crashContent() {
         // This test doesn't make sense without multiprocess
         assumeThat(sessionRule.env.isMultiprocess, equalTo(true))
+        // Cannot test x86 debug builds due to Gecko's "ah_crap_handler"
+        // that waits for debugger to attach during a SIGSEGV.
+        assumeThat(sessionRule.env.isDebugBuild && sessionRule.env.cpuArch == "x86",
+                   equalTo(false))
 
-        sessionRule.session.loadUri(CONTENT_CRASH_URL)
-
-        sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
+        mainSession.loadUri(CONTENT_CRASH_URL)
+        mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
             @AssertCalled(count = 1)
             override fun onCrash(session: GeckoSession) {
-                assertThat("Session should be closed after a crash", session.isOpen, equalTo(false))
-
-                // Recover immediately
-                session.open()
-                session.loadTestPath(HELLO_HTML_PATH)
+                assertThat("Session should be closed after a crash",
+                           session.isOpen, equalTo(false))
             }
         });
 
-        sessionRule.waitForPageStop()
-
-        sessionRule.forCallbacksDuringWait(object: Callbacks.ProgressDelegate {
+        // Recover immediately
+        mainSession.open()
+        mainSession.loadTestPath(HELLO_HTML_PATH)
+        mainSession.waitUntilCalled(object: Callbacks.ProgressDelegate {
             @AssertCalled(count = 1)
             override fun onPageStop(session: GeckoSession, success: Boolean) {
                 assertThat("Page should load successfully", success, equalTo(true))
             }
         })
     }
 
     @IgnoreCrash
     @ReuseSession(false)
     @Test fun crashContentMultipleSessions() {
         // This test doesn't make sense without multiprocess
         assumeThat(sessionRule.env.isMultiprocess, equalTo(true))
+        // Cannot test x86 debug builds due to Gecko's "ah_crap_handler"
+        // that waits for debugger to attach during a SIGSEGV.
+        assumeThat(sessionRule.env.isDebugBuild && sessionRule.env.cpuArch == "x86",
+                   equalTo(false))
 
-        // We need to make sure all sessions in a given content process
-        // receive onCrash(). If we add multiple content processes, this
-        // test will need fixed to ensure the test sessions go into the
-        // same one.
-        sessionRule.createOpenSession()
-        sessionRule.session.loadUri(CONTENT_CRASH_URL)
+        // XXX we need to make sure all sessions in a given content process receive onCrash().
+        // If we add multiple content processes, this test will need to be fixed to ensure the
+        // test sessions go into the same one.
+        val newSession = sessionRule.createOpenSession()
+        mainSession.loadUri(CONTENT_CRASH_URL)
 
-        sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
-            @AssertCalled(count = 2)
-            override fun onCrash(session: GeckoSession) {
-                assertThat("Session should be closed after a crash", session.isOpen, equalTo(false))
-            }
-        });
+        // We can inadvertently catch the `onCrash` call for the cached session if we don't specify
+        // individual sessions here. Therefore, assert 'onCrash' is called for the two sessions
+        // individually.
+        val remainingSessions = mutableListOf(newSession, mainSession)
+        while (remainingSessions.isNotEmpty()) {
+            sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
+                @AssertCalled(count = 1)
+                override fun onCrash(session: GeckoSession) {
+                    remainingSessions.remove(session)
+                }
+            })
+        }
     }
 }
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt
@@ -1647,30 +1647,34 @@ class GeckoSessionTestRuleTest : BaseSes
                 delegate?.onDelegate("", ""), equalTo(42))
         sessionRule.performTestEndCheck()
     }
 
     @IgnoreCrash
     @ReuseSession(false)
     @Test fun contentCrashIgnored() {
         assumeThat(sessionRule.env.isMultiprocess, equalTo(true))
+        // Cannot test x86 debug builds due to Gecko's "ah_crap_handler"
+        // that waits for debugger to attach during a SIGSEGV.
+        assumeThat(sessionRule.env.isDebugBuild && sessionRule.env.cpuArch == "x86",
+                   equalTo(false))
 
-        // This test has some kind of strange race on ARM emulators
-        assumeThat(!(sessionRule.env.isEmulator && sessionRule.env.cpuArch.contains("arm")),
-                equalTo(true))
-
-        sessionRule.session.loadUri(CONTENT_CRASH_URL)
-        sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
+        mainSession.loadUri(CONTENT_CRASH_URL)
+        mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
             @AssertCalled(count = 1)
             override fun onCrash(session: GeckoSession) = Unit
         })
     }
 
     @Test(expected = RuntimeException::class)
     @ReuseSession(false)
     fun contentCrashFails() {
         assumeThat(sessionRule.env.isMultiprocess, equalTo(true))
-        assumeThat(sessionRule.env.shouldShutdownOnCrash(), equalTo(false));
+        assumeThat(sessionRule.env.shouldShutdownOnCrash(), equalTo(false))
+        // Cannot test x86 debug builds due to Gecko's "ah_crap_handler"
+        // that waits for debugger to attach during a SIGSEGV.
+        assumeThat(sessionRule.env.isDebugBuild && sessionRule.env.cpuArch == "x86",
+                   equalTo(false))
 
         sessionRule.session.loadUri(CONTENT_CRASH_URL)
         sessionRule.waitForPageStop()
     }
 }