本文整理汇总了Python中mozcrash.check_for_crashes函数的典型用法代码示例。如果您正苦于以下问题:Python check_for_crashes函数的具体用法?Python check_for_crashes怎么用?Python check_for_crashes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_for_crashes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cleanupAndCheckForCrashes
def cleanupAndCheckForCrashes(self, browser_config, profile_dir, test_name):
"""cleanup browser processes and process crashes if found"""
# cleanup processes
self._ffprocess.cleanupProcesses(browser_config['process'],
browser_config['child_process'],
browser_config['browser_wait'])
# find stackwalk binary
if platform.system() in ('Windows', 'Microsoft'):
stackwalkpaths = ['win32', 'minidump_stackwalk.exe']
elif platform.system() == 'Linux':
# are we 64 bit?
if '64' in platform.architecture()[0]:
stackwalkpaths = ['linux64', 'minidump_stackwalk']
else:
stackwalkpaths = ['linux', 'minidump_stackwalk']
elif platform.system() == 'Darwin':
stackwalkpaths = ['osx', 'minidump_stackwalk']
else:
# no minidump_stackwalk available for your platform
return
stackwalkbin = os.path.join(os.path.dirname(__file__), 'breakpad', *stackwalkpaths)
assert os.path.exists(stackwalkbin), "minidump_stackwalk binary not found: %s" % stackwalkbin
if browser_config['remote'] is True:
# favour using Java exceptions in the logcat over minidumps
if os.path.exists('logcat.log'):
with open('logcat.log') as f:
logcat = f.read().split('\r')
found = mozcrash.check_for_java_exception(logcat)
remoteminidumpdir = profile_dir + '/minidumps/'
if not found:
# check for minidumps
minidumpdir = tempfile.mkdtemp()
try:
if self._ffprocess.testAgent.dirExists(remoteminidumpdir):
self._ffprocess.testAgent.getDirectory(remoteminidumpdir, minidumpdir)
except mozdevice.DMError:
print "Remote Device Error: Error getting crash minidumps from device"
raise
found = mozcrash.check_for_crashes(minidumpdir,
browser_config['symbols_path'],
stackwalk_binary=stackwalkbin,
test_name=test_name)
self._hostproc.removeDirectory(minidumpdir)
# cleanup dumps on remote
self._ffprocess.testAgent.removeDir(remoteminidumpdir)
else:
# check for minidumps
minidumpdir = os.path.join(profile_dir, 'minidumps')
found = mozcrash.check_for_crashes(minidumpdir,
browser_config['symbols_path'],
stackwalk_binary=stackwalkbin,
test_name=test_name)
if found:
raise talosCrash("Found crashes after test run, terminating test")
示例2: run_gtest
def run_gtest(self, prog, xre_path, symbols_path=None):
"""
Run a single C++ unit test program.
Arguments:
* prog: The path to the test program to run.
* env: The environment to use for running the program.
* symbols_path: A path to a directory containing Breakpad-formatted
symbol files for producing stack traces on crash.
Return True if the program exits with a zero status, False otherwise.
"""
self.xre_path = xre_path
env = self.build_environment()
log.info("Running gtest")
proc = mozprocess.ProcessHandler([prog, "-unittest"],
cwd=os.getcwd(),
env=env)
#TODO: After bug 811320 is fixed, don't let .run() kill the process,
# instead use a timeout in .wait() and then kill to get a stack.
proc.run(timeout=GTests.TEST_PROC_TIMEOUT,
outputTimeout=GTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
proc.wait()
if proc.timedOut:
log.testFail("gtest | timed out after %d seconds", GTests.TEST_PROC_TIMEOUT)
return False
if mozcrash.check_for_crashes(os.getcwd(), symbols_path, test_name="gtest"):
# mozcrash will output the log failure line for us.
return False
result = proc.proc.returncode == 0
if not result:
log.testFail("gtest | test failed with return code %d", proc.proc.returncode)
return result
示例3: run_one_test
def run_one_test(self, prog, env, symbols_path=None, interactive=False):
"""
Run a single C++ unit test program remotely.
Arguments:
* prog: The path to the test program to run.
* env: The environment to use for running the program.
* symbols_path: A path to a directory containing Breakpad-formatted
symbol files for producing stack traces on crash.
Return True if the program exits with a zero status, False otherwise.
"""
basename = os.path.basename(prog)
remote_bin = posixpath.join(self.remote_bin_dir, basename)
self.log.test_start(basename)
buf = StringIO.StringIO()
returncode = self.device.shell([remote_bin], buf, env=env, cwd=self.remote_home_dir,
timeout=cppunittests.CPPUnitTests.TEST_PROC_TIMEOUT)
self.log.process_output(basename, "\n%s" % buf.getvalue(),
command=[remote_bin])
with mozfile.TemporaryDirectory() as tempdir:
self.device.getDirectory(self.remote_home_dir, tempdir)
if mozcrash.check_for_crashes(tempdir, symbols_path,
test_name=basename):
self.log.test_end(basename, status='CRASH', expected='PASS')
return False
result = returncode == 0
if not result:
self.log.test_end(basename, status='FAIL', expected='PASS',
message=("test failed with return code %d" %
returncode))
else:
self.log.test_end(basename, status='PASS', expected='PASS')
return result
示例4: check_for_crashes
def check_for_crashes(self, dump_directory=None, dump_save_path=None, test_name=None, quiet=False):
"""
Check for a possible crash and output stack trace.
:param dump_directory: Directory to search for minidump files
:param dump_save_path: Directory to save the minidump files to
:param test_name: Name to use in the crash output
:param quiet: If `True` don't print the PROCESS-CRASH message to stdout
:returns: True if a crash was detected, otherwise False
"""
if not dump_directory:
dump_directory = os.path.join(self.profile.profile, "minidumps")
if not dump_save_path:
dump_save_path = self.dump_save_path
try:
logger = get_default_logger()
if logger is not None:
if test_name is None:
test_name = "runner.py"
self.crashed += mozcrash.log_crashes(
logger, dump_directory, self.symbols_path, dump_save_path=dump_save_path, test=test_name
)
else:
crashed = mozcrash.check_for_crashes(
dump_directory, self.symbols_path, dump_save_path=dump_save_path, test_name=test_name, quiet=quiet
)
if crashed:
self.crashed += 1
except:
traceback.print_exc()
return self.crashed
示例5: check_for_crashes
def check_for_crashes(self, dump_directory=None, dump_save_path=None,
test_name=None, quiet=False):
"""
Check for a possible crash and output stack trace.
:param dump_directory: Directory to search for minidump files
:param dump_save_path: Directory to save the minidump files to
:param test_name: Name to use in the crash output
:param quiet: If `True` don't print the PROCESS-CRASH message to stdout
:returns: True if a crash was detected, otherwise False
"""
if not dump_directory:
dump_directory = os.path.join(self.profile.profile, 'minidumps')
crashed = False
try:
crashed = mozcrash.check_for_crashes(dump_directory,
self.symbols_path,
dump_save_path=dump_save_path,
test_name=test_name,
quiet=quiet)
except:
traceback.print_exc()
return crashed
示例6: run_one_test
def run_one_test(self, prog, env, symbols_path=None):
"""
Run a single C++ unit test program.
Arguments:
* prog: The path to the test program to run.
* env: The environment to use for running the program.
* symbols_path: A path to a directory containing Breakpad-formatted
symbol files for producing stack traces on crash.
Return True if the program exits with a zero status, False otherwise.
"""
basename = os.path.basename(prog)
log.info("Running test %s", basename)
with TemporaryDirectory() as tempdir:
proc = mozprocess.ProcessHandler([prog],
cwd=tempdir,
env=env)
#TODO: After bug 811320 is fixed, don't let .run() kill the process,
# instead use a timeout in .wait() and then kill to get a stack.
proc.run(timeout=CPPUnitTests.TEST_PROC_TIMEOUT)
proc.wait()
if proc.timedOut:
log.testFail("%s | timed out after %d seconds",
basename, CPPUnitTests.TEST_PROC_TIMEOUT)
return False
if mozcrash.check_for_crashes(tempdir, symbols_path,
test_name=basename):
log.testFail("%s | test crashed", basename)
return False
result = proc.proc.returncode == 0
if not result:
log.testFail("%s | test failed with return code %d",
basename, proc.proc.returncode)
return result
示例7: run_one_test
def run_one_test(self, prog, env, symbols_path=None):
"""
Run a single C++ unit test program remotely.
Arguments:
* prog: The path to the test program to run.
* env: The environment to use for running the program.
* symbols_path: A path to a directory containing Breakpad-formatted
symbol files for producing stack traces on crash.
Return True if the program exits with a zero status, False otherwise.
"""
basename = os.path.basename(prog)
remote_bin = posixpath.join(self.remote_bin_dir, basename)
log.info("Running test %s", basename)
buf = StringIO.StringIO()
returncode = self.device.shell([remote_bin], buf, env=env, cwd=self.remote_home_dir,
timeout=cppunittests.CPPUnitTests.TEST_PROC_TIMEOUT)
print >> sys.stdout, buf.getvalue()
with mozfile.TemporaryDirectory() as tempdir:
self.device.getDirectory(self.remote_home_dir, tempdir)
if mozcrash.check_for_crashes(tempdir, symbols_path,
test_name=basename):
log.testFail("%s | test crashed", basename)
return False
result = returncode == 0
if not result:
log.testFail("%s | test failed with return code %s",
basename, returncode)
return result
示例8: test_symbol_path_url
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():
data = StringIO.StringIO()
z = zipfile.ZipFile(data, 'w')
z.writestr("symbols.txt", "abc/xyz")
z.close()
return data.getvalue()
def get_symbols(req):
headers = {}
return (200, headers, make_zipfile())
httpd = mozhttpd.MozHttpd(port=0,
urlhandlers=[{'method':'GET', 'path':'/symbols', 'function':get_symbols}])
httpd.start()
symbol_url = urlparse.urlunsplit(('http', '%s:%d' % httpd.httpd.server_address,
'/symbols','',''))
self.assert_(mozcrash.check_for_crashes(self.tempdir,
symbol_url,
stackwalk_binary=self.stackwalk,
quiet=True))
示例9: test_symbol_path_not_present
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))
示例10: test_nodumps
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',
stackwalk_binary=self.stackwalk))
示例11: check_for_crashes
def check_for_crashes(self, browser_config, profile_dir, test_name):
# check for minidumps
minidumpdir = os.path.join(profile_dir, "minidumps")
found = mozcrash.check_for_crashes(minidumpdir, browser_config["symbols_path"], test_name=test_name)
mozfile.remove(minidumpdir)
if found:
raise TalosCrash("Found crashes after test run, terminating test")
示例12: run_gtest
def run_gtest(self, prog, xre_path, cwd, symbols_path=None,
utility_path=None):
"""
Run a single C++ unit test program.
Arguments:
* prog: The path to the test program to run.
* env: The environment to use for running the program.
* cwd: The directory to run tests from (support files will be found
in this direcotry).
* symbols_path: A path to a directory containing Breakpad-formatted
symbol files for producing stack traces on crash.
* utility_path: A path to a directory containing utility programs.
currently used to locate a stack fixer to provide
symbols symbols for assertion stacks.
Return True if the program exits with a zero status, False otherwise.
"""
self.xre_path = xre_path
env = self.build_environment()
log.info("Running gtest")
if cwd and not os.path.isdir(cwd):
os.makedirs(cwd)
stream_output = mozprocess.StreamOutput(sys.stdout)
process_output = stream_output
if utility_path:
stack_fixer = get_stack_fixer_function(utility_path, symbols_path)
if stack_fixer:
process_output = lambda line: stream_output(stack_fixer(line))
proc = mozprocess.ProcessHandler([prog, "-unittest",
"--gtest_death_test_style=threadsafe"],
cwd=cwd,
env=env,
processOutputLine=process_output)
#TODO: After bug 811320 is fixed, don't let .run() kill the process,
# instead use a timeout in .wait() and then kill to get a stack.
proc.run(timeout=GTests.TEST_PROC_TIMEOUT,
outputTimeout=GTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
proc.wait()
if proc.timedOut:
if proc.outputTimedOut:
log.testFail("gtest | timed out after %d seconds without output",
GTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
else:
log.testFail("gtest | timed out after %d seconds",
GTests.TEST_PROC_TIMEOUT)
return False
if mozcrash.check_for_crashes(cwd, symbols_path, test_name="gtest"):
# mozcrash will output the log failure line for us.
return False
result = proc.proc.returncode == 0
if not result:
log.testFail("gtest | test failed with return code %d", proc.proc.returncode)
return result
示例13: check_for_crashes
def check_for_crashes(self, browser_config, minidump_dir, test_name):
# check for minidumps
found = mozcrash.check_for_crashes(minidump_dir,
browser_config['symbols_path'],
test_name=test_name)
mozfile.remove(minidump_dir)
if found:
raise TalosCrash("Found crashes after test run, terminating test")
示例14: test_simple
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',
stackwalk_binary=self.stackwalk))
示例15: check_for_crashes
def check_for_crashes(self, dump_directory, test_name=None):
crashed = False
try:
crashed = mozcrash.check_for_crashes(dump_directory,
self.symbols_path,
test_name=test_name)
except:
traceback.print_exc()
return crashed