--- a/testing/mozbase/mozcrash/mozcrash/mozcrash.py
+++ b/testing/mozbase/mozcrash/mozcrash/mozcrash.py
@@ -39,17 +39,17 @@ StackInfo = namedtuple("StackInfo",
def get_logger():
structured_logger = mozlog.get_default_logger("mozcrash")
if structured_logger is None:
return mozlog.unstructured.getLogger('mozcrash')
return structured_logger
def check_for_crashes(dump_directory,
- symbols_path,
+ symbols_path=None,
stackwalk_binary=None,
dump_save_path=None,
test_name=None,
quiet=False):
"""
Print a stack trace for minidump files left behind by a crashing program.
`dump_directory` will be searched for minidump files. Any minidump files found will
@@ -158,18 +158,24 @@ class CrashInfo(object):
if stackwalk_binary is None:
stackwalk_binary = os.environ.get('MINIDUMP_STACKWALK', None)
self.stackwalk_binary = stackwalk_binary
self.logger = get_logger()
self._dump_files = None
def _get_symbols(self):
- # This updates self.symbols_path so we only download once
- if self.symbols_path and mozfile.is_url(self.symbols_path):
+ # If no symbols path has been set create a temporary folder to let the
+ # minidump stackwalk download the symbols.
+ if not self.symbols_path:
+ self.symbols_path = tempfile.mkdtemp()
+ self.remove_symbols = True
+
+ # This updates self.symbols_path so we only download once.
+ if mozfile.is_url(self.symbols_path):
self.remove_symbols = True
self.logger.info("Downloading symbols from: %s" % self.symbols_path)
# Get the symbols and write them to a temporary zipfile
data = urllib2.urlopen(self.symbols_path)
with tempfile.TemporaryFile() as symbols_file:
symbols_file.write(data.read())
# extract symbols to a temporary directory (which we'll delete after
# processing all crashes)
--- a/testing/mozbase/mozcrash/tests/test.py
+++ b/testing/mozbase/mozcrash/tests/test.py
@@ -51,70 +51,70 @@ class TestCrash(unittest.TestCase):
yield iter(s)
def test_nodumps(self):
"""
Test that check_for_crashes returns False if no dumps are present.
"""
self.stdouts.append(["this is some output"])
self.assertFalse(mozcrash.check_for_crashes(self.tempdir,
- 'symbols_path',
+ symbols_path='symbols_path',
stackwalk_binary=self.stackwalk,
quiet=True))
def test_simple(self):
"""
Test that check_for_crashes returns True if a dump is present.
"""
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
self.stdouts.append(["this is some output"])
self.assert_(mozcrash.check_for_crashes(self.tempdir,
- 'symbols_path',
+ symbols_path='symbols_path',
stackwalk_binary=self.stackwalk,
quiet=True))
def test_stackwalk_envvar(self):
"""
Test that check_for_crashes uses the MINIDUMP_STACKWALK environment var.
"""
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
self.stdouts.append(["this is some output"])
os.environ['MINIDUMP_STACKWALK'] = self.stackwalk
self.assert_(mozcrash.check_for_crashes(self.tempdir,
- 'symbols_path',
+ symbols_path='symbols_path',
quiet=True))
del os.environ['MINIDUMP_STACKWALK']
def test_save_path(self):
"""
Test that dump_save_path works.
"""
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
open(os.path.join(self.tempdir, "test.extra"), "w").write("bar")
save_path = os.path.join(self.tempdir, "saved")
os.mkdir(save_path)
self.stdouts.append(["this is some output"])
self.assert_(mozcrash.check_for_crashes(self.tempdir,
- 'symbols_path',
+ symbols_path='symbols_path',
stackwalk_binary=self.stackwalk,
dump_save_path=save_path,
quiet=True))
self.assert_(os.path.isfile(os.path.join(save_path, "test.dmp")))
self.assert_(os.path.isfile(os.path.join(save_path, "test.extra")))
def test_save_path_not_present(self):
"""
Test that dump_save_path works when the directory doesn't exist.
"""
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
open(os.path.join(self.tempdir, "test.extra"), "w").write("bar")
save_path = os.path.join(self.tempdir, "saved")
self.stdouts.append(["this is some output"])
self.assert_(mozcrash.check_for_crashes(self.tempdir,
- 'symbols_path',
+ symbols_path='symbols_path',
stackwalk_binary=self.stackwalk,
dump_save_path=save_path,
quiet=True))
self.assert_(os.path.isfile(os.path.join(save_path, "test.dmp")))
self.assert_(os.path.isfile(os.path.join(save_path, "test.extra")))
def test_save_path_isfile(self):
"""
@@ -122,17 +122,17 @@ class TestCrash(unittest.TestCase):
but a file with the same name exists.
"""
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
open(os.path.join(self.tempdir, "test.extra"), "w").write("bar")
save_path = os.path.join(self.tempdir, "saved")
open(save_path, "w").write("junk")
self.stdouts.append(["this is some output"])
self.assert_(mozcrash.check_for_crashes(self.tempdir,
- 'symbols_path',
+ symbols_path='symbols_path',
stackwalk_binary=self.stackwalk,
dump_save_path=save_path,
quiet=True))
self.assert_(os.path.isfile(os.path.join(save_path, "test.dmp")))
self.assert_(os.path.isfile(os.path.join(save_path, "test.extra")))
def test_save_path_envvar(self):
"""
@@ -140,23 +140,31 @@ class TestCrash(unittest.TestCase):
"""
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
open(os.path.join(self.tempdir, "test.extra"), "w").write("bar")
save_path = os.path.join(self.tempdir, "saved")
os.mkdir(save_path)
self.stdouts.append(["this is some output"])
os.environ['MINIDUMP_SAVE_PATH'] = save_path
self.assert_(mozcrash.check_for_crashes(self.tempdir,
- 'symbols_path',
+ symbols_path='symbols_path',
stackwalk_binary=self.stackwalk,
quiet=True))
del os.environ['MINIDUMP_SAVE_PATH']
self.assert_(os.path.isfile(os.path.join(save_path, "test.dmp")))
self.assert_(os.path.isfile(os.path.join(save_path, "test.extra")))
+ def test_symbol_path_not_present(self):
+ open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
+ self.stdouts.append(["this is some output"])
+ self.assert_(mozcrash.check_for_crashes(self.tempdir,
+ symbols_path=None,
+ stackwalk_binary=self.stackwalk,
+ quiet=True))
+
def test_symbol_path_url(self):
"""
Test that passing a URL as symbols_path correctly fetches the URL.
"""
open(os.path.join(self.tempdir, "test.dmp"), "w").write("foo")
self.stdouts.append(["this is some output"])
def make_zipfile():