def wait_for_prompt(self, timeout=-1): wait_for_prompt(self._connection, self._prompt_str, timeout)
def _wait_for_prompt(self, connection, prompt_pattern, timeout): wait_for_prompt(connection, prompt_pattern, timeout)
def boot_linaro_android_image(self, adb_check=False): """Reboot the system to the test android image.""" boot_attempts = self.config.boot_retries attempts = 0 in_linaro_android_image = False while (attempts < boot_attempts) and (not in_linaro_android_image): logging.info("Booting the Android test image. Attempt: %d" % (attempts + 1)) TESTER_PS1_PATTERN = self.target_device.tester_ps1_pattern timeout = self.config.android_boot_prompt_timeout start = time.time() try: self._boot_linaro_android_image() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Failed to boot the Android test image: %s" % e logging.info(msg) attempts += 1 continue try: wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout) except pexpect.TIMEOUT: msg = "Timeout waiting for boot prompt" logging.info(msg) attempts += 1 continue # Record boot time metadata boottime = "{0:.2f}".format(time.time() - start) boottime_meta = {'kernel-boot-time': boottime} self.context.test_data.add_metadata(boottime_meta) logging.debug("Kernel boot time: %s seconds" % boottime) # TODO: set up proxy if not self.config.android_adb_over_usb: try: self._disable_adb_over_usb() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Failed to disable adb: %s" % e logging.info(msg) attempts += 1 continue if self.config.android_disable_suspend: try: self._disable_suspend() except (OperationFailed, pexpect.TIMEOUT, CriticalError) as e: msg = "Failed to disable suspend: %s" % e logging.info(msg) attempts += 1 continue if self.config.enable_network_after_boot_android: time.sleep(1) try: self._enable_network() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Failed to enable network: %s" % e logging.info(msg) attempts += 1 continue if self.config.android_adb_over_tcp: try: self._enable_adb_over_tcp() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Failed to enable adp over tcp: %s" % e logging.info(msg) attempts += 1 continue in_linaro_android_image = True if not in_linaro_android_image: msg = "Could not get the Android test image booted properly" logging.critical(msg) raise CriticalError(msg) # check if the adb connection can be created. # by adb connect dev_ip command if adb_check: try: session = AndroidTesterCommandRunner(self) session.connect() finally: session.disconnect()
def boot_linaro_image(self): """ Reboot the system to the test image """ logging.info("Boot the test image") boot_attempts = self.config.boot_retries attempts = 0 in_linaro_image = False while (attempts < boot_attempts) and (not in_linaro_image): logging.info("Booting the test image. Attempt: %d" % (attempts + 1)) timeout = self.config.boot_linaro_timeout TESTER_PS1_PATTERN = self.target_device.tester_ps1_pattern self.vm_group.wait_for_vms() start = time.time() try: self._boot_linaro_image() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Boot linaro image failed: %s" % e logging.info(msg) attempts += 1 continue try: wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout) except pexpect.TIMEOUT as e: msg = "Timeout waiting for boot prompt: %s" % e logging.info(msg) attempts += 1 continue # Record boot time metadata boottime = "{0:.2f}".format(time.time() - start) boottime_meta = {'kernel-boot-time': boottime} self.context.test_data.add_metadata(boottime_meta) logging.debug("Kernel boot time: %s seconds" % boottime) self.setup_proxy(TESTER_PS1_PATTERN) logging.info("System is in test image now") logging.debug("mount information") self.proc.sendline('mount') wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout) logging.debug("root directory information") self.proc.sendline('ls -l /') wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout) logging.debug("free space information") self.proc.sendline('df -h') wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout) logging.debug("IP addr information") self.proc.sendline('ip addr') wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout) in_linaro_image = True logging.debug("Checking for vm-group host") self.vm_group.start_vms() if not in_linaro_image: msg = "Could not get the test image booted properly" logging.critical(msg) raise CriticalError(msg)
def _wait_for_prompt(self, connection, prompt_pattern, timeout, skip_newlines=False): wait_for_prompt(connection, prompt_pattern, timeout, skip_newlines=skip_newlines)