def connect(self): self.adb = B2GInstance.check_adb(self.homedir, emulator=True) self.start_adb() online, offline = self._get_adb_devices() now = datetime.datetime.now() while online == set([]): time.sleep(1) if datetime.datetime.now() - now > datetime.timedelta(seconds=60): raise Exception("timed out waiting for emulator to be available") online, offline = self._get_adb_devices() self.port = int(list(online)[0]) self.dm = devicemanagerADB.DeviceManagerADB(adbPath=self.adb, deviceSerial="emulator-%d" % self.port)
def connect(self): self.adb = B2GInstance.check_adb(self.homedir, emulator=True) self.start_adb() online, offline = self._get_adb_devices() now = datetime.datetime.now() while online == set([]): time.sleep(1) if datetime.datetime.now() - now > datetime.timedelta(seconds=60): raise Exception('timed out waiting for emulator to be available') online, offline = self._get_adb_devices() self.port = int(list(online)[0]) self.dm = devicemanagerADB.DeviceManagerADB(adbPath=self.adb, deviceSerial='emulator-%d' % self.port)
def _check_for_b2g(self): self.b2g = B2GInstance(homedir=self.homedir, emulator=True, symbols_path=self.symbols_path) self.adb = self.b2g.adb_path self.homedir = self.b2g.homedir if self.arch not in ("x86", "arm"): raise Exception( "Emulator architecture must be one of x86, arm, got: %s" % 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": binary = os.path.join(host_bin_dir, "emulator-x86") kernel = "prebuilts/qemu-kernel/x86/kernel-qemu" sysdir = "out/target/product/generic_x86" self.tail_args = [] else: binary = os.path.join(host_bin_dir, "emulator") kernel = "prebuilts/qemu-kernel/arm/kernel-qemu-armv7" sysdir = "out/target/product/generic" self.tail_args = ["-cpu", "cortex-a8"] if (self.sdcard): self.mksdcard = os.path.join(self.homedir, host_bin_dir, "mksdcard") self.create_sdcard(self.sdcard) if not self.binary: self.binary = os.path.join(self.homedir, binary) self.b2g.check_file(self.binary) self.kernelImg = os.path.join(self.homedir, kernel) self.b2g.check_file(self.kernelImg) self.sysDir = os.path.join(self.homedir, sysdir) self.b2g.check_file(self.sysDir) if not self.dataImg: self.dataImg = os.path.join(self.sysDir, 'userdata.img') self.b2g.check_file(self.dataImg)
def __init__(self, host='localhost', port=2828, b2gbin=False, emulator=None, emulatorBinary=None, connectToRunningEmulator=False, homedir=None, baseurl=None, noWindow=False, logcat_dir=None): self.host = host self.port = self.local_port = port self.b2gbin = b2gbin self.session = None self.window = None self.emulator = None self.extra_emulators = [] self.homedir = homedir self.baseurl = baseurl self.noWindow = noWindow self.logcat_dir = logcat_dir if b2gbin: self.b2ginstance = B2GInstance(host=self.host, port=self.port, b2gbin=self.b2gbin) self.b2ginstance.start() assert (self.b2ginstance.wait_for_port()) if emulator: self.emulator = Emulator(homedir=homedir, noWindow=self.noWindow, logcat_dir=self.logcat_dir, arch=emulator, emulatorBinary=emulatorBinary) 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.connect() self.port = self.emulator.setup_port_forwarding(self.port) assert (self.emulator.wait_for_port()) self.client = MarionetteClient(self.host, self.port)
def __init__(self, **kwargs): MarionetteTestRunner.__init__(self, **kwargs) if self.emulator or self.bin: raise Exception('Update tests do not support emulator or custom binaries') if not self.address: raise Exception('Update tests must be run with ' '--address=localhost:<port>') self.host, port = self.address.split(':') self.port = int(port) self.test_handlers.append(self) self.b2g = B2GInstance(homedir=kwargs.get('homedir')) self.update_tools = self.b2g.import_update_tools() self.adb = self.update_tools.AdbTool(path=self.b2g.adb_path, device=self.device)
def find_b2g(): sys.path.append(marionette_client_dir) from b2ginstance import B2GInstance return B2GInstance()