mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 789976 - Add --gecko-path argument to Marionette, r=ahal, DONTBUILD (NPOTB)
This commit is contained in:
parent
fc58561b1a
commit
bc1d385b46
@ -36,8 +36,9 @@ class Emulator(object):
|
||||
|
||||
deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
|
||||
|
||||
def __init__(self, homedir=None, noWindow=False, logcat_dir=None, arch="x86",
|
||||
emulatorBinary=None, res='480x800', sdcard=None, userdata=None):
|
||||
def __init__(self, homedir=None, noWindow=False, logcat_dir=None,
|
||||
arch="x86", emulatorBinary=None, res='480x800', sdcard=None,
|
||||
userdata=None, gecko_path=None):
|
||||
self.port = None
|
||||
self._emulator_launched = False
|
||||
self.proc = None
|
||||
@ -59,6 +60,7 @@ class Emulator(object):
|
||||
self.homedir = os.path.expanduser(homedir)
|
||||
self.dataImg = userdata
|
||||
self.copy_userdata = self.dataImg is None
|
||||
self.gecko_path = gecko_path
|
||||
|
||||
def _check_for_b2g(self):
|
||||
if self.homedir is None:
|
||||
@ -67,7 +69,7 @@ class Emulator(object):
|
||||
raise Exception('Must define B2G_HOME or pass the homedir parameter')
|
||||
self._check_file(self.homedir)
|
||||
|
||||
oldstyle_homedir = os.path.join(self.homedir, 'glue','gonk-ics')
|
||||
oldstyle_homedir = os.path.join(self.homedir, 'glue', 'gonk-ics')
|
||||
if os.access(oldstyle_homedir, os.F_OK):
|
||||
self.homedir = oldstyle_homedir
|
||||
|
||||
@ -79,7 +81,7 @@ class Emulator(object):
|
||||
if platform.system() == "Darwin":
|
||||
host_dir = "darwin-x86"
|
||||
|
||||
host_bin_dir = os.path.join("out","host", host_dir, "bin")
|
||||
host_bin_dir = os.path.join("out", "host", host_dir, "bin")
|
||||
|
||||
if self.arch == "x86":
|
||||
binary = os.path.join(host_bin_dir, "emulator-x86")
|
||||
@ -125,10 +127,10 @@ class Emulator(object):
|
||||
|
||||
@property
|
||||
def args(self):
|
||||
qemuArgs = [ self.binary,
|
||||
'-kernel', self.kernelImg,
|
||||
'-sysdir', self.sysDir,
|
||||
'-data', self.dataImg ]
|
||||
qemuArgs = [self.binary,
|
||||
'-kernel', self.kernelImg,
|
||||
'-sysdir', self.sysDir,
|
||||
'-data', self.dataImg]
|
||||
if self._tmp_sdcard:
|
||||
qemuArgs.extend(['-sdcard', self._tmp_sdcard])
|
||||
if self.noWindow:
|
||||
@ -147,16 +149,16 @@ class Emulator(object):
|
||||
return self.proc is not None and self.proc.poll() is None
|
||||
else:
|
||||
return self.port is not None
|
||||
|
||||
|
||||
def create_sdcard(self, sdcard):
|
||||
self._tmp_sdcard = tempfile.mktemp(prefix='sdcard')
|
||||
sdargs = [self.mksdcard, "-l" , "mySdCard", sdcard, self._tmp_sdcard]
|
||||
sd = subprocess.Popen(sdargs, stdout= subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
retcode = sd.wait()
|
||||
if retcode:
|
||||
raise Exception('unable to create sdcard : exit code %d: %s'
|
||||
% (retcode, adb.stdout.read()))
|
||||
return None
|
||||
self._tmp_sdcard = tempfile.mktemp(prefix='sdcard')
|
||||
sdargs = [self.mksdcard, "-l", "mySdCard", sdcard, self._tmp_sdcard]
|
||||
sd = subprocess.Popen(sdargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
retcode = sd.wait()
|
||||
if retcode:
|
||||
raise Exception('unable to create sdcard : exit code %d: %s'
|
||||
% (retcode, sd.stdout.read()))
|
||||
return None
|
||||
|
||||
def _check_for_adb(self):
|
||||
host_dir = "linux-x86"
|
||||
@ -166,12 +168,13 @@ class Emulator(object):
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
if adb.wait() == 0:
|
||||
self.adb = adb.stdout.read().strip() # remove trailing newline
|
||||
self.adb = adb.stdout.read().strip() # remove trailing newline
|
||||
return
|
||||
adb_paths = [os.path.join(self.homedir,'glue','gonk','out','host',
|
||||
host_dir ,'bin','adb'),os.path.join(self.homedir, 'out',
|
||||
'host', host_dir,'bin', 'adb'),os.path.join(self.homedir,
|
||||
'bin','adb')]
|
||||
adb_paths = [os.path.join(self.homedir, 'glue', 'gonk', 'out', 'host',
|
||||
host_dir, 'bin', 'adb'),
|
||||
os.path.join(self.homedir, 'out', 'host', host_dir,
|
||||
'bin', 'adb'),
|
||||
os.path.join(self.homedir, 'bin', 'adb')]
|
||||
for option in adb_paths:
|
||||
if os.path.exists(option):
|
||||
self.adb = option
|
||||
@ -180,10 +183,13 @@ class Emulator(object):
|
||||
|
||||
def _run_adb(self, args):
|
||||
args.insert(0, self.adb)
|
||||
if self.port:
|
||||
args.insert(1, '-s')
|
||||
args.insert(2, 'emulator-%d' % self.port)
|
||||
adb = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
retcode = adb.wait()
|
||||
if retcode:
|
||||
raise Exception('adb terminated with exit code %d: %s'
|
||||
raise Exception('adb terminated with exit code %d: %s'
|
||||
% (retcode, adb.stdout.read()))
|
||||
return adb.stdout.read()
|
||||
|
||||
@ -198,7 +204,7 @@ class Emulator(object):
|
||||
if line.startswith('OK'):
|
||||
return output
|
||||
elif line.startswith('KO:'):
|
||||
raise Exception ('bad telnet response: %s' % line)
|
||||
raise Exception('bad telnet response: %s' % line)
|
||||
|
||||
def _run_telnet(self, command):
|
||||
if not self.telnet:
|
||||
@ -219,7 +225,7 @@ class Emulator(object):
|
||||
if self._tmp_userdata:
|
||||
os.remove(self._tmp_userdata)
|
||||
self._tmp_userdata = None
|
||||
if self._tmp_sdcard:
|
||||
if self._tmp_sdcard:
|
||||
os.remove(self._tmp_sdcard)
|
||||
self._tmp_sdcard = None
|
||||
return retcode
|
||||
@ -269,6 +275,8 @@ class Emulator(object):
|
||||
online, offline = self._get_adb_devices()
|
||||
self.port = int(list(online)[0])
|
||||
|
||||
self.install_gecko()
|
||||
|
||||
def start(self):
|
||||
self._check_for_b2g()
|
||||
self.start_adb()
|
||||
@ -301,8 +309,9 @@ class Emulator(object):
|
||||
self.save_logcat()
|
||||
|
||||
# setup DNS fix for networking
|
||||
self._run_adb(['-s', 'emulator-%d' % self.port,
|
||||
'shell', 'setprop', 'net.dns1', '10.0.2.3'])
|
||||
self._run_adb(['shell', 'setprop', 'net.dns1', '10.0.2.3'])
|
||||
|
||||
self.install_gecko()
|
||||
|
||||
def _save_logcat_proc(self, filename, cmd):
|
||||
self.logcat_proc = LogcatProc(filename, cmd)
|
||||
@ -311,6 +320,21 @@ class Emulator(object):
|
||||
self.logcat_proc.waitForFinish()
|
||||
self.logcat_proc = None
|
||||
|
||||
def install_gecko(self):
|
||||
"""
|
||||
Install gecko into the emulator using adb push. Restart b2g after the
|
||||
installation.
|
||||
"""
|
||||
if not self.gecko_path:
|
||||
return
|
||||
# need to remount so we can write to /system/b2g
|
||||
self._run_adb(['remount'])
|
||||
self._run_adb(['shell', 'stop', 'b2g'])
|
||||
print 'installing gecko binaries'
|
||||
self._run_adb(['push', self.gecko_path, '/system/b2g'])
|
||||
print 'restarting B2G'
|
||||
self._run_adb(['shell', 'start', 'b2g'])
|
||||
|
||||
def rotate_log(self, srclog, index=1):
|
||||
""" Rotate a logfile, by recursively rotating logs further in the sequence,
|
||||
deleting the last file if necessary.
|
||||
@ -349,8 +373,7 @@ class Emulator(object):
|
||||
local_port = s.getsockname()[1]
|
||||
s.close()
|
||||
|
||||
output = self._run_adb(['-s', 'emulator-%d' % self.port,
|
||||
'forward',
|
||||
output = self._run_adb(['forward',
|
||||
'tcp:%d' % local_port,
|
||||
'tcp:%d' % remote_port])
|
||||
|
||||
@ -374,4 +397,3 @@ class Emulator(object):
|
||||
print traceback.format_exc()
|
||||
time.sleep(1)
|
||||
return False
|
||||
|
||||
|
@ -85,9 +85,10 @@ class Marionette(object):
|
||||
CONTEXT_CONTENT = 'content'
|
||||
|
||||
def __init__(self, host='localhost', port=2828, bin=None, profile=None,
|
||||
emulator=None, sdcard= None, emulatorBinary=None, emulatorImg=None,
|
||||
emulator_res='480x800', connectToRunningEmulator=False,
|
||||
homedir=None, baseurl=None, noWindow=False, logcat_dir=None):
|
||||
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):
|
||||
self.host = host
|
||||
self.port = self.local_port = port
|
||||
self.bin = bin
|
||||
@ -101,6 +102,7 @@ class Marionette(object):
|
||||
self.baseurl = baseurl
|
||||
self.noWindow = noWindow
|
||||
self.logcat_dir = logcat_dir
|
||||
self.gecko_path = gecko_path
|
||||
|
||||
if bin:
|
||||
self.instance = GeckoInstance(host=self.host, port=self.port,
|
||||
@ -115,13 +117,16 @@ class Marionette(object):
|
||||
sdcard=sdcard,
|
||||
emulatorBinary=emulatorBinary,
|
||||
userdata=emulatorImg,
|
||||
res=emulator_res)
|
||||
res=emulator_res,
|
||||
gecko_path=self.gecko_path)
|
||||
self.emulator.start()
|
||||
self.port = self.emulator.setup_port_forwarding(self.port)
|
||||
assert(self.emulator.wait_for_port())
|
||||
|
||||
if connectToRunningEmulator:
|
||||
self.emulator = Emulator(homedir=homedir, logcat_dir=self.logcat_dir)
|
||||
self.emulator = Emulator(homedir=homedir,
|
||||
logcat_dir=self.logcat_dir,
|
||||
gecko_path=self.gecko_path)
|
||||
self.emulator.connect()
|
||||
self.port = self.emulator.setup_port_forwarding(self.port)
|
||||
assert(self.emulator.wait_for_port())
|
||||
@ -262,7 +267,7 @@ class Marionette(object):
|
||||
def current_window_handle(self):
|
||||
self.window = self._send_message('getWindow', 'value')
|
||||
return self.window
|
||||
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
response = self._send_message('getTitle', 'value')
|
||||
|
@ -129,7 +129,8 @@ class MarionetteTestCase(CommonTestCase):
|
||||
emulatorBinary=self.marionette.emulator.binary,
|
||||
homedir=self.marionette.homedir,
|
||||
baseurl=self.marionette.baseurl,
|
||||
noWindow=self.marionette.noWindow)
|
||||
noWindow=self.marionette.noWindow,
|
||||
gecko_path=self.marionette.gecko_path)
|
||||
qemu.start_session()
|
||||
self.marionette.extra_emulators.append(qemu)
|
||||
else:
|
||||
|
@ -171,7 +171,8 @@ class MarionetteTestRunner(object):
|
||||
bin=None, profile=None, autolog=False, revision=None,
|
||||
es_server=None, rest_server=None, logger=None,
|
||||
testgroup="marionette", noWindow=False, logcat_dir=None,
|
||||
xml_output=None, repeat=0, perf=False, perfserv=None):
|
||||
xml_output=None, repeat=0, perf=False, perfserv=None,
|
||||
gecko_path=None):
|
||||
self.address = address
|
||||
self.emulator = emulator
|
||||
self.emulatorBinary = emulatorBinary
|
||||
@ -196,6 +197,7 @@ class MarionetteTestRunner(object):
|
||||
self.repeat = repeat
|
||||
self.perf = perf
|
||||
self.perfserv = perfserv
|
||||
self.gecko_path = gecko_path
|
||||
|
||||
# set up test handlers
|
||||
self.test_handlers = []
|
||||
@ -253,7 +255,8 @@ class MarionetteTestRunner(object):
|
||||
connectToRunningEmulator=True,
|
||||
homedir=self.homedir,
|
||||
baseurl=self.baseurl,
|
||||
logcat_dir=self.logcat_dir)
|
||||
logcat_dir=self.logcat_dir,
|
||||
gecko_path=self.gecko_path)
|
||||
else:
|
||||
self.marionette = Marionette(host=host,
|
||||
port=int(port),
|
||||
@ -266,7 +269,8 @@ class MarionetteTestRunner(object):
|
||||
homedir=self.homedir,
|
||||
baseurl=self.baseurl,
|
||||
noWindow=self.noWindow,
|
||||
logcat_dir=self.logcat_dir)
|
||||
logcat_dir=self.logcat_dir,
|
||||
gecko_path=self.gecko_path)
|
||||
else:
|
||||
raise Exception("must specify binary, address or emulator")
|
||||
|
||||
@ -604,7 +608,11 @@ def parse_options():
|
||||
default=0, help='number of times to repeat the test(s).')
|
||||
parser.add_option('-x', '--xml-output', action='store', dest='xml_output',
|
||||
help='XML output.')
|
||||
|
||||
parser.add_option('--gecko-path', dest='gecko_path', action='store',
|
||||
default=None,
|
||||
help='path to B2G gecko binaries that should be '
|
||||
'installed on the device or emulator')
|
||||
|
||||
options, tests = parser.parse_args()
|
||||
|
||||
if not tests:
|
||||
@ -653,7 +661,8 @@ def startTestRunner(runner_class, options, tests):
|
||||
xml_output=options.xml_output,
|
||||
repeat=options.repeat,
|
||||
perf=options.perf,
|
||||
perfserv=options.perfserv)
|
||||
perfserv=options.perfserv,
|
||||
gecko_path=options.gecko_path)
|
||||
runner.run_tests(tests, testtype=options.type)
|
||||
return runner
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user