mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 815807 - Part 1: add --load-early arg to Marionette, r=ahal
This commit is contained in:
parent
c124d722b1
commit
a47c16de3a
@ -54,6 +54,7 @@ class Emulator(object):
|
||||
self._tmp_sdcard = None
|
||||
self._tmp_userdata = None
|
||||
self._adb_started = False
|
||||
self.remote_user_js = '/data/local/user.js'
|
||||
self.logcat_dir = logcat_dir
|
||||
self.logcat_proc = None
|
||||
self.arch = arch
|
||||
@ -311,7 +312,6 @@ waitFor(
|
||||
marionette.set_context(marionette.CONTEXT_CONTENT)
|
||||
marionette.delete_session()
|
||||
|
||||
|
||||
def connect(self):
|
||||
self._check_for_adb()
|
||||
self.start_adb()
|
||||
@ -328,6 +328,15 @@ waitFor(
|
||||
self.dm = devicemanagerADB.DeviceManagerADB(adbPath=self.adb,
|
||||
deviceSerial='emulator-%d' % self.port)
|
||||
|
||||
def add_prefs_to_profile(self, prefs=None):
|
||||
if not prefs:
|
||||
prefs = ["user_pref('marionette.loadearly', true);"]
|
||||
local_user_js = tempfile.mktemp(prefix='localuserjs')
|
||||
self.dm.getFile(self.remote_user_js, local_user_js)
|
||||
with open(local_user_js, 'a') as f:
|
||||
f.write('/n'.join(prefs))
|
||||
self.dm.pushFile(local_user_js, self.remote_user_js)
|
||||
|
||||
def start(self):
|
||||
self._check_for_b2g()
|
||||
self.start_adb()
|
||||
@ -369,6 +378,37 @@ waitFor(
|
||||
# setup DNS fix for networking
|
||||
self._run_adb(['shell', 'setprop', 'net.dns1', '10.0.2.3'])
|
||||
|
||||
def setup(self, marionette, gecko_path=None, load_early=False):
|
||||
# Wait for the system-message-listener-ready event, otherwise
|
||||
# Bad Things happen.
|
||||
self.wait_for_system_message(marionette)
|
||||
|
||||
if gecko_path:
|
||||
if load_early:
|
||||
# Inject prefs into the profile now, since we have to restart
|
||||
# B2G after installing a new gecko anyway.
|
||||
self.add_prefs_to_profile()
|
||||
self.install_gecko(gecko_path, marionette)
|
||||
elif load_early:
|
||||
self.add_prefs_to_profile()
|
||||
self.restart_b2g()
|
||||
|
||||
if load_early:
|
||||
# If we're loading early, we have to wait for the
|
||||
# system-message-listener-ready event again after restarting B2G.
|
||||
# If we're not loading early, we skip this because Marionette
|
||||
# doesn't load until after this event has fired.
|
||||
self.wait_for_system_message(marionette)
|
||||
|
||||
def restart_b2g(self):
|
||||
print 'restarting B2G'
|
||||
self.dm.shellCheckOutput(['stop', 'b2g'])
|
||||
time.sleep(10)
|
||||
self.dm.shellCheckOutput(['start', 'b2g'])
|
||||
|
||||
if not self.wait_for_port():
|
||||
raise TimeoutException("Timeout waiting for marionette on port '%s'" % self.marionette_port)
|
||||
|
||||
def install_gecko(self, gecko_path, marionette):
|
||||
"""
|
||||
Install gecko into the emulator using adb push. Restart b2g after the
|
||||
@ -382,6 +422,7 @@ waitFor(
|
||||
|
||||
print 'installing gecko binaries...'
|
||||
|
||||
# see bug 809437 for the path that lead to this madness
|
||||
try:
|
||||
# need to remount so we can write to /system/b2g
|
||||
self._run_adb(['remount'])
|
||||
@ -389,7 +430,7 @@ waitFor(
|
||||
for filename in files:
|
||||
rel_path = os.path.relpath(os.path.join(root, filename), gecko_path)
|
||||
system_b2g_file = os.path.join('/system/b2g', rel_path)
|
||||
for retry in range(1, push_attempts+1):
|
||||
for retry in range(1, push_attempts + 1):
|
||||
print 'pushing', system_b2g_file, '(attempt %s of %s)' % (retry, push_attempts)
|
||||
try:
|
||||
self.dm.pushFile(os.path.join(root, filename), system_b2g_file)
|
||||
@ -398,15 +439,7 @@ waitFor(
|
||||
if retry == push_attempts:
|
||||
raise
|
||||
|
||||
print 'restarting B2G'
|
||||
# see bug 809437 for the path that lead to this madness
|
||||
self.dm.shellCheckOutput(['stop', 'b2g'])
|
||||
time.sleep(10)
|
||||
self.dm.shellCheckOutput(['start', 'b2g'])
|
||||
|
||||
if not self.wait_for_port():
|
||||
raise TimeoutException("Timeout waiting for marionette on port '%s'" % self.marionette_port)
|
||||
self.wait_for_system_message(marionette)
|
||||
self.restart_b2g()
|
||||
|
||||
except (DMError, MarionetteException):
|
||||
# Bug 812395 - raise a single exception type for these so we can
|
||||
|
@ -100,7 +100,7 @@ class Marionette(object):
|
||||
emulator=None, sdcard=None, emulatorBinary=None,
|
||||
emulatorImg=None, emulator_res='480x800', gecko_path=None,
|
||||
connectToRunningEmulator=False, homedir=None, baseurl=None,
|
||||
noWindow=False, logcat_dir=None, busybox=None):
|
||||
noWindow=False, logcat_dir=None, busybox=None, load_early=False):
|
||||
self.host = host
|
||||
self.port = self.local_port = port
|
||||
self.bin = bin
|
||||
@ -145,9 +145,8 @@ class Marionette(object):
|
||||
self.client = MarionetteClient(self.host, self.port)
|
||||
|
||||
if emulator:
|
||||
self.emulator.wait_for_system_message(self)
|
||||
if gecko_path:
|
||||
self.emulator.install_gecko(gecko_path, self)
|
||||
self.emulator.setup(self, gecko_path=self.gecko_path,
|
||||
load_early=load_early)
|
||||
if busybox:
|
||||
self.emulator.install_busybox(busybox)
|
||||
|
||||
|
@ -185,7 +185,7 @@ class MarionetteTestRunner(object):
|
||||
es_server=None, rest_server=None, logger=None,
|
||||
testgroup="marionette", noWindow=False, logcat_dir=None,
|
||||
xml_output=None, repeat=0, perf=False, perfserv=None,
|
||||
gecko_path=None, testvars=None, tree=None):
|
||||
gecko_path=None, testvars=None, tree=None, load_early=False):
|
||||
self.address = address
|
||||
self.emulator = emulator
|
||||
self.emulatorBinary = emulatorBinary
|
||||
@ -213,6 +213,7 @@ class MarionetteTestRunner(object):
|
||||
self.gecko_path = gecko_path
|
||||
self.testvars = None
|
||||
self.tree = tree
|
||||
self.load_early = load_early
|
||||
|
||||
if testvars is not None:
|
||||
if not os.path.exists(testvars):
|
||||
@ -295,7 +296,8 @@ class MarionetteTestRunner(object):
|
||||
baseurl=self.baseurl,
|
||||
noWindow=self.noWindow,
|
||||
logcat_dir=self.logcat_dir,
|
||||
gecko_path=self.gecko_path)
|
||||
gecko_path=self.gecko_path,
|
||||
load_early=self.load_early)
|
||||
else:
|
||||
raise Exception("must specify binary, address or emulator")
|
||||
|
||||
@ -628,6 +630,11 @@ def parse_options():
|
||||
parser.add_option('--tree', dest='tree', action='store',
|
||||
default='b2g',
|
||||
help='the tree that the revsion parameter refers to')
|
||||
parser.add_option('--load-early', dest='load_early', action='store_true',
|
||||
default=False,
|
||||
help='on an emulator, causes Marionette to load earlier '
|
||||
'in the startup process than it otherwise would; needed '
|
||||
'for testing WebAPIs')
|
||||
|
||||
options, tests = parser.parse_args()
|
||||
|
||||
@ -640,6 +647,11 @@ def parse_options():
|
||||
print "must specify --binary, --emulator or --address"
|
||||
parser.exit()
|
||||
|
||||
if options.load_early and not options.emulator:
|
||||
parser.print_usage()
|
||||
print "must specify --load-early on when using --emulator"
|
||||
parser.exit()
|
||||
|
||||
# default to storing logcat output for emulator runs
|
||||
if options.emulator and not options.logcat_dir:
|
||||
options.logcat_dir = 'logcat'
|
||||
@ -680,7 +692,8 @@ def startTestRunner(runner_class, options, tests):
|
||||
perf=options.perf,
|
||||
perfserv=options.perfserv,
|
||||
gecko_path=options.gecko_path,
|
||||
testvars=options.testvars)
|
||||
testvars=options.testvars,
|
||||
load_early=options.load_early)
|
||||
runner.run_tests(tests, testtype=options.type)
|
||||
return runner
|
||||
|
||||
@ -692,5 +705,3 @@ def cli(runner_class=MarionetteTestRunner):
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user