Bug 754229 - Support x86 emulator in Marionette. r=jgriffin

This commit is contained in:
Philipp von Weitershausen 2012-05-11 13:06:45 -07:00
Родитель 80b7f36e85
Коммит 3be352ad8d
4 изменённых файлов: 31 добавлений и 20 удалений

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

@ -32,7 +32,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): def __init__(self, homedir=None, noWindow=False, logcat_dir=None, arch="x86"):
self.port = None self.port = None
self._emulator_launched = False self._emulator_launched = False
self.proc = None self.proc = None
@ -42,6 +42,7 @@ class Emulator(object):
self._adb_started = False self._adb_started = False
self.logcat_dir = logcat_dir self.logcat_dir = logcat_dir
self.logcat_proc = None self.logcat_proc = None
self.arch = arch
self.battery = EmulatorBattery(self) self.battery = EmulatorBattery(self)
self.homedir = homedir self.homedir = homedir
self.noWindow = noWindow self.noWindow = noWindow
@ -59,24 +60,32 @@ class Emulator(object):
if os.access(oldstyle_homedir, os.F_OK): if os.access(oldstyle_homedir, os.F_OK):
self.homedir = oldstyle_homedir self.homedir = oldstyle_homedir
if self.arch not in ("x86", "arm"):
raise Exception("Emulator architecture must be one of x86, arm, got: %s" %
self.arch)
if self.arch == "x86":
binary = "out/host/linux-x86/bin/emulator-x86"
kernel = "prebuilts/qemu-kernel/x86/kernel-qemu"
sysdir = "out/target/product/generic_x86"
self.tail_args = []
else:
binary = "out/host/linux-x86/bin/emulator"
kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7"
sysdir = "out/target/product/generic"
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, 'out/host/linux-x86/bin/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')
self.binary = os.path.join(self.homedir, 'out/host/linux-x86/bin/emulator') self.binary = os.path.join(self.homedir, binary)
if not os.access(self.binary, os.F_OK):
self.binary = os.path.join(self.homedir, 'bin/emulator')
self._check_file(self.binary) self._check_file(self.binary)
self.kernelImg = os.path.join(self.homedir, self.kernelImg = os.path.join(self.homedir, kernel)
'prebuilts/qemu-kernel/arm/kernel-qemu-armv7')
if not os.access(self.kernelImg, os.F_OK):
self.kernelImg = os.path.join(self.homedir, 'kernel-qemu-armv7')
self._check_file(self.kernelImg) self._check_file(self.kernelImg)
self.sysDir = os.path.join(self.homedir, 'out/target/product/generic') self.sysDir = os.path.join(self.homedir, sysdir)
if not os.access(self.sysDir, os.F_OK):
self.sysDir = os.path.join(self.homedir, 'generic')
self._check_file(self.sysDir) self._check_file(self.sysDir)
self.dataImg = os.path.join(self.sysDir, 'userdata.img') self.dataImg = os.path.join(self.sysDir, 'userdata.img')
@ -105,7 +114,7 @@ class Emulator(object):
'-partition-size', '512', '-partition-size', '512',
'-verbose', '-verbose',
'-skin', '480x800', '-skin', '480x800',
'-qemu', '-cpu', 'cortex-a8']) '-qemu'] + self.tail_args)
return qemuArgs return qemuArgs
@property @property

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

@ -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=False, connectToRunningEmulator=False, emulator=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
@ -124,7 +124,8 @@ class Marionette(object):
if emulator: if emulator:
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)
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())

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

@ -67,7 +67,7 @@ class MarionetteTestCase(CommonTestCase):
def get_new_emulator(self): def get_new_emulator(self):
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=True, qemu = Marionette(emulator=self.marionette.emulator.arch,
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,7 +130,7 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
class MarionetteTestRunner(object): class MarionetteTestRunner(object):
def __init__(self, address=None, emulator=False, homedir=None, def __init__(self, address=None, emulator=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):
@ -200,7 +200,7 @@ class MarionetteTestRunner(object):
port=int(port), port=int(port),
baseurl=self.baseurl) baseurl=self.baseurl)
elif self.emulator: elif self.emulator:
self.marionette = Marionette(emulator=True, self.marionette = Marionette(emulator=self.emulator,
homedir=self.homedir, homedir=self.homedir,
baseurl=self.baseurl, baseurl=self.baseurl,
noWindow=self.noWindow, noWindow=self.noWindow,
@ -354,9 +354,10 @@ if __name__ == "__main__":
action = "store", dest = "testgroup", action = "store", dest = "testgroup",
help = "testgroup names for autolog submissions") help = "testgroup names for autolog submissions")
parser.add_option("--emulator", parser.add_option("--emulator",
action = "store_true", dest = "emulator", action = "store", dest = "emulator",
default = False, 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.")
parser.add_option("--no-window", parser.add_option("--no-window",
action = "store_true", dest = "noWindow", action = "store_true", dest = "noWindow",
default = False, default = False,