本文整理汇总了Python中mozhttpd.MozHttpd.stop方法的典型用法代码示例。如果您正苦于以下问题:Python MozHttpd.stop方法的具体用法?Python MozHttpd.stop怎么用?Python MozHttpd.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozhttpd.MozHttpd
的用法示例。
在下文中一共展示了MozHttpd.stop方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FixtureServer
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
class FixtureServer(object):
def __init__(self, root, host="127.0.0.1", port=0):
if not os.path.isdir(root):
raise Exception("Server root is not a valid path: %s" % root)
self.root = root
self.host = host
self.port = port
self._server = None
def start(self, block=False):
if self.alive:
return
self._server = MozHttpd(host=self.host, port=self.port, docroot=self.root, urlhandlers=[
{"method": "POST", "path": "/file_upload", "function": upload_handler}])
self._server.start(block=block)
self.port = self._server.httpd.server_port
self.base_url = self.get_url()
def stop(self):
if not self.alive:
return
self._server.stop()
self._server = None
@property
def alive(self):
return self._server is not None
def get_url(self, path="/"):
if not self.alive:
raise "Server not started"
return self._server.get_url(path)
@property
def urlhandlers(self):
return self._server.urlhandlers
示例2: MarionetteTestRunner
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
#.........这里部分代码省略.........
testgroup.submit()
def run_tests(self, tests, testtype=None):
self.reset_test_stats()
starttime = datetime.utcnow()
for test in tests:
self.run_test(test, testtype)
self.logger.info('\nSUMMARY\n-------')
self.logger.info('passed: %d' % self.passed)
self.logger.info('failed: %d' % self.failed)
self.logger.info('todo: %d' % self.todo)
elapsedtime = datetime.utcnow() - starttime
if self.autolog:
self.post_to_autolog(elapsedtime)
if self.marionette.emulator:
self.marionette.emulator.close()
self.marionette.emulator = None
self.marionette = None
def run_test(self, test, testtype):
if not self.httpd:
self.start_httpd()
if not self.marionette:
self.start_marionette()
filepath = os.path.abspath(test)
if os.path.isdir(filepath):
for root, dirs, files in os.walk(filepath):
for filename in files:
if ((filename.startswith('test_') or filename.startswith('browser_')) and
(filename.endswith('.py') or filename.endswith('.js'))):
filepath = os.path.join(root, filename)
self.run_test(filepath, testtype)
return
mod_name,file_ext = os.path.splitext(os.path.split(filepath)[-1])
testloader = unittest.TestLoader()
suite = unittest.TestSuite()
if file_ext == '.ini':
if testtype is not None:
testargs = {}
testtypes = testtype.replace('+', ' +').replace('-', ' -').split()
for atype in testtypes:
if atype.startswith('+'):
testargs.update({ atype[1:]: 'true' })
elif atype.startswith('-'):
testargs.update({ atype[1:]: 'false' })
else:
testargs.update({ atype: 'true' })
manifest = TestManifest()
manifest.read(filepath)
if testtype is None:
manifest_tests = manifest.get()
else:
manifest_tests = manifest.get(**testargs)
for i in manifest_tests:
self.run_test(i["path"], testtype)
return
self.logger.info('TEST-START %s' % os.path.basename(test))
if file_ext == '.py':
test_mod = imp.load_source(mod_name, filepath)
for name in dir(test_mod):
obj = getattr(test_mod, name)
if (isinstance(obj, (type, types.ClassType)) and
issubclass(obj, unittest.TestCase)):
testnames = testloader.getTestCaseNames(obj)
for testname in testnames:
suite.addTest(obj(self.marionette, methodName=testname))
elif file_ext == '.js':
suite.addTest(MarionetteJSTestCase(self.marionette, jsFile=filepath))
if suite.countTestCases():
results = MarionetteTextTestRunner(verbosity=3).run(suite)
self.failed += len(results.failures) + len(results.errors)
self.todo = 0
if hasattr(results, 'skipped'):
self.todo += len(results.skipped) + len(results.expectedFailures)
self.passed += results.passed
for failure in results.failures + results.errors:
self.failures.append((results.getInfo(failure[0]), failure[1], 'TEST-UNEXPECTED-FAIL'))
if hasattr(results, 'unexpectedSuccess'):
self.failed += len(results.unexpectedSuccesses)
for failure in results.unexpectedSuccesses:
self.failures.append((results.getInfo(failure[0]), failure[1], 'TEST-UNEXPECTED-PASS'))
def cleanup(self):
if self.httpd:
self.httpd.stop()
__del__ = cleanup
示例3: valgrind_test
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
#.........这里部分代码省略.........
locations = ServerLocations()
locations.add_host(host='127.0.0.1',
port=httpd.httpd.server_port,
options='primary')
profile = FirefoxProfile(profile=profilePath,
preferences=prefs,
addons=[quitter],
locations=locations)
firefox_args = [httpd.get_url()]
env = os.environ.copy()
env['G_SLICE'] = 'always-malloc'
env['MOZ_CC_RUN_DURING_SHUTDOWN'] = '1'
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
env['XPCOM_DEBUG_BREAK'] = 'warn'
env.update(self.extra_environment_variables)
outputHandler = OutputHandler()
kp_kwargs = {'processOutputLine': [outputHandler]}
valgrind = 'valgrind'
if not os.path.exists(valgrind):
valgrind = findInPath(valgrind)
valgrind_args = [
valgrind,
'--smc-check=all-non-file',
'--vex-iropt-register-updates=allregs-at-mem-access',
'--gen-suppressions=all',
'--num-callers=36',
'--leak-check=full',
'--show-possibly-lost=no',
'--track-origins=yes',
'--trace-children=yes',
# The gstreamer plugin scanner can run as part of executing
# firefox, but is an external program. In some weird cases,
# valgrind finds errors while executing __libc_freeres when
# it runs, but those are not relevant, as it's related to
# executing third party code. So don't trace
# gst-plugin-scanner.
'--trace-children-skip=*/gst-plugin-scanner',
'-v', # Enable verbosity to get the list of used suppressions
]
for s in suppressions:
valgrind_args.append('--suppressions=' + s)
supps_dir = os.path.join(build_dir, 'valgrind')
supps_file1 = os.path.join(supps_dir, 'cross-architecture.sup')
valgrind_args.append('--suppressions=' + supps_file1)
# MACHTYPE is an odd bash-only environment variable that doesn't
# show up in os.environ, so we have to get it another way.
machtype = subprocess.check_output(['bash', '-c', 'echo $MACHTYPE']).rstrip()
supps_file2 = os.path.join(supps_dir, machtype + '.sup')
if os.path.isfile(supps_file2):
valgrind_args.append('--suppressions=' + supps_file2)
exitcode = None
timeout = 1100
try:
runner = FirefoxRunner(profile=profile,
binary=self.get_binary_path(),
cmdargs=firefox_args,
env=env,
process_args=kp_kwargs)
runner.start(debug_args=valgrind_args)
# This timeout is slightly less than the no-output timeout on
# TBPL, so we'll timeout here first and give an informative
# message.
exitcode = runner.wait(timeout=timeout)
finally:
errs = outputHandler.error_count
supps = outputHandler.suppression_count
if errs != supps:
status = 1 # turns the TBPL job orange
print('TEST-UNEXPECTED-FAIL | valgrind-test | error parsing: {} errors seen, but {} generated suppressions seen'.format(errs, supps))
elif errs == 0:
status = 0
print('TEST-PASS | valgrind-test | valgrind found no errors')
else:
status = 1 # turns the TBPL job orange
# We've already printed details of the errors.
if exitcode == None:
status = 2 # turns the TBPL job red
print('TEST-UNEXPECTED-FAIL | valgrind-test | Valgrind timed out (reached {} second limit)'.format(timeout))
elif exitcode != 0:
status = 2 # turns the TBPL job red
print('TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code from Valgrind')
httpd.stop()
return status
示例4: FirefoxRunner
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
preferences=prefs,
addons=[os.path.join(build.distdir, 'xpi-stage', 'quitter')],
locations=locations)
env = os.environ.copy()
env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
env["XPCOM_DEBUG_BREAK"] = "warn"
# For VC12, make sure we can find the right bitness of pgort120.dll
if "VS120COMNTOOLS" in env and not substs["HAVE_64BIT_OS"]:
vc12dir = os.path.abspath(os.path.join(env["VS120COMNTOOLS"],
"../../VC/bin"))
if os.path.exists(vc12dir):
env["PATH"] = vc12dir + ";" + env["PATH"]
jarlog = os.getenv("JARLOG_FILE")
if jarlog:
env["MOZ_JAR_LOG_FILE"] = os.path.abspath(jarlog)
print "jarlog: %s" % env["MOZ_JAR_LOG_FILE"]
cmdargs = ["http://localhost:%d/index.html" % PORT]
runner = FirefoxRunner(profile=profile,
binary=build.get_binary_path(where="staged-package"),
cmdargs=cmdargs,
env=env)
runner.start(debug_args=debug_args, interactive=interactive)
runner.wait()
httpd.stop()
finally:
shutil.rmtree(profilePath)
示例5: MarionetteTestRunner
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
#.........这里部分代码省略.........
handler.add_tests_to_suite(mod_name,
filepath,
suite,
testloader,
self.marionette,
self.testvars,
**self.test_kwargs)
break
if suite.countTestCases():
runner = self.textrunnerclass(verbosity=3,
marionette=self.marionette)
results = runner.run(suite)
self.results.append(results)
self.failed += len(results.failures) + len(results.errors)
if hasattr(results, 'skipped'):
self.todo += len(results.skipped)
self.passed += results.passed
for failure in results.failures + results.errors:
self.failures.append((results.getInfo(failure[0]), failure[1], 'TEST-UNEXPECTED-FAIL'))
if hasattr(results, 'unexpectedSuccesses'):
self.failed += len(results.unexpectedSuccesses)
for failure in results.unexpectedSuccesses:
self.failures.append((results.getInfo(failure), 'TEST-UNEXPECTED-PASS'))
if hasattr(results, 'expectedFailures'):
self.passed += len(results.expectedFailures)
def register_handlers(self):
self.test_handlers.extend([MarionetteTestCase, MarionetteJSTestCase])
def cleanup(self):
if self.httpd:
self.httpd.stop()
__del__ = cleanup
def generate_xml(self, results_list):
def _extract_xml(test, text='', result='passed'):
cls_name = test.__class__.__name__
testcase = doc.createElement('testcase')
testcase.setAttribute('classname', cls_name)
testcase.setAttribute('name', unicode(test).split()[0])
testcase.setAttribute('time', str(test.duration))
testsuite.appendChild(testcase)
if result in ['failure', 'error', 'skipped']:
f = doc.createElement(result)
f.setAttribute('message', 'test %s' % result)
f.appendChild(doc.createTextNode(text))
testcase.appendChild(f)
doc = dom.Document()
testsuite = doc.createElement('testsuite')
testsuite.setAttribute('name', 'Marionette')
testsuite.setAttribute('time', str(self.elapsedtime.total_seconds()))
testsuite.setAttribute('tests', str(sum([results.testsRun for
results in results_list])))
def failed_count(results):
count = len(results.failures)
if hasattr(results, 'unexpectedSuccesses'):
count += len(results.unexpectedSuccesses)
示例6: Peptest
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
class Peptest():
"""
Peptest
Runs and logs tests designed to test responsiveness
"""
profile_class = Profile
runner_class = Runner
def __init__(self, options, **kwargs):
self.options = options
self.server = None
self.logger = mozlog.getLogger('PEP')
# create the profile
enable_proxy = False
locations = ServerLocations()
if self.options.proxyLocations:
if not self.options.serverPath:
self.logger.warning('Can\'t set up proxy without server path')
else:
enable_proxy = True
for proxyLocation in self.options.proxyLocations:
locations.read(proxyLocation, False)
locations.add_host(host='127.0.0.1',
port=self.options.serverPort,
options='primary,privileged')
self.profile = self.profile_class(profile=self.options.profilePath,
addons=[os.path.join(here, 'extension')],
locations=locations,
proxy=enable_proxy)
# fork a server to serve the test related files
if self.options.serverPath:
self.runServer()
tests = []
# TODO is there a better way of doing this?
if self.options.testPath.endswith('.js'):
# a single test file was passed in
testObj = {}
testObj['path'] = os.path.realpath(self.options.testPath)
testObj['name'] = os.path.basename(self.options.testPath)
testObj['here'] = os.path.dirname(testObj['path'])
tests.append(testObj)
else:
# a test manifest was passed in
# open and convert the manifest to json
manifest = TestManifest()
manifest.read(self.options.testPath)
tests = manifest.get()
# create a manifest object to be read by the JS side
manifestObj = {}
manifestObj['tests'] = tests
manifestObj['options'] = options.__dict__
# write manifest to a JSON file
jsonManifest = open(os.path.join(here, 'manifest.json'), 'w')
jsonManifest.write(json.dumps(manifestObj))
jsonManifest.close()
# setup environment
env = os.environ.copy()
env['MOZ_INSTRUMENT_EVENT_LOOP'] = '1'
env['MOZ_INSTRUMENT_EVENT_LOOP_THRESHOLD'] = str(options.tracerThreshold)
env['MOZ_INSTRUMENT_EVENT_LOOP_INTERVAL'] = str(options.tracerInterval)
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
# construct the browser arguments
cmdargs = []
# TODO Make browserArgs a list
cmdargs.extend(self.options.browserArgs)
cmdargs.extend(['-pep-start', os.path.realpath(jsonManifest.name)])
# run with managed process handler
self.runner = self.runner_class(profile=self.profile,
binary=self.options.binary,
cmdargs=cmdargs,
env=env,
process_class=PepProcess)
def start(self):
self.logger.debug('Starting Peptest')
# start firefox
self.runner.start(outputTimeout=self.options.timeout)
self.runner.wait()
crashed = self.checkForCrashes(results.currentTest)
self.stop()
if crashed or results.has_fails():
return 1
return 0
def runServer(self):
"""
Start a basic HTML server to host
test related files.
"""
#.........这里部分代码省略.........
示例7: valgrind_test
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
#.........这里部分代码省略.........
firefox_args = [httpd.get_url()]
env = os.environ.copy()
env['G_SLICE'] = 'always-malloc'
env['MOZ_CC_RUN_DURING_SHUTDOWN'] = '1'
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
env['XPCOM_DEBUG_BREAK'] = 'warn'
env.update(self.extra_environment_variables)
outputHandler = OutputHandler(self.log)
kp_kwargs = {'processOutputLine': [outputHandler]}
valgrind = 'valgrind'
if not os.path.exists(valgrind):
valgrind = findInPath(valgrind)
valgrind_args = [
valgrind,
'--smc-check=all-non-file',
'--vex-iropt-register-updates=allregs-at-mem-access',
'--gen-suppressions=all',
'--num-callers=36',
'--leak-check=full',
'--show-possibly-lost=no',
'--track-origins=yes',
'--trace-children=yes',
'-v', # Enable verbosity to get the list of used suppressions
# Avoid excessive delays in the presence of spinlocks.
# See bug 1309851.
'--fair-sched=yes',
# Keep debuginfo after library unmap. See bug 1382280.
'--keep-debuginfo=yes',
# Reduce noise level on rustc and/or LLVM compiled code.
# See bug 1365915
'--expensive-definedness-checks=yes',
]
for s in suppressions:
valgrind_args.append('--suppressions=' + s)
supps_dir = os.path.join(build_dir, 'valgrind')
supps_file1 = os.path.join(supps_dir, 'cross-architecture.sup')
valgrind_args.append('--suppressions=' + supps_file1)
if mozinfo.os == 'linux':
machtype = {
'x86_64': 'x86_64-pc-linux-gnu',
'x86': 'i386-pc-linux-gnu',
}.get(mozinfo.processor)
if machtype:
supps_file2 = os.path.join(supps_dir, machtype + '.sup')
if os.path.isfile(supps_file2):
valgrind_args.append('--suppressions=' + supps_file2)
exitcode = None
timeout = 1800
try:
runner = FirefoxRunner(profile=profile,
binary=self.get_binary_path(),
cmdargs=firefox_args,
env=env,
process_args=kp_kwargs)
runner.start(debug_args=valgrind_args)
exitcode = runner.wait(timeout=timeout)
finally:
errs = outputHandler.error_count
supps = outputHandler.suppression_count
if errs != supps:
status = 1 # turns the TBPL job orange
self.log(logging.ERROR, 'valgrind-fail-parsing',
{'errs': errs, 'supps': supps},
'TEST-UNEXPECTED-FAIL | valgrind-test | error parsing: {errs} errors '
'seen, but {supps} generated suppressions seen')
elif errs == 0:
status = 0
self.log(logging.INFO, 'valgrind-pass', {},
'TEST-PASS | valgrind-test | valgrind found no errors')
else:
status = 1 # turns the TBPL job orange
# We've already printed details of the errors.
if exitcode is None:
status = 2 # turns the TBPL job red
self.log(logging.ERROR, 'valgrind-fail-timeout',
{'timeout': timeout},
'TEST-UNEXPECTED-FAIL | valgrind-test | Valgrind timed out '
'(reached {timeout} second limit)')
elif exitcode != 0:
status = 2 # turns the TBPL job red
self.log(logging.ERROR, 'valgrind-fail-errors', {},
'TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code'
'from Valgrind')
httpd.stop()
return status
示例8: valgrind_test
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
#.........这里部分代码省略.........
from mozrunner import FirefoxRunner
from mozrunner.utils import findInPath
build_dir = os.path.join(self.topsrcdir, "build")
# XXX: currently we just use the PGO inputs for Valgrind runs. This may
# change in the future.
httpd = MozHttpd(docroot=os.path.join(build_dir, "pgo"))
httpd.start(block=False)
with TemporaryDirectory() as profilePath:
# TODO: refactor this into mozprofile
prefpath = os.path.join(self.topsrcdir, "testing", "profiles", "prefs_general.js")
prefs = {}
prefs.update(Preferences.read_prefs(prefpath))
interpolation = {"server": "%s:%d" % httpd.httpd.server_address, "OOP": "false"}
prefs = json.loads(json.dumps(prefs) % interpolation)
for pref in prefs:
prefs[pref] = Preferences.cast(prefs[pref])
quitter = os.path.join(self.distdir, "xpi-stage", "quitter")
locations = ServerLocations()
locations.add_host(host="127.0.0.1", port=httpd.httpd.server_port, options="primary")
profile = FirefoxProfile(profile=profilePath, preferences=prefs, addons=[quitter], locations=locations)
firefox_args = [httpd.get_url()]
env = os.environ.copy()
env["G_SLICE"] = "always-malloc"
env["XPCOM_CC_RUN_DURING_SHUTDOWN"] = "1"
env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
env["XPCOM_DEBUG_BREAK"] = "warn"
class OutputHandler(object):
def __init__(self):
self.found_errors = False
def __call__(self, line):
print(line)
m = re.match(r".*ERROR SUMMARY: [1-9]\d* errors from \d+ contexts", line)
if m:
self.found_errors = True
outputHandler = OutputHandler()
kp_kwargs = {"processOutputLine": [outputHandler]}
valgrind = "valgrind"
if not os.path.exists(valgrind):
valgrind = findInPath(valgrind)
valgrind_args = [
valgrind,
"--smc-check=all-non-file",
"--vex-iropt-register-updates=allregs-at-mem-access",
"--gen-suppressions=all",
"--num-callers=20",
"--leak-check=full",
"--show-possibly-lost=no",
"--track-origins=yes",
]
for s in suppressions:
valgrind_args.append("--suppressions=" + s)
supps_dir = os.path.join(build_dir, "valgrind")
supps_file1 = os.path.join(supps_dir, "cross-architecture.sup")
valgrind_args.append("--suppressions=" + supps_file1)
# MACHTYPE is an odd bash-only environment variable that doesn't
# show up in os.environ, so we have to get it another way.
machtype = subprocess.check_output(["bash", "-c", "echo $MACHTYPE"]).rstrip()
supps_file2 = os.path.join(supps_dir, machtype + ".sup")
if os.path.isfile(supps_file2):
valgrind_args.append("--suppressions=" + supps_file2)
exitcode = None
try:
runner = FirefoxRunner(
profile=profile, binary=self.get_binary_path(), cmdargs=firefox_args, env=env, kp_kwargs=kp_kwargs
)
runner.start(debug_args=valgrind_args)
exitcode = runner.wait()
finally:
if not outputHandler.found_errors:
status = 0
print("TEST-PASS | valgrind-test | valgrind found no errors")
else:
status = 1 # turns the TBPL job orange
print("TEST-UNEXPECTED-FAIL | valgrind-test | valgrind found errors")
if exitcode != 0:
status = 2 # turns the TBPL job red
print("TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code from Valgrind")
httpd.stop()
return status
示例9: valgrind_test
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
#.........这里部分代码省略.........
locations.add_host(host="127.0.0.1", port=httpd.httpd.server_port, options="primary")
profile = FirefoxProfile(profile=profilePath, preferences=prefs, addons=[quitter], locations=locations)
firefox_args = [httpd.get_url()]
env = os.environ.copy()
env["G_SLICE"] = "always-malloc"
env["MOZ_CC_RUN_DURING_SHUTDOWN"] = "1"
env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
env["XPCOM_DEBUG_BREAK"] = "warn"
env.update(self.extra_environment_variables)
outputHandler = OutputHandler(self.log)
kp_kwargs = {"processOutputLine": [outputHandler]}
valgrind = "valgrind"
if not os.path.exists(valgrind):
valgrind = findInPath(valgrind)
valgrind_args = [
valgrind,
"--smc-check=all-non-file",
"--vex-iropt-register-updates=allregs-at-mem-access",
"--gen-suppressions=all",
"--num-callers=36",
"--leak-check=full",
"--show-possibly-lost=no",
"--track-origins=yes",
"--trace-children=yes",
"-v", # Enable verbosity to get the list of used suppressions
]
for s in suppressions:
valgrind_args.append("--suppressions=" + s)
supps_dir = os.path.join(build_dir, "valgrind")
supps_file1 = os.path.join(supps_dir, "cross-architecture.sup")
valgrind_args.append("--suppressions=" + supps_file1)
# MACHTYPE is an odd bash-only environment variable that doesn't
# show up in os.environ, so we have to get it another way.
machtype = subprocess.check_output(["bash", "-c", "echo $MACHTYPE"]).rstrip()
supps_file2 = os.path.join(supps_dir, machtype + ".sup")
if os.path.isfile(supps_file2):
valgrind_args.append("--suppressions=" + supps_file2)
exitcode = None
timeout = 1800
try:
runner = FirefoxRunner(
profile=profile,
binary=self.get_binary_path(),
cmdargs=firefox_args,
env=env,
process_args=kp_kwargs,
)
runner.start(debug_args=valgrind_args)
exitcode = runner.wait(timeout=timeout)
finally:
errs = outputHandler.error_count
supps = outputHandler.suppression_count
if errs != supps:
status = 1 # turns the TBPL job orange
self.log(
logging.ERROR,
"valgrind-fail-parsing",
{"errs": errs, "supps": supps},
"TEST-UNEXPECTED-FAIL | valgrind-test | error parsing: {errs} errors seen, but {supps} generated suppressions seen",
)
elif errs == 0:
status = 0
self.log(logging.INFO, "valgrind-pass", {}, "TEST-PASS | valgrind-test | valgrind found no errors")
else:
status = 1 # turns the TBPL job orange
# We've already printed details of the errors.
if exitcode == None:
status = 2 # turns the TBPL job red
self.log(
logging.ERROR,
"valgrind-fail-timeout",
{"timeout": timeout},
"TEST-UNEXPECTED-FAIL | valgrind-test | Valgrind timed out (reached {timeout} second limit)",
)
elif exitcode != 0:
status = 2 # turns the TBPL job red
self.log(
logging.ERROR,
"valgrind-fail-errors",
{},
"TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code from Valgrind",
)
httpd.stop()
return status
示例10: main
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
def main(args):
parser = Options()
options, args = parser.parse_args()
if not options.html_manifest or not options.specialpowers or not options.host1 or not options.host2 or not options.signalling_server:
parser.print_usage()
return 2
package_options = get_package_options(parser, options)
if not package_options:
parser.print_usage()
return 2
if not os.path.isdir(options.specialpowers):
parser.error("SpecialPowers directory %s does not exist" % options.specialpowers)
return 2
if options.prefs and not os.path.isfile(options.prefs):
parser.error("Prefs file %s does not exist" % options.prefs)
return 2
if options.log_dest and not os.path.isdir(options.log_dest):
parser.error("Log directory %s does not exist" % options.log_dest)
return 2
log = mozlog.getLogger('steeplechase')
log.setLevel(mozlog.DEBUG)
if ':' in options.host1:
host, port = options.host1.split(':')
dm1 = DeviceManagerSUT(host, port)
else:
dm1 = DeviceManagerSUT(options.host1)
if ':' in options.host2:
host, port = options.host2.split(':')
dm2 = DeviceManagerSUT(host, port)
else:
dm2 = DeviceManagerSUT(options.host2)
remote_info = [{'dm': dm1,
'binary': package_options.binary,
'package': package_options.package,
'is_initiator': True,
'name': 'Client1'},
{'dm': dm2,
'binary': package_options.binary2,
'package': package_options.package2,
'is_initiator': False,
'name': 'Client2'}]
# first, push app
for info in remote_info:
dm = info['dm']
if info['binary']:
asset = Binary(path=info['binary'], log=log, dm=info['dm'], name=info['name'])
else:
asset = generate_package_asset(path=info['package'], log=log, dm=info['dm'], name=info['name'])
if options.setup:
asset.setup_test_root()
info['test_root'] = asset.test_root()
if options.setup:
log.info("Pushing app to %s...", info["name"])
asset.setup_client()
info['remote_app_path'] = asset.path_to_launch()
if not options.setup and not dm.fileExists(info['remote_app_path']):
log.error("App does not exist on %s, don't use --noSetup", info['name'])
return 2
pass_count, fail_count = 0, 0
if options.html_manifest:
manifest = TestManifest(strict=False)
manifest.read(options.html_manifest)
manifest_data = {"tests": [{"path": t["relpath"]} for t in manifest.active_tests(disabled=False, **mozinfo.info)]}
remote_port = 0
if options.remote_webserver:
result = re.search(':(\d+)', options.remote_webserver)
if result:
remote_port = int(result.groups()[0])
@json_response
def get_manifest(req):
return (200, manifest_data)
handlers = [{
'method': 'GET',
'path': '/manifest.json',
'function': get_manifest
}]
httpd = MozHttpd(host=moznetwork.get_ip(), port=remote_port, log_requests=True,
docroot=os.path.join(os.path.dirname(__file__), "..", "webharness"),
urlhandlers=handlers,
path_mappings={"/tests": os.path.dirname(options.html_manifest)})
httpd.start(block=False)
test = HTMLTests(httpd, remote_info, log, options)
html_pass_count, html_fail_count = test.run()
pass_count += html_pass_count
fail_count += html_fail_count
httpd.stop()
log.info("Result summary:")
log.info("Passed: %d" % pass_count)
log.info("Failed: %d" % fail_count)
return pass_count > 0 and fail_count == 0
示例11: valgrind_test
# 需要导入模块: from mozhttpd import MozHttpd [as 别名]
# 或者: from mozhttpd.MozHttpd import stop [as 别名]
#.........这里部分代码省略.........
# XXX: currently we just use the PGO inputs for Valgrind runs. This may
# change in the future.
httpd = MozHttpd(docroot=os.path.join(build_dir, 'pgo'))
httpd.start(block=False)
with TemporaryDirectory() as profilePath:
#TODO: refactor this into mozprofile
prefpath = os.path.join(self.topsrcdir, 'testing', 'profiles', 'prefs_general.js')
prefs = {}
prefs.update(Preferences.read_prefs(prefpath))
interpolation = { 'server': '%s:%d' % httpd.httpd.server_address,
'OOP': 'false'}
prefs = json.loads(json.dumps(prefs) % interpolation)
for pref in prefs:
prefs[pref] = Preferences.cast(prefs[pref])
quitter = os.path.join(self.distdir, 'xpi-stage', 'quitter')
locations = ServerLocations()
locations.add_host(host='127.0.0.1',
port=httpd.httpd.server_port,
options='primary')
profile = FirefoxProfile(profile=profilePath,
preferences=prefs,
addons=[quitter],
locations=locations)
firefox_args = [httpd.get_url()]
env = os.environ.copy()
env['G_SLICE'] = 'always-malloc'
env['XPCOM_CC_RUN_DURING_SHUTDOWN'] = '1'
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
env['XPCOM_DEBUG_BREAK'] = 'warn'
outputHandler = OutputHandler()
kp_kwargs = {'processOutputLine': [outputHandler]}
valgrind = 'valgrind'
if not os.path.exists(valgrind):
valgrind = findInPath(valgrind)
valgrind_args = [
valgrind,
'--smc-check=all-non-file',
'--vex-iropt-register-updates=allregs-at-mem-access',
'--gen-suppressions=all',
'--num-callers=20',
'--leak-check=full',
'--show-possibly-lost=no',
'--track-origins=yes'
]
for s in suppressions:
valgrind_args.append('--suppressions=' + s)
supps_dir = os.path.join(build_dir, 'valgrind')
supps_file1 = os.path.join(supps_dir, 'cross-architecture.sup')
valgrind_args.append('--suppressions=' + supps_file1)
# MACHTYPE is an odd bash-only environment variable that doesn't
# show up in os.environ, so we have to get it another way.
machtype = subprocess.check_output(['bash', '-c', 'echo $MACHTYPE']).rstrip()
supps_file2 = os.path.join(supps_dir, machtype + '.sup')
if os.path.isfile(supps_file2):
valgrind_args.append('--suppressions=' + supps_file2)
exitcode = None
try:
runner = FirefoxRunner(profile=profile,
binary=self.get_binary_path(),
cmdargs=firefox_args,
env=env,
kp_kwargs=kp_kwargs)
runner.start(debug_args=valgrind_args)
exitcode = runner.wait()
finally:
errs = outputHandler.error_count
supps = outputHandler.suppression_count
if errs != supps:
status = 1 # turns the TBPL job orange
print('TEST-UNEXPECTED-FAILURE | valgrind-test | error parsing:', errs, "errors seen, but", supps, "generated suppressions seen")
elif errs == 0:
status = 0
print('TEST-PASS | valgrind-test | valgrind found no errors')
else:
status = 1 # turns the TBPL job orange
# We've already printed details of the errors.
if exitcode != 0:
status = 2 # turns the TBPL job red
print('TEST-UNEXPECTED-FAIL | valgrind-test | non-zero exit code from Valgrind')
httpd.stop()
return status