Bug 978066 - [mozcrash] Mozcrash check_for_java_exception function should take quiet parameter; r=wlach

This commit is contained in:
Dan Minor 2014-02-28 09:18:25 -05:00
parent dfb5c2e301
commit bb9160e97c
2 changed files with 10 additions and 6 deletions

View File

@ -161,7 +161,7 @@ def check_for_crashes(dump_directory, symbols_path,
return True
def check_for_java_exception(logcat):
def check_for_java_exception(logcat, quiet=False):
"""
Print a summary of a fatal Java exception, if present in the provided
logcat output.
@ -171,6 +171,9 @@ def check_for_java_exception(logcat):
`logcat` should be a list of strings.
If `quiet` is set, no PROCESS-CRASH message will be printed to stdout if a
crash is detected.
Returns True if a fatal Java exception was found, False otherwise.
"""
found_exception = False
@ -194,6 +197,7 @@ def check_for_java_exception(logcat):
m = logre.search(logcat[i+2])
if m and m.group(1):
exception_location = m.group(1)
if not quiet:
print "PROCESS-CRASH | java-exception | %s %s" % (exception_type, exception_location)
else:
print "Automation Error: Logcat is truncated!"

View File

@ -187,7 +187,7 @@ class TestJavaException(unittest.TestCase):
"""
Test for an exception which should be caught
"""
self.assert_(mozcrash.check_for_java_exception(self.test_log))
self.assert_(mozcrash.check_for_java_exception(self.test_log, quiet=True))
def test_fatal_exception(self):
"""
@ -195,7 +195,7 @@ class TestJavaException(unittest.TestCase):
"""
fatal_log = list(self.test_log)
fatal_log[0] = "01-30 20:15:41.937 E/GeckoAppShell( 1703): >>> FATAL EXCEPTION FROM THREAD 9 (\"GeckoBackgroundThread\")"
self.assert_(mozcrash.check_for_java_exception(fatal_log))
self.assert_(mozcrash.check_for_java_exception(fatal_log, quiet=True))
def test_truncated_exception(self):
"""
@ -204,7 +204,7 @@ class TestJavaException(unittest.TestCase):
"""
truncated_log = list(self.test_log)
truncated_log[0], truncated_log[1] = truncated_log[1], truncated_log[0]
self.assert_(mozcrash.check_for_java_exception(truncated_log))
self.assert_(mozcrash.check_for_java_exception(truncated_log, quiet=True))
def test_unchecked_exception(self):
"""
@ -212,7 +212,7 @@ class TestJavaException(unittest.TestCase):
"""
passable_log = list(self.test_log)
passable_log[0] = "01-30 20:15:41.937 E/GeckoAppShell( 1703): >>> NOT-SO-BAD EXCEPTION FROM THREAD 9 (\"GeckoBackgroundThread\")"
self.assert_(not mozcrash.check_for_java_exception(passable_log))
self.assert_(not mozcrash.check_for_java_exception(passable_log, quiet=True))
if __name__ == '__main__':
unittest.main()