2012-04-27 22:44:59 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2013-10-01 18:32:58 +04:00
|
|
|
import json
|
2012-04-27 22:44:59 +04:00
|
|
|
import os
|
2013-07-26 22:40:04 +04:00
|
|
|
import posixpath
|
2012-04-27 22:44:59 +04:00
|
|
|
import sys
|
|
|
|
import tempfile
|
2012-06-16 01:13:04 +04:00
|
|
|
import traceback
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2013-08-27 01:17:51 +04:00
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
2013-03-29 00:42:49 +04:00
|
|
|
sys.path.insert(0, here)
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
from runtests import MochitestBase
|
2015-04-30 20:47:01 +03:00
|
|
|
from mochitest_options import MochitestArgumentParser
|
2012-04-27 22:44:59 +04:00
|
|
|
from marionette import Marionette
|
2013-08-14 21:57:43 +04:00
|
|
|
from mozprofile import Profile, Preferences
|
2015-08-27 02:41:43 +03:00
|
|
|
from mozrunner.utils import get_stack_fixer_function
|
2013-07-26 22:40:04 +04:00
|
|
|
import mozinfo
|
2015-07-03 08:04:22 +03:00
|
|
|
import mozleak
|
2013-07-26 22:40:04 +04:00
|
|
|
|
2015-02-13 22:42:02 +03:00
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
class MochitestB2G(MochitestBase):
|
|
|
|
"""
|
|
|
|
Mochitest class for b2g emulators and devices.
|
|
|
|
"""
|
2014-06-19 22:17:26 +04:00
|
|
|
marionette = None
|
2015-11-18 21:35:38 +03:00
|
|
|
remote_log = None
|
2014-06-19 22:17:26 +04:00
|
|
|
|
|
|
|
def __init__(self, marionette_args,
|
2015-02-13 22:42:02 +03:00
|
|
|
logger_options,
|
2015-11-18 21:35:38 +03:00
|
|
|
profile_data_dir,
|
|
|
|
local_binary_dir,
|
|
|
|
locations=os.path.join(here, 'server-locations.txt'),
|
2015-02-13 22:42:02 +03:00
|
|
|
out_of_process=True,
|
2015-11-18 21:35:38 +03:00
|
|
|
remote_test_root=None,
|
|
|
|
remote_log_file=None):
|
|
|
|
MochitestBase.__init__(self, logger_options)
|
2014-06-19 22:17:26 +04:00
|
|
|
self.marionette_args = marionette_args
|
2013-07-26 22:40:04 +04:00
|
|
|
self.out_of_process = out_of_process
|
2014-03-14 22:25:41 +04:00
|
|
|
self.locations_file = locations
|
2013-03-29 00:42:49 +04:00
|
|
|
self.preferences = []
|
|
|
|
self.webapps = None
|
2016-01-25 17:55:57 +03:00
|
|
|
self.start_script = os.path.join(here, 'start_b2g.js')
|
|
|
|
self.start_script_args = [self.out_of_process]
|
2013-07-26 22:40:04 +04:00
|
|
|
self.product = 'b2g'
|
2014-12-24 00:17:41 +03:00
|
|
|
self.remote_chrome_test_dir = None
|
2015-11-18 21:35:38 +03:00
|
|
|
self.local_log = None
|
|
|
|
self.local_binary_dir = local_binary_dir
|
2013-03-29 00:42:49 +04:00
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
self.preferences = [
|
|
|
|
os.path.join(
|
|
|
|
profile_data_dir,
|
|
|
|
f) for f in os.listdir(profile_data_dir) if f.startswith('pref')]
|
|
|
|
self.webapps = [
|
|
|
|
os.path.join(
|
|
|
|
profile_data_dir,
|
|
|
|
f) for f in os.listdir(profile_data_dir) if f.startswith('webapp')]
|
2013-03-29 00:42:49 +04:00
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
# mozinfo is populated by the parent class
|
|
|
|
if mozinfo.info['debug']:
|
|
|
|
self.SERVER_STARTUP_TIMEOUT = 180
|
2013-01-04 22:41:34 +04:00
|
|
|
else:
|
2013-07-26 22:40:04 +04:00
|
|
|
self.SERVER_STARTUP_TIMEOUT = 90
|
2013-03-22 19:41:07 +04:00
|
|
|
|
2014-07-04 15:55:00 +04:00
|
|
|
def buildTestPath(self, options, testsToFilter=None):
|
2014-06-16 22:51:22 +04:00
|
|
|
if options.manifestFile != 'tests.json':
|
2015-11-18 21:35:38 +03:00
|
|
|
MochitestBase.buildTestPath(self, options, testsToFilter, disabled=False)
|
2014-03-18 19:03:51 +04:00
|
|
|
return self.buildTestURL(options)
|
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
def build_profile(self, options):
|
2013-03-29 00:42:49 +04:00
|
|
|
# preferences
|
|
|
|
prefs = {}
|
|
|
|
for path in self.preferences:
|
|
|
|
prefs.update(Preferences.read_prefs(path))
|
|
|
|
|
|
|
|
for v in options.extraPrefs:
|
|
|
|
thispref = v.split("=", 1)
|
|
|
|
if len(thispref) < 2:
|
|
|
|
print "Error: syntax error in --setpref=" + v
|
|
|
|
sys.exit(1)
|
|
|
|
prefs[thispref[0]] = thispref[1]
|
|
|
|
|
|
|
|
# interpolate the preferences
|
2015-02-13 22:42:02 +03:00
|
|
|
interpolation = {
|
|
|
|
"server": "%s:%s" %
|
|
|
|
(options.webServer,
|
|
|
|
options.httpPort),
|
|
|
|
"OOP": "true" if self.out_of_process else "false"}
|
2013-03-29 00:42:49 +04:00
|
|
|
prefs = json.loads(json.dumps(prefs) % interpolation)
|
2013-04-10 04:31:42 +04:00
|
|
|
for pref in prefs:
|
|
|
|
prefs[pref] = Preferences.cast(prefs[pref])
|
2013-03-29 00:42:49 +04:00
|
|
|
|
2013-04-10 04:13:32 +04:00
|
|
|
kwargs = {
|
|
|
|
'addons': self.getExtensionsToInstall(options),
|
|
|
|
'apps': self.webapps,
|
2014-03-14 22:25:41 +04:00
|
|
|
'locations': self.locations_file,
|
2013-04-10 04:13:32 +04:00
|
|
|
'preferences': prefs,
|
|
|
|
'proxy': {"remote": options.webServer}
|
|
|
|
}
|
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
self.profile = Profile(**kwargs)
|
2013-03-29 00:42:49 +04:00
|
|
|
options.profilePath = self.profile.profile
|
|
|
|
# TODO bug 839108 - mozprofile should probably handle this
|
|
|
|
manifest = self.addChromeToProfile(options)
|
|
|
|
self.copyExtraFilesToProfile(options)
|
|
|
|
return manifest
|
2013-01-04 22:41:34 +04:00
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
def run_tests(self, options):
|
|
|
|
""" Prepare, configure, run tests and cleanup """
|
2013-01-04 22:41:34 +04:00
|
|
|
|
2015-06-05 20:28:29 +03:00
|
|
|
self.setTestRoot(options)
|
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
manifest = self.build_profile(options)
|
2014-10-02 19:08:41 +04:00
|
|
|
self.logPreamble(self.getActiveTests(options))
|
2013-01-04 05:37:26 +04:00
|
|
|
|
2014-07-17 11:02:00 +04:00
|
|
|
# configuring the message logger's buffering
|
|
|
|
self.message_logger.buffering = options.quiet
|
|
|
|
|
2013-10-18 23:47:35 +04:00
|
|
|
if options.debugger or not options.autorun:
|
2013-07-26 22:40:04 +04:00
|
|
|
timeout = None
|
|
|
|
else:
|
2013-10-18 23:47:35 +04:00
|
|
|
if not options.timeout:
|
|
|
|
if mozinfo.info['debug']:
|
|
|
|
options.timeout = 420
|
|
|
|
else:
|
|
|
|
options.timeout = 300
|
|
|
|
timeout = options.timeout + 30.0
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2014-08-13 20:03:00 +04:00
|
|
|
self.log.info("runtestsb2g.py | Running tests: start.")
|
2013-07-26 22:40:04 +04:00
|
|
|
status = 0
|
|
|
|
try:
|
2014-07-17 11:02:00 +04:00
|
|
|
def on_output(line):
|
|
|
|
messages = self.message_logger.write(line)
|
|
|
|
for message in messages:
|
|
|
|
if message['action'] == 'test_start':
|
|
|
|
self.runner.last_test = message['test']
|
|
|
|
|
2015-02-13 22:42:02 +03:00
|
|
|
# The logging will be handled by on_output, so we set the stream to
|
|
|
|
# None
|
2014-07-17 11:02:00 +04:00
|
|
|
process_args = {'processOutputLine': on_output,
|
|
|
|
'stream': None}
|
|
|
|
self.marionette_args['process_args'] = process_args
|
2014-06-19 22:17:26 +04:00
|
|
|
self.marionette_args['profile'] = self.profile
|
2015-12-22 17:32:11 +03:00
|
|
|
# Increase the timeout to fix bug 1208725
|
|
|
|
self.marionette_args['socket_timeout'] = 720
|
2014-07-17 11:02:00 +04:00
|
|
|
|
2014-06-19 22:17:26 +04:00
|
|
|
self.marionette = Marionette(**self.marionette_args)
|
|
|
|
self.runner = self.marionette.runner
|
|
|
|
self.app_ctx = self.runner.app_ctx
|
|
|
|
|
|
|
|
self.remote_log = posixpath.join(self.app_ctx.remote_test_root,
|
|
|
|
'log', 'mochitest.log')
|
2015-02-13 22:42:02 +03:00
|
|
|
if not self.app_ctx.dm.dirExists(
|
|
|
|
posixpath.dirname(
|
|
|
|
self.remote_log)):
|
2014-06-19 22:17:26 +04:00
|
|
|
self.app_ctx.dm.mkDirs(self.remote_log)
|
|
|
|
|
2014-12-24 00:17:41 +03:00
|
|
|
if options.chrome:
|
|
|
|
# Update chrome manifest file in profile with correct path.
|
|
|
|
self.writeChromeManifest(options)
|
|
|
|
|
2015-02-13 22:42:02 +03:00
|
|
|
self.leak_report_file = posixpath.join(
|
|
|
|
self.app_ctx.remote_test_root,
|
|
|
|
'log',
|
|
|
|
'runtests_leaks.log')
|
2014-08-06 01:11:53 +04:00
|
|
|
|
|
|
|
# We don't want to copy the host env onto the device, so pass in an
|
|
|
|
# empty env.
|
|
|
|
self.browserEnv = self.buildBrowserEnv(options, env={})
|
|
|
|
|
2014-08-13 19:51:50 +04:00
|
|
|
# B2G emulator debug tests still make external connections, so don't
|
2015-02-13 22:42:02 +03:00
|
|
|
# pass MOZ_DISABLE_NONLOCAL_CONNECTIONS to them for now (bug
|
|
|
|
# 1039019).
|
|
|
|
if mozinfo.info[
|
|
|
|
'debug'] and 'MOZ_DISABLE_NONLOCAL_CONNECTIONS' in self.browserEnv:
|
2014-08-06 01:11:53 +04:00
|
|
|
del self.browserEnv['MOZ_DISABLE_NONLOCAL_CONNECTIONS']
|
|
|
|
self.runner.env.update(self.browserEnv)
|
|
|
|
|
2015-04-10 23:41:36 +03:00
|
|
|
# Despite our efforts to clean up servers started by this script, in practice
|
|
|
|
# we still see infrequent cases where a process is orphaned and interferes
|
|
|
|
# with future tests, typically because the old server is keeping the port in use.
|
|
|
|
# Try to avoid those failures by checking for and killing orphan servers before
|
|
|
|
# trying to start new ones.
|
|
|
|
self.killNamedOrphans('ssltunnel')
|
|
|
|
self.killNamedOrphans('xpcshell')
|
|
|
|
|
2014-06-19 22:17:26 +04:00
|
|
|
self.startServers(options, None)
|
2015-05-05 23:41:59 +03:00
|
|
|
|
|
|
|
# In desktop mochitests buildTestPath is called before buildURLOptions. This
|
|
|
|
# means options.manifestFile has already been converted to the proper json
|
|
|
|
# style manifest. Not so with B2G, that conversion along with updating the URL
|
|
|
|
# option will happen later. So backup and restore options.manifestFile to
|
|
|
|
# prevent us from trying to pass in an instance of TestManifest via url param.
|
|
|
|
manifestFile = options.manifestFile
|
|
|
|
options.manifestFile = None
|
2014-06-19 22:17:26 +04:00
|
|
|
self.buildURLOptions(options, {'MOZ_HIDE_RESULTS_TABLE': '1'})
|
2015-05-05 23:41:59 +03:00
|
|
|
options.manifestFile = manifestFile
|
|
|
|
|
2016-01-25 17:55:57 +03:00
|
|
|
self.start_script_args.append(not options.emulator)
|
|
|
|
self.start_script_args.append(options.wifi)
|
|
|
|
self.start_script_args.append(options.chrome)
|
2014-06-19 22:17:26 +04:00
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
self.runner.start(outputTimeout=timeout)
|
2014-06-19 22:17:26 +04:00
|
|
|
|
|
|
|
self.marionette.wait_for_port()
|
|
|
|
self.marionette.start_session()
|
|
|
|
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
|
|
|
|
|
|
|
|
# Disable offline status management (bug 777145), otherwise the network
|
|
|
|
# will be 'offline' when the mochitests start. Presumably, the network
|
2015-02-13 22:42:02 +03:00
|
|
|
# won't be offline on a real device, so we only do this for
|
|
|
|
# emulators.
|
2014-06-19 22:17:26 +04:00
|
|
|
self.marionette.execute_script("""
|
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
|
|
|
Services.io.manageOfflineStatus = false;
|
|
|
|
Services.io.offline = false;
|
|
|
|
""")
|
|
|
|
|
2015-05-19 02:36:15 +03:00
|
|
|
self.marionette.execute_script("""
|
|
|
|
let SECURITY_PREF = "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
|
|
|
|
Services.prefs.setBoolPref(SECURITY_PREF, true);
|
|
|
|
|
|
|
|
if (!testUtils.hasOwnProperty("specialPowersObserver")) {
|
|
|
|
let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Components.interfaces.mozIJSSubScriptLoader);
|
2015-11-05 18:00:59 +03:00
|
|
|
loader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserver.jsm",
|
2015-05-19 02:36:15 +03:00
|
|
|
testUtils);
|
|
|
|
testUtils.specialPowersObserver = new testUtils.SpecialPowersObserver();
|
|
|
|
testUtils.specialPowersObserver.init();
|
|
|
|
}
|
|
|
|
""")
|
|
|
|
|
2014-12-24 00:17:41 +03:00
|
|
|
if options.chrome:
|
|
|
|
self.app_ctx.dm.removeDir(self.remote_chrome_test_dir)
|
|
|
|
self.app_ctx.dm.mkDir(self.remote_chrome_test_dir)
|
2015-11-18 21:35:38 +03:00
|
|
|
local = MochitestBase.getChromeTestDir(self, options)
|
2014-12-24 00:17:41 +03:00
|
|
|
local = os.path.join(local, "chrome")
|
|
|
|
remote = self.remote_chrome_test_dir
|
2015-02-13 22:42:02 +03:00
|
|
|
self.log.info(
|
|
|
|
"pushing %s to %s on device..." %
|
|
|
|
(local, remote))
|
2014-12-24 00:17:41 +03:00
|
|
|
self.app_ctx.dm.pushDir(local, remote)
|
|
|
|
|
2016-01-25 17:55:57 +03:00
|
|
|
self.execute_start_script()
|
2013-09-30 19:05:46 +04:00
|
|
|
status = self.runner.wait()
|
2014-07-17 11:02:00 +04:00
|
|
|
|
2013-09-30 19:05:46 +04:00
|
|
|
if status is None:
|
|
|
|
# the runner has timed out
|
|
|
|
status = 124
|
2014-08-06 01:11:53 +04:00
|
|
|
|
|
|
|
local_leak_file = tempfile.NamedTemporaryFile()
|
2015-02-13 22:42:02 +03:00
|
|
|
self.app_ctx.dm.getFile(
|
|
|
|
self.leak_report_file,
|
|
|
|
local_leak_file.name)
|
2014-08-06 01:11:53 +04:00
|
|
|
self.app_ctx.dm.removeFile(self.leak_report_file)
|
|
|
|
|
2015-07-03 08:04:22 +03:00
|
|
|
mozleak.process_leak_log(
|
|
|
|
local_leak_file.name,
|
|
|
|
leak_thresholds=options.leakThresholds,
|
|
|
|
ignore_missing_leaks=options.ignoreMissingLeaks,
|
|
|
|
log=self.log,
|
2015-08-27 02:41:43 +03:00
|
|
|
stack_fixer=get_stack_fixer_function(options.utilityPath,
|
|
|
|
options.symbolsPath),
|
2015-07-03 08:04:22 +03:00
|
|
|
)
|
2013-07-26 22:40:04 +04:00
|
|
|
except KeyboardInterrupt:
|
2015-02-13 22:42:02 +03:00
|
|
|
self.log.info("runtests.py | Received keyboard interrupt.\n")
|
2013-07-26 22:40:04 +04:00
|
|
|
status = -1
|
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
2015-02-13 22:42:02 +03:00
|
|
|
self.log.error(
|
|
|
|
"Automation Error: Received unexpected exception while running application\n")
|
2014-06-19 22:17:26 +04:00
|
|
|
if hasattr(self, 'runner'):
|
|
|
|
self.runner.check_for_crashes()
|
2013-07-26 22:40:04 +04:00
|
|
|
status = 1
|
|
|
|
|
2014-03-14 22:25:41 +04:00
|
|
|
self.stopServers()
|
2013-07-26 22:40:04 +04:00
|
|
|
|
2014-08-13 20:03:00 +04:00
|
|
|
self.log.info("runtestsb2g.py | Running tests: end.")
|
2013-07-26 22:40:04 +04:00
|
|
|
|
|
|
|
if manifest is not None:
|
|
|
|
self.cleanup(manifest, options)
|
|
|
|
return status
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2014-07-25 15:01:13 +04:00
|
|
|
def getGMPPluginPath(self, options):
|
2015-03-31 05:32:15 +03:00
|
|
|
if options.gmp_path:
|
|
|
|
return options.gmp_path
|
|
|
|
return '/system/b2g/gmp-clearkey/0.1'
|
2014-07-25 15:01:13 +04:00
|
|
|
|
2014-12-24 00:17:41 +03:00
|
|
|
def getChromeTestDir(self, options):
|
|
|
|
# The chrome test directory returned here is the remote location
|
|
|
|
# of chrome test files. A reference to this directory is requested
|
|
|
|
# when building the profile locally, before self.app_ctx is defined.
|
|
|
|
# To get around this, return a dummy directory until self.app_ctx
|
|
|
|
# is defined; the correct directory will be returned later, over-
|
|
|
|
# writing the dummy.
|
|
|
|
if hasattr(self, 'app_ctx'):
|
2015-02-13 22:42:02 +03:00
|
|
|
self.remote_chrome_test_dir = posixpath.join(
|
|
|
|
self.app_ctx.remote_test_root,
|
|
|
|
'chrome')
|
2014-12-24 00:17:41 +03:00
|
|
|
return self.remote_chrome_test_dir
|
|
|
|
return 'dummy-chrome-test-dir'
|
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
def cleanup(self, manifest, options):
|
|
|
|
if self.local_log:
|
2014-06-19 22:17:26 +04:00
|
|
|
self.app_ctx.dm.getFile(self.remote_log, self.local_log)
|
|
|
|
self.app_ctx.dm.removeFile(self.remote_log)
|
2012-06-06 02:17:26 +04:00
|
|
|
|
2012-04-27 22:44:59 +04:00
|
|
|
if options.pidFile != "":
|
|
|
|
try:
|
|
|
|
os.remove(options.pidFile)
|
|
|
|
os.remove(options.pidFile + ".xpcshell.pid")
|
|
|
|
except:
|
|
|
|
print "Warning: cleaning up pidfile '%s' was unsuccessful from the test harness" % options.pidFile
|
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
# stop and clean up the runner
|
|
|
|
if getattr(self, 'runner', False):
|
2014-06-19 22:17:26 +04:00
|
|
|
if self.local_log:
|
|
|
|
self.app_ctx.dm.getFile(self.remote_log, self.local_log)
|
|
|
|
self.app_ctx.dm.removeFile(self.remote_log)
|
|
|
|
|
2013-07-26 22:40:04 +04:00
|
|
|
self.runner.cleanup()
|
|
|
|
self.runner = None
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2014-03-14 22:25:41 +04:00
|
|
|
def startServers(self, options, debuggerInfo):
|
|
|
|
""" Create the servers on the host and start them up """
|
|
|
|
savedXre = options.xrePath
|
|
|
|
savedUtility = options.utilityPath
|
|
|
|
savedProfie = options.profilePath
|
|
|
|
options.xrePath = self.local_binary_dir
|
|
|
|
options.utilityPath = self.local_binary_dir
|
|
|
|
options.profilePath = tempfile.mkdtemp()
|
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
MochitestBase.startServers(self, options, debuggerInfo)
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2014-03-14 22:25:41 +04:00
|
|
|
options.xrePath = savedXre
|
|
|
|
options.utilityPath = savedUtility
|
|
|
|
options.profilePath = savedProfie
|
2012-04-27 22:44:59 +04:00
|
|
|
|
|
|
|
def buildURLOptions(self, options, env):
|
2013-07-26 22:40:04 +04:00
|
|
|
self.local_log = options.logFile
|
|
|
|
options.logFile = self.remote_log
|
2013-03-29 00:42:49 +04:00
|
|
|
options.profilePath = self.profile.profile
|
2015-11-18 21:35:38 +03:00
|
|
|
MochitestBase.buildURLOptions(self, options, env)
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
test_url = self.buildTestPath(options)
|
2015-11-19 22:54:17 +03:00
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
# For B2G emulators buildURLOptions has been called
|
|
|
|
# without calling buildTestPath first and that
|
|
|
|
# causes manifestFile not to be set
|
|
|
|
if "manifestFile=tests.json" not in self.urlOpts:
|
|
|
|
self.urlOpts.append("manifestFile=%s" % options.manifestFile)
|
2013-08-14 21:57:43 +04:00
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
if len(self.urlOpts) > 0:
|
|
|
|
test_url += "?" + "&".join(self.urlOpts)
|
2016-01-25 17:55:57 +03:00
|
|
|
self.start_script_args.append(test_url)
|
2013-01-04 22:41:34 +04:00
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
options.profilePath = self.app_ctx.remote_profile
|
|
|
|
options.logFile = self.local_log
|
2015-11-19 22:54:17 +03:00
|
|
|
|
|
|
|
|
2016-07-20 18:13:30 +03:00
|
|
|
def run_test_harness(parser, options):
|
|
|
|
parser.validate(options)
|
|
|
|
|
2012-04-27 22:44:59 +04:00
|
|
|
# create our Marionette instance
|
2014-06-19 22:17:26 +04:00
|
|
|
marionette_args = {
|
|
|
|
'adb_path': options.adbPath,
|
|
|
|
'emulator': options.emulator,
|
|
|
|
'no_window': options.noWindow,
|
|
|
|
'logdir': options.logdir,
|
|
|
|
'busybox': options.busybox,
|
|
|
|
'symbols_path': options.symbolsPath,
|
|
|
|
'sdcard': options.sdcard,
|
|
|
|
'homedir': options.b2gPath,
|
|
|
|
}
|
2012-04-27 22:44:59 +04:00
|
|
|
if options.marionette:
|
2013-01-04 22:41:34 +04:00
|
|
|
host, port = options.marionette.split(':')
|
2014-06-19 22:17:26 +04:00
|
|
|
marionette_args['host'] = host
|
|
|
|
marionette_args['port'] = int(port)
|
2014-02-21 01:56:57 +04:00
|
|
|
|
2015-02-13 22:42:02 +03:00
|
|
|
if (options is None):
|
2012-04-27 22:44:59 +04:00
|
|
|
print "ERROR: Invalid options specified, use --help for a list of valid options"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2015-11-18 21:35:38 +03:00
|
|
|
mochitest = MochitestB2G(
|
2015-02-13 22:42:02 +03:00
|
|
|
marionette_args,
|
|
|
|
options,
|
|
|
|
options.profile_data_dir,
|
|
|
|
options.xrePath,
|
|
|
|
remote_log_file=options.remoteLogFile)
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2015-02-13 22:42:02 +03:00
|
|
|
if (options is None):
|
2012-04-27 22:44:59 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
retVal = 1
|
|
|
|
try:
|
2012-08-09 04:29:26 +04:00
|
|
|
mochitest.cleanup(None, options)
|
2013-07-26 22:40:04 +04:00
|
|
|
retVal = mochitest.run_tests(options)
|
2012-04-27 22:44:59 +04:00
|
|
|
except:
|
2012-11-05 17:03:55 +04:00
|
|
|
print "Automation Error: Exception caught while running tests"
|
2012-06-16 01:13:04 +04:00
|
|
|
traceback.print_exc()
|
2014-03-14 22:25:41 +04:00
|
|
|
mochitest.stopServers()
|
2012-04-27 22:44:59 +04:00
|
|
|
try:
|
|
|
|
mochitest.cleanup(None, options)
|
|
|
|
except:
|
|
|
|
pass
|
2012-11-20 19:24:28 +04:00
|
|
|
retVal = 1
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2014-07-29 16:11:00 +04:00
|
|
|
mochitest.message_logger.finish()
|
|
|
|
|
2015-05-05 23:41:59 +03:00
|
|
|
return retVal
|
2012-04-27 22:44:59 +04:00
|
|
|
|
2015-02-13 22:42:02 +03:00
|
|
|
|
2013-01-04 22:41:34 +04:00
|
|
|
def main():
|
2015-04-30 20:47:01 +03:00
|
|
|
parser = MochitestArgumentParser(app='b2g')
|
2015-03-25 00:42:24 +03:00
|
|
|
options = parser.parse_args()
|
2016-07-20 18:13:30 +03:00
|
|
|
return run_test_harness(parser, options)
|
2013-01-04 22:41:34 +04:00
|
|
|
|
2012-04-27 22:44:59 +04:00
|
|
|
if __name__ == "__main__":
|
2015-05-05 23:41:59 +03:00
|
|
|
sys.exit(main())
|