Bug 755427: Use the darwin-x86 host directory for the emulator in OSX. Added a new --emulator-binary argument to runtests.py to allow overriding of the emulator used by Marionette. r=mdas

This commit is contained in:
Marshall Culpepper 2012-05-16 12:42:59 -07:00
Родитель d70936f0e6
Коммит 313f16d96e
4 изменённых файлов: 28 добавлений и 8 удалений

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

@ -3,6 +3,7 @@ from mozprocess import ProcessHandlerMixin
import multiprocessing import multiprocessing
import os import os
import re import re
import platform
import shutil import shutil
import socket import socket
import subprocess import subprocess
@ -32,7 +33,7 @@ class Emulator(object):
deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$") deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
def __init__(self, homedir=None, noWindow=False, logcat_dir=None, arch="x86"): def __init__(self, homedir=None, noWindow=False, logcat_dir=None, arch="x86", emulatorBinary=None):
self.port = None self.port = None
self._emulator_launched = False self._emulator_launched = False
self.proc = None self.proc = None
@ -43,6 +44,7 @@ class Emulator(object):
self.logcat_dir = logcat_dir self.logcat_dir = logcat_dir
self.logcat_proc = None self.logcat_proc = None
self.arch = arch self.arch = arch
self.binary = emulatorBinary
self.battery = EmulatorBattery(self) self.battery = EmulatorBattery(self)
self.homedir = homedir self.homedir = homedir
self.noWindow = noWindow self.noWindow = noWindow
@ -64,22 +66,30 @@ class Emulator(object):
raise Exception("Emulator architecture must be one of x86, arm, got: %s" % raise Exception("Emulator architecture must be one of x86, arm, got: %s" %
self.arch) self.arch)
host_dir = "linux-x86"
if platform.system() == "Darwin":
host_dir = "darwin-x86"
host_bin_dir = os.path.join("out/host", host_dir, "bin")
if self.arch == "x86": if self.arch == "x86":
binary = "out/host/linux-x86/bin/emulator-x86" binary = os.path.join(host_bin_dir, "emulator-x86")
kernel = "prebuilts/qemu-kernel/x86/kernel-qemu" kernel = "prebuilts/qemu-kernel/x86/kernel-qemu"
sysdir = "out/target/product/generic_x86" sysdir = "out/target/product/generic_x86"
self.tail_args = [] self.tail_args = []
else: else:
binary = "out/host/linux-x86/bin/emulator" binary = os.path.join(host_bin_dir, "emulator")
kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7" kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7"
sysdir = "out/target/product/generic" sysdir = "out/target/product/generic"
self.tail_args = ["-cpu", "cortex-a8"] self.tail_args = ["-cpu", "cortex-a8"]
self.adb = os.path.join(self.homedir, 'out/host/linux-x86/bin/adb') self.adb = os.path.join(self.homedir, host_bin_dir, "adb")
if not os.access(self.adb, os.F_OK): if not os.access(self.adb, os.F_OK):
self.adb = os.path.join(self.homedir, 'bin/adb') self.adb = os.path.join(self.homedir, 'bin/adb')
if not self.binary:
self.binary = os.path.join(self.homedir, binary) self.binary = os.path.join(self.homedir, binary)
self._check_file(self.binary) self._check_file(self.binary)
self.kernelImg = os.path.join(self.homedir, kernel) self.kernelImg = os.path.join(self.homedir, kernel)

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

@ -103,7 +103,7 @@ class Marionette(object):
CONTEXT_CONTENT = 'content' CONTEXT_CONTENT = 'content'
def __init__(self, host='localhost', port=2828, b2gbin=False, def __init__(self, host='localhost', port=2828, b2gbin=False,
emulator=None, connectToRunningEmulator=False, emulator=None, emulatorBinary=None, connectToRunningEmulator=False,
homedir=None, baseurl=None, noWindow=False, logcat_dir=None): homedir=None, baseurl=None, noWindow=False, logcat_dir=None):
self.host = host self.host = host
self.port = self.local_port = port self.port = self.local_port = port
@ -125,7 +125,8 @@ class Marionette(object):
self.emulator = Emulator(homedir=homedir, self.emulator = Emulator(homedir=homedir,
noWindow=self.noWindow, noWindow=self.noWindow,
logcat_dir=self.logcat_dir, logcat_dir=self.logcat_dir,
arch=emulator) arch=emulator,
emulatorBinary=emulatorBinary)
self.emulator.start() self.emulator.start()
self.port = self.emulator.setup_port_forwarding(self.port) self.port = self.emulator.setup_port_forwarding(self.port)
assert(self.emulator.wait_for_port()) assert(self.emulator.wait_for_port())

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

@ -103,6 +103,7 @@ class MarionetteTestCase(CommonTestCase):
self.extra_emulator_index += 1 self.extra_emulator_index += 1
if len(self.marionette.extra_emulators) == self.extra_emulator_index: if len(self.marionette.extra_emulators) == self.extra_emulator_index:
qemu = Marionette(emulator=self.marionette.emulator.arch, qemu = Marionette(emulator=self.marionette.emulator.arch,
emulatorBinary=self.marionette.emulator.binary,
homedir=self.marionette.homedir, homedir=self.marionette.homedir,
baseurl=self.marionette.baseurl, baseurl=self.marionette.baseurl,
noWindow=self.marionette.noWindow) noWindow=self.marionette.noWindow)

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

@ -130,12 +130,13 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
class MarionetteTestRunner(object): class MarionetteTestRunner(object):
def __init__(self, address=None, emulator=None, homedir=None, def __init__(self, address=None, emulator=None, emulatorBinary=None, homedir=None,
b2gbin=None, autolog=False, revision=None, es_server=None, b2gbin=None, autolog=False, revision=None, es_server=None,
rest_server=None, logger=None, testgroup="marionette", rest_server=None, logger=None, testgroup="marionette",
noWindow=False, logcat_dir=None): noWindow=False, logcat_dir=None):
self.address = address self.address = address
self.emulator = emulator self.emulator = emulator
self.emulatorBinary = emulatorBinary
self.homedir = homedir self.homedir = homedir
self.b2gbin = b2gbin self.b2gbin = b2gbin
self.autolog = autolog self.autolog = autolog
@ -201,6 +202,7 @@ class MarionetteTestRunner(object):
baseurl=self.baseurl) baseurl=self.baseurl)
elif self.emulator: elif self.emulator:
self.marionette = Marionette(emulator=self.emulator, self.marionette = Marionette(emulator=self.emulator,
emulatorBinary=self.emulatorBinary,
homedir=self.homedir, homedir=self.homedir,
baseurl=self.baseurl, baseurl=self.baseurl,
noWindow=self.noWindow, noWindow=self.noWindow,
@ -358,6 +360,11 @@ if __name__ == "__main__":
default = None, choices = ["x86", "arm"], default = None, choices = ["x86", "arm"],
help = "Launch a B2G emulator on which to run tests. " help = "Launch a B2G emulator on which to run tests. "
"You need to specify which architecture to emulate.") "You need to specify which architecture to emulate.")
parser.add_option("--emulator-binary",
action = "store", dest = "emulatorBinary",
default = None,
help = "Launch a specific emulator binary rather than "
"launching from the B2G built emulator")
parser.add_option("--no-window", parser.add_option("--no-window",
action = "store_true", dest = "noWindow", action = "store_true", dest = "noWindow",
default = False, default = False,
@ -399,6 +406,7 @@ if __name__ == "__main__":
runner = MarionetteTestRunner(address=options.address, runner = MarionetteTestRunner(address=options.address,
emulator=options.emulator, emulator=options.emulator,
emulatorBinary=options.emulatorBinary,
homedir=options.homedir, homedir=options.homedir,
logcat_dir=options.logcat_dir, logcat_dir=options.logcat_dir,
b2gbin=options.b2gbin, b2gbin=options.b2gbin,