Remove Python 3.x version of trace-test.py. Maintaining two copies is a headache...
[mozilla-central.git] / build / automationutils.py
bloba76a992f64129a2537079888b4418d4ea9092e4a
1 import sys, glob, os, subprocess, logging
3 __all__ = [
4 "addCommonOptions",
5 "checkForCrashes",
8 log = logging.getLogger()
10 def addCommonOptions(parser, defaults={}):
11 parser.add_option("--xre-path",
12 action = "store", type = "string", dest = "xrePath",
13 # individual scripts will set a sane default
14 default = None,
15 help = "absolute path to directory containing XRE (probably xulrunner)")
16 if 'SYMBOLS_PATH' not in defaults:
17 defaults['SYMBOLS_PATH'] = None
18 parser.add_option("--symbols-path",
19 action = "store", type = "string", dest = "symbolsPath",
20 default = defaults['SYMBOLS_PATH'],
21 help = "absolute path to directory containing breakpad symbols")
23 def checkForCrashes(dumpDir, symbolsPath, testName=None):
24 stackwalkPath = os.environ.get('MINIDUMP_STACKWALK', None)
25 # try to get the caller's filename if no test name is given
26 if testName is None:
27 try:
28 testName = os.path.basename(sys._getframe(1).f_code.co_filename)
29 except:
30 testName = "unknown"
32 foundCrash = False
33 dumps = glob.glob(os.path.join(dumpDir, '*.dmp'))
34 for d in dumps:
35 log.info("TEST-UNEXPECTED-FAIL | %s | application crashed (minidump found)", testName)
36 if symbolsPath and stackwalkPath:
37 nullfd = open(os.devnull, 'w')
38 # eat minidump_stackwalk errors
39 subprocess.call([stackwalkPath, d, symbolsPath], stderr=nullfd)
40 nullfd.close()
41 os.remove(d)
42 extra = os.path.splitext(d)[0] + ".extra"
43 if os.path.exists(extra):
44 os.remove(extra)
45 foundCrash = True
46 return foundCrash