Bug 1238305: Modify cppunittests to look up breakpad symbols for logged stack traces; r=ted

MozReview-Commit-ID: LnqEVRqYYFZ

--HG--
extra : rebase_source : 49cf7894832c9b1ccf63380bed89cb82cc322dfb
This commit is contained in:
Aaron Klotz 2016-01-12 12:58:59 -07:00
Родитель 71a877d360
Коммит 117d3269f1
5 изменённых файлов: 28 добавлений и 5 удалений

Просмотреть файл

@ -376,14 +376,18 @@ class MachCommands(MachCommandBase):
else:
manifest_path = None
utility_path = self.bindir
if conditions.is_android(self):
from mozrunner.devices.android_device import verify_android_device
verify_android_device(self, install=False)
return self.run_android_test(tests, symbols_path, manifest_path, log)
return self.run_desktop_test(tests, symbols_path, manifest_path, log)
return self.run_desktop_test(tests, symbols_path, manifest_path,
utility_path, log)
def run_desktop_test(self, tests, symbols_path, manifest_path, log):
def run_desktop_test(self, tests, symbols_path, manifest_path, utility_path,
log):
import runcppunittests as cppunittests
from mozlog import commandline
@ -393,6 +397,7 @@ class MachCommands(MachCommandBase):
options.symbols_path = symbols_path
options.manifest_path = manifest_path
options.utility_path = utility_path
options.xre_path = self.bindir
try:

Просмотреть файл

@ -80,6 +80,7 @@ config = {
"cppunittest": {
"options": [
"--symbols-path=%(symbols_path)s",
"--utility-path=tests/bin",
"--xre-path=%(abs_app_dir)s"
],
"run_filename": "runcppunittests.py",

Просмотреть файл

@ -57,6 +57,7 @@ config = {
"cppunittest": {
"options": [
"--symbols-path=%(symbols_path)s",
"--utility-path=tests/bin",
"--xre-path=%(abs_res_dir)s"
],
"run_filename": "runcppunittests.py",

Просмотреть файл

@ -68,6 +68,7 @@ config = {
"cppunittest": {
"options": [
"--symbols-path=%(symbols_path)s",
"--utility-path=tests/bin",
"--xre-path=%(abs_app_dir)s"
],
"run_filename": "runcppunittests.py",

Просмотреть файл

@ -14,6 +14,7 @@ import mozcrash
import mozfile
import mozlog
from contextlib import contextmanager
from mozrunner.utils import get_stack_fixer_function
from subprocess import PIPE
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
@ -60,7 +61,11 @@ class CPPUnitTests(object):
outputTimeout=CPPUnitTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
proc.wait()
if proc.output:
output = "\n%s" % "\n".join(proc.output)
if self.fix_stack:
procOutput = [self.fix_stack(l) for l in proc.output]
else:
procOutput = proc.output
output = "\n%s" % "\n".join(procOutput)
self.log.process_output(proc.pid, output, command=[prog])
if proc.timedOut:
message = "timed out after %d seconds" % CPPUnitTests.TEST_PROC_TIMEOUT
@ -137,7 +142,7 @@ class CPPUnitTests(object):
return env
def run_tests(self, programs, xre_path, symbols_path=None, interactive=False):
def run_tests(self, programs, xre_path, symbols_path=None, utility_path=None, interactive=False):
"""
Run a set of C++ unit test programs.
@ -146,12 +151,16 @@ class CPPUnitTests(object):
* xre_path: A path to a directory containing a XUL Runtime Environment.
* 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
(xpcshell et al)
Returns True if all test programs exited with a zero status, False
otherwise.
"""
self.xre_path = xre_path
self.log = mozlog.get_default_logger()
if utility_path:
self.fix_stack = get_stack_fixer_function(utility_path, symbols_path)
self.log.suite_start(programs)
env = self.build_environment()
pass_count = 0
@ -188,6 +197,10 @@ class CPPUnittestOptions(OptionParser):
action = "store", type = "string", dest = "manifest_path",
default = None,
help = "path to test manifest, if different from the path to test binaries")
self.add_option("--utility-path",
action = "store", type = "string", dest = "utility_path",
default = None,
help = "path to directory containing utility programs")
def extract_unittests_from_args(args, environ, manifest_path):
"""Extract unittests from args, expanding directories as needed"""
@ -239,8 +252,10 @@ def run_test_harness(options, args):
update_mozinfo()
progs = extract_unittests_from_args(args, mozinfo.info, options.manifest_path)
options.xre_path = os.path.abspath(options.xre_path)
options.utility_path = os.path.abspath(options.utility_path)
tester = CPPUnitTests()
result = tester.run_tests(progs, options.xre_path, options.symbols_path)
result = tester.run_tests(progs, options.xre_path, options.symbols_path,
options.utility_path)
return result