mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1299216 - [mozrunner] check_for_crashes() has to return the crash count since its last invocation. r=ahal
Adapt check_for_crashes() for latest mozcrash changes, which returns the number of crashes for both log_crashes() and check_for_crashes() now. Also the runner should accumulate the number of crashes so it will be known at any time how many times the process has been crashed. MozReview-Commit-ID: Dl9FlH1TalH --HG-- extra : rebase_source : b27895482fcad099cf4fcfc01a65fe0fbc5243e3
This commit is contained in:
parent
659bb474d2
commit
c2cf729145
@ -41,6 +41,8 @@ class BaseRunner(object):
|
|||||||
self.profile = profile or self.app_ctx.profile_class(**getattr(self.app_ctx,
|
self.profile = profile or self.app_ctx.profile_class(**getattr(self.app_ctx,
|
||||||
'profile_args', {}))
|
'profile_args', {}))
|
||||||
|
|
||||||
|
self.logger = get_default_logger()
|
||||||
|
|
||||||
# process environment
|
# process environment
|
||||||
if env is None:
|
if env is None:
|
||||||
self.env = os.environ.copy()
|
self.env = os.environ.copy()
|
||||||
@ -99,9 +101,8 @@ class BaseRunner(object):
|
|||||||
if debug_args:
|
if debug_args:
|
||||||
cmd = list(debug_args) + cmd
|
cmd = list(debug_args) + cmd
|
||||||
|
|
||||||
logger = get_default_logger()
|
if self.logger:
|
||||||
if logger:
|
self.logger.info('Application command: %s' % ' '.join(cmd))
|
||||||
logger.info('Application command: %s' % ' '.join(cmd))
|
|
||||||
if interactive:
|
if interactive:
|
||||||
self.process_handler = subprocess.Popen(cmd, env=self.env)
|
self.process_handler = subprocess.Popen(cmd, env=self.env)
|
||||||
# TODO: other arguments
|
# TODO: other arguments
|
||||||
@ -179,51 +180,51 @@ class BaseRunner(object):
|
|||||||
|
|
||||||
def check_for_crashes(self, dump_directory=None, dump_save_path=None,
|
def check_for_crashes(self, dump_directory=None, dump_save_path=None,
|
||||||
test_name=None, quiet=False):
|
test_name=None, quiet=False):
|
||||||
"""
|
"""Check for possible crashes and output the stack traces.
|
||||||
Check for a possible crash and output stack trace.
|
|
||||||
|
|
||||||
:param dump_directory: Directory to search for minidump files
|
:param dump_directory: Directory to search for minidump files
|
||||||
:param dump_save_path: Directory to save the minidump files to
|
:param dump_save_path: Directory to save the minidump files to
|
||||||
:param test_name: Name to use in the crash output
|
:param test_name: Name to use in the crash output
|
||||||
:param quiet: If `True` don't print the PROCESS-CRASH message to stdout
|
:param quiet: If `True` don't print the PROCESS-CRASH message to stdout
|
||||||
:returns: True if a crash was detected, otherwise False
|
|
||||||
|
:returns: Number of crashes which have been detected since the last invocation
|
||||||
"""
|
"""
|
||||||
|
crash_count = 0
|
||||||
|
|
||||||
if not dump_directory:
|
if not dump_directory:
|
||||||
dump_directory = os.path.join(self.profile.profile, 'minidumps')
|
dump_directory = os.path.join(self.profile.profile, 'minidumps')
|
||||||
|
|
||||||
if not dump_save_path:
|
if not dump_save_path:
|
||||||
dump_save_path = self.dump_save_path
|
dump_save_path = self.dump_save_path
|
||||||
|
|
||||||
|
if not test_name:
|
||||||
|
test_name = "runner.py"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger = get_default_logger()
|
if self.logger:
|
||||||
if logger is not None:
|
|
||||||
if test_name is None:
|
|
||||||
test_name = "runner.py"
|
|
||||||
if mozcrash:
|
if mozcrash:
|
||||||
self.crashed += mozcrash.log_crashes(
|
crash_count = mozcrash.log_crashes(
|
||||||
logger,
|
self.logger,
|
||||||
dump_directory,
|
dump_directory,
|
||||||
self.symbols_path,
|
self.symbols_path,
|
||||||
dump_save_path=dump_save_path,
|
dump_save_path=dump_save_path,
|
||||||
test=test_name)
|
test=test_name)
|
||||||
else:
|
else:
|
||||||
logger.warning("Can not log crashes without mozcrash")
|
self.logger.warning("Can not log crashes without mozcrash")
|
||||||
else:
|
else:
|
||||||
if mozcrash:
|
if mozcrash:
|
||||||
crashed = mozcrash.check_for_crashes(
|
crash_count = mozcrash.check_for_crashes(
|
||||||
dump_directory,
|
dump_directory,
|
||||||
self.symbols_path,
|
self.symbols_path,
|
||||||
dump_save_path=dump_save_path,
|
dump_save_path=dump_save_path,
|
||||||
test_name=test_name,
|
test_name=test_name,
|
||||||
quiet=quiet)
|
quiet=quiet)
|
||||||
if crashed:
|
|
||||||
self.crashed += 1
|
self.crashed += crash_count
|
||||||
else:
|
|
||||||
logger.warning("Can not log crashes without mozcrash")
|
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
return self.crashed
|
return crash_count
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
[test_crash.py]
|
||||||
[test_interactive.py]
|
[test_interactive.py]
|
||||||
[test_start.py]
|
[test_start.py]
|
||||||
[test_states.py]
|
[test_states.py]
|
||||||
|
37
testing/mozbase/mozrunner/tests/test_crash.py
Normal file
37
testing/mozbase/mozrunner/tests/test_crash.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# 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 mock
|
||||||
|
|
||||||
|
import mozrunnertest
|
||||||
|
|
||||||
|
|
||||||
|
class MozrunnerCrashTestCase(mozrunnertest.MozrunnerTestCase):
|
||||||
|
|
||||||
|
@mock.patch('mozcrash.log_crashes', return_value=2)
|
||||||
|
def test_crash_count_with_logger(self, log_crashes):
|
||||||
|
self.assertEqual(self.runner.crashed, 0)
|
||||||
|
self.assertEqual(self.runner.check_for_crashes(), 2)
|
||||||
|
self.assertEqual(self.runner.crashed, 2)
|
||||||
|
self.assertEqual(self.runner.check_for_crashes(), 2)
|
||||||
|
self.assertEqual(self.runner.crashed, 4)
|
||||||
|
|
||||||
|
log_crashes.return_value = 0
|
||||||
|
self.assertEqual(self.runner.check_for_crashes(), 0)
|
||||||
|
self.assertEqual(self.runner.crashed, 4)
|
||||||
|
|
||||||
|
@mock.patch('mozcrash.check_for_crashes', return_value=2)
|
||||||
|
def test_crash_count_without_logger(self, check_for_crashes):
|
||||||
|
self.runner.logger = None
|
||||||
|
|
||||||
|
self.assertEqual(self.runner.crashed, 0)
|
||||||
|
self.assertEqual(self.runner.check_for_crashes(), 2)
|
||||||
|
self.assertEqual(self.runner.crashed, 2)
|
||||||
|
self.assertEqual(self.runner.check_for_crashes(), 2)
|
||||||
|
self.assertEqual(self.runner.crashed, 4)
|
||||||
|
|
||||||
|
check_for_crashes.return_value = 0
|
||||||
|
self.assertEqual(self.runner.check_for_crashes(), 0)
|
||||||
|
self.assertEqual(self.runner.crashed, 4)
|
Loading…
Reference in New Issue
Block a user