Bug 1381403 - Wait for minidump files in mozcrash mockup. draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 17 Jul 2017 10:32:40 +0200
changeset 609879 74f4ebe24a3c88fd5449d1f952337e40092942ac
parent 609461 5f44d10bacca2d693413b529e0caadc73e634e1e
child 637708 a1e199aee4f40e79cc4f72b4145c19f2a9c85020
push id68724
push userbmo:hskupin@gmail.com
push dateMon, 17 Jul 2017 17:24:28 +0000
bugs1381403, 1376795
milestone56.0a1
Bug 1381403 - Wait for minidump files in mozcrash mockup. Because of bug 1376795 minidump files seem to get created with a slight delay. As such these are not present at the time when the application process is gone. Mozcrash currently doesn't detect those crashes, which causes test failures to happen in our crash unit tests. Also the tests should only run for those builds with the crash reporter enabled. If that's not the case, like for code-coverage builds, mark the test as skipped in setUp. MozReview-Commit-ID: 9VqFuLX5NHl
testing/marionette/harness/marionette_harness/tests/unit/test_crash.py
testing/marionette/harness/marionette_harness/tests/unit/unit-tests.ini
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_crash.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_crash.py
@@ -1,17 +1,21 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import glob
 import shutil
 
 from marionette_driver import Wait
-from marionette_driver.errors import MarionetteException, NoSuchWindowException
+from marionette_driver.errors import (
+    MarionetteException,
+    NoSuchWindowException,
+    TimeoutException
+)
 
 from marionette_harness import MarionetteTestCase, expectedFailure, run_if_e10s
 
 # Import runner module to monkey patch mozcrash module
 from mozrunner.base import runner
 
 
 class MockMozCrash(object):
@@ -27,20 +31,29 @@ class MockMozCrash(object):
                     getService(Components.interfaces.nsICrashReporter);
                   return true;
                 } catch (exc) {
                   return false;
                 }
             """)
 
     def check_for_crashes(self, dump_directory, *args, **kwargs):
-        minidump_files = glob.glob('{}/*.dmp'.format(dump_directory))
-        shutil.rmtree(dump_directory)
+        if self.crash_reporter_enabled:
+            # Workaround until bug 1376795 has been fixed
+            # Wait at maximum 5s for the minidump files being created
+            # minidump_files = glob.glob('{}/*.dmp'.format(dump_directory))
+            try:
+                minidump_files = Wait(None, timeout=5).until(
+                    lambda _: glob.glob('{}/*.dmp'.format(dump_directory))
+                )
+            except TimeoutException:
+                minidump_files = []
 
-        if self.crash_reporter_enabled:
+            shutil.rmtree(dump_directory)
+
             return len(minidump_files)
         else:
             return len(minidump_files) == 0
 
     def log_crashes(self, logger, dump_directory, *args, **kwargs):
         return self.check_for_crashes(dump_directory, *args, **kwargs)
 
 
@@ -48,18 +61,23 @@ class BaseCrashTestCase(MarionetteTestCa
 
     # Reduce the timeout for faster processing of the tests
     socket_timeout = 10
 
     def setUp(self):
         super(BaseCrashTestCase, self).setUp()
 
         # Monkey patch mozcrash to avoid crash info output only for our triggered crashes.
+        mozcrash_mock = MockMozCrash(self.marionette)
+        if not mozcrash_mock.crash_reporter_enabled:
+            self.skipTest('Crash reporter disabled')
+            return
+
         self.mozcrash = runner.mozcrash
-        runner.mozcrash = MockMozCrash(self.marionette)
+        runner.mozcrash = mozcrash_mock
 
         self.crash_count = self.marionette.crashed
         self.pid = self.marionette.process_id
         self.remote_uri = self.marionette.absolute_url("javascriptPage.html")
 
     def tearDown(self):
         # Replace mockup with original mozcrash instance
         runner.mozcrash = self.mozcrash
--- a/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.ini
+++ b/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.ini
@@ -115,10 +115,10 @@ skip-if = appname == 'fennec' || os == "
 [test_chrome.py]
 skip-if = appname == 'fennec'
 
 [test_addons.py]
 skip-if = appname == 'fennec' # Bug 1330598
 
 [test_select.py]
 [test_crash.py]
-skip-if = manage_instance == false || appname == 'fennec' || ccov # Bug 1298921, bug 1322993, and bug 1377876
+skip-if = manage_instance == false || appname == 'fennec' # Bug 1298921, bug 1322993
 [test_localization.py]