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
parent bbda646b7e
commit 67b4c3b130
4 changed files with 31 additions and 20 deletions

View File

@ -32,7 +32,7 @@ class Emulator(object):
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._emulator_launched = False
self.proc = None
@ -42,6 +42,7 @@ class Emulator(object):
self._adb_started = False
self.logcat_dir = logcat_dir
self.logcat_proc = None
self.arch = arch
self.battery = EmulatorBattery(self)
self.homedir = homedir
self.noWindow = noWindow
@ -59,24 +60,32 @@ class Emulator(object):
if os.access(oldstyle_homedir, os.F_OK):
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')
if not os.access(self.adb, os.F_OK):
self.adb = os.path.join(self.homedir, 'bin/adb')
self.binary = os.path.join(self.homedir, 'out/host/linux-x86/bin/emulator')
if not os.access(self.binary, os.F_OK):
self.binary = os.path.join(self.homedir, 'bin/emulator')
self.binary = os.path.join(self.homedir, binary)
self._check_file(self.binary)
self.kernelImg = os.path.join(self.homedir,
'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.kernelImg = os.path.join(self.homedir, kernel)
self._check_file(self.kernelImg)
self.sysDir = os.path.join(self.homedir, 'out/target/product/generic')
if not os.access(self.sysDir, os.F_OK):
self.sysDir = os.path.join(self.homedir, 'generic')
self.sysDir = os.path.join(self.homedir, sysdir)
self._check_file(self.sysDir)
self.dataImg = os.path.join(self.sysDir, 'userdata.img')
@ -105,7 +114,7 @@ class Emulator(object):
'-partition-size', '512',
'-verbose',
'-skin', '480x800',
'-qemu', '-cpu', 'cortex-a8'])
'-qemu'] + self.tail_args)
return qemuArgs
@property

View File

@ -103,7 +103,7 @@ class Marionette(object):
CONTEXT_CONTENT = 'content'
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):
self.host = host
self.port = self.local_port = port
@ -124,7 +124,8 @@ class Marionette(object):
if emulator:
self.emulator = Emulator(homedir=homedir,
noWindow=self.noWindow,
logcat_dir=self.logcat_dir)
logcat_dir=self.logcat_dir,
arch=emulator)
self.emulator.start()
self.port = self.emulator.setup_port_forwarding(self.port)
assert(self.emulator.wait_for_port())

View File

@ -67,7 +67,7 @@ class MarionetteTestCase(CommonTestCase):
def get_new_emulator(self):
self.extra_emulator_index += 1
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,
baseurl=self.marionette.baseurl,
noWindow=self.marionette.noWindow)

View File

@ -130,7 +130,7 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
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,
rest_server=None, logger=None, testgroup="marionette",
noWindow=False, logcat_dir=None):
@ -200,7 +200,7 @@ class MarionetteTestRunner(object):
port=int(port),
baseurl=self.baseurl)
elif self.emulator:
self.marionette = Marionette(emulator=True,
self.marionette = Marionette(emulator=self.emulator,
homedir=self.homedir,
baseurl=self.baseurl,
noWindow=self.noWindow,
@ -354,9 +354,10 @@ if __name__ == "__main__":
action = "store", dest = "testgroup",
help = "testgroup names for autolog submissions")
parser.add_option("--emulator",
action = "store_true", dest = "emulator",
default = False,
help = "launch a B2G emulator on which to run tests")
action = "store", dest = "emulator",
default = None, choices = ["x86", "arm"],
help = "Launch a B2G emulator on which to run tests. "
"You need to specify which architecture to emulate.")
parser.add_option("--no-window",
action = "store_true", dest = "noWindow",
default = False,