def _boot_linaro_image(self, skip, emmc): if self.proc: if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None self.proc = connect_to_serial(self.context) # add below part # skip=True, only connect to the device, don't reboot & deploy the image # skip=False, connect to the device, then reboot to bootloader & deploy the image # emmc=True, make factory emmc if skip is True: self._booted = True # bootloader and not booted, 2016.01.21 if self._is_bootloader() and not self._booted: if self.config.hard_reset_command or self.config.hard_reset_command == "": self._hard_reboot(self.proc) self._run_boot() else: self._soft_reboot(self.proc) self._run_boot() self._booted = True # bootloader and booted, 2016.01.21 elif self._is_bootloader() and self._booted: self.proc.sendline('export PS1="%s"' % self.tester_ps1, send_char=self.config.send_char) else: super(BootloaderTarget, self)._boot_linaro_image()
def power_off(self, proc): if self._uefi_vars is not None: logging.info('Requesting graceful shutdown') self._sim_proc.kill(signal.SIGTERM) self._sim_proc.wait() super(FastModelTarget, self).power_off(proc) finalize_process(self._sim_proc) self._sim_proc = None
def power_off(self, proc): if self.proc: try: self._soft_reboot(self.proc) except KeyboardInterrupt: raise KeyboardInterrupt except: logging.info('Graceful reboot of platform failed') finalize_process(self.proc) self.proc = None
def power_off(self, proc): if self.config.power_off_cmd != "": self.context.run_command(self.config.power_off_cmd) else: proc.send("~$") proc.sendline("off") if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None
def power_off(self, proc): if self.proc: try: subprocess.check_call(['lxc-stop', '-n', self.name]) if not self.persist: subprocess.check_call(['lxc-destroy', '-n', self.name]) logging.info('Destroyed container %s' % self.name) except OperationFailed: logging.info('Power off failed') finalize_process(self.proc) self.proc = None
def power_off(self, proc): # if self.config.power_off_cmd != "": # self.context.run_command(self.config.power_off_cmd) # else: # # proc.send("~$") # proc.sendline("off") logging.warning("comment the power_off function at 2016.02.16") if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None
def power_off(self, proc): if self.config.power_off_cmd != "": self.context.run_command(self.config.power_off_cmd) else: proc.send("~$") # add by wuyanjun proc.send("~.") proc.sendline("off") if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None
def power_off(self, proc): if self._sim_proc: try: self._soft_reboot(self.proc) except KeyboardInterrupt: raise KeyboardInterrupt except: logging.info('Graceful reboot of platform failed') if self._uefi_vars is not None and self._sim_proc: logging.info('Requesting graceful shutdown') self._sim_proc.kill(signal.SIGTERM) self._sim_proc.wait() finalize_process(self._sim_proc) super(FastModelTarget, self).power_off(proc) self._sim_proc = None
def power_off(self, proc): if self.config.master_image_halt_command: self.proc.sendline(self.config.master_image_halt_command) self.proc.expect([self.config.master_image_halt_complete_message, pexpect.TIMEOUT], timeout=self.config.master_image_halt_time) if self.config.power_off_cmd != "": self.context.run_command(self.config.power_off_cmd) else: proc.send("~$") proc.sendline("off") if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) else: self._politely_close_console(self.proc) finalize_process(self.proc) self.proc = None
def _boot_linaro_image(self): if self.proc: if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None self.proc = connect_to_serial(self.context) if self._is_bootloader() and not self._booted: if self.config.hard_reset_command or self.config.hard_reset_command != "": self._hard_reboot(self.proc) self._run_boot() else: self._soft_reboot(self.proc) self._run_boot() self._booted = True elif self._is_bootloader() and self._booted: self.proc.sendline('export PS1="%s"' % self.tester_ps1, send_char=self.config.send_char) else: super(BootloaderTarget, self)._boot_linaro_image()
def _boot_linaro_image(self): if self.proc: if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) else: self._politely_close_console(self.proc) finalize_process(self.proc) self.proc = None self.proc = connect_to_serial(self.context) if self._is_bootloader() and not self._booted: if self.config.hard_reset_command or self.config.hard_reset_command == "": self._hard_reboot(self.proc) self._run_boot() else: self._soft_reboot(self.proc) self._run_boot() self._booted = True elif self._is_bootloader() and self._booted: self.proc.sendline('export PS1="%s"' % self.tester_ps1, send_char=self.config.send_char) else: super(BootloaderTarget, self)._boot_linaro_image()
def whaley_file_system(self, path, git_info): logging.info( "get the target device socat command, ip address and pdu port") # socat command connection_command = self.config.connection_command ############################################## # get device ip address info ############################################## pat = self.tester_ps1_pattern incrc = self.tester_ps1_includes_rc runner = NetworkCommandRunner(self, pat, incrc) ip = '' for i in range(3): try: # get the target device ip ip = runner.get_target_ip() break except Exception as e: logging.warning("can't get target ip, try reboot") self.proc.sendline('reboot') self._burn_su_image(self.proc) self._enter_recovery_whaley(self.proc) self._su_device_whaley(self.proc) time.sleep(30) self._skip_guide_whaley(self.proc) if not ip: raise CriticalError("Network error detected..aborting") ############################################## # get the pdu port info ############################################## hard_reset_command = self.config.hard_reset_command command = hard_reset_command.strip().split(' ') if command: pdu_ip = '' pdu_port = '' if '--hostname' in command: index = command.index('--hostname') pdu_ip = command[index + 1] if '--port' in command: index = command.index('--port') pdu_port = command[index + 1] if pdu_port and pdu_ip: pdu = pdu_ip + ':' + pdu_port else: pdu = '' logging.info("PDU port number is: %s" % pdu) ############################################## # get current job id ############################################## output_dir = self.context.output.output_dir if output_dir: logging.info("current job output directory: %s" % output_dir) job_id = output_dir.strip().split('/')[-1] job_id = job_id.split('-')[-1] else: job_id = "0" ############################################## # dump info to plan.json ###############################e############### if os.path.isfile(path): with open(path, "r") as fin: data = json.load(fin) else: logging.error("no json file found") raise data["device"]["target"] = str(ip) + ":5555" data["device"]["socat"] = connection_command data["device"]["pdu"] = str(pdu) job_data = self.context.job_data params = {} for cmd in job_data['actions']: if cmd.get('command') == 'deploy_whaley_image': params = cmd.get('parameters', {}) logging.info("deploy_whaley_image parameters: %s" % params) image = params.get("image", "").split("/") data["device"]["image"] = image[0] + "/" + image[1] # get prop ro.build.product self.proc.sendline('') self.proc.empty_buffer() self.proc.sendline('getprop ro.build.product') self.proc.expect(['shell@', 'root@', pexpect.TIMEOUT]) buffer_before = self.proc.before.strip() platform = buffer_before.split('\r\n')[-1] data["device"]["platform"] = platform.capitalize() data["device"]["job_id"] = int(job_id) data["mail"]["subject"] = data["mail"][ "subject"] + " " + self.context.job_data.get("job_name") data["git"] = git_info # H01P55D-01.13.00-1616508-65_1255 result = self.context.job_data.get("job_name") + "_" + job_id result_dir = os.path.join("/result", result) os.makedirs(result_dir) if os.path.isdir(result_dir): logging.info("makedirs %s successfully" % result_dir) else: logging.warning("can't makedirs %s, try again" % result_dir) os.makedirs(result_dir) case_json = os.path.join(result_dir, "plan.json") with open(case_json, "w") as fout: logging.info("write lava to json file %s" % case_json) json.dump(data, fout, indent=4) logging.warning( "disconnect the serial connection, try to run the script") if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None self.context.client.proc = self.proc return case_json
def finalize(self, proc): finalize_process(proc)
def power_off(self, proc): if self.config.power_off_cmd: self.context.run_command(self.config.power_off_cmd) finalize_process(self.proc)
def boot_master_image(self): """ reboot the system, and check that we are in a master shell """ self.context.client.vm_group.wait_for_vms() boot_attempts = self.config.boot_retries attempts = 0 in_master_image = False while (attempts < boot_attempts) and (not in_master_image): logging.info("Booting the system master image. Attempt: %d", attempts + 1) try: if self.proc: if self.config.connection_command_terminate: self.proc.sendline( self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None self.proc = connect_to_serial(self.context) self.master_ip = None if self.config.hard_reset_command: self._hard_reboot(self.proc) self._load_master_firmware() self._wait_for_master_boot() else: self._soft_reboot(self.proc) self._load_master_firmware() self._wait_for_master_boot() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Resetting platform into master image failed: %s" % e logging.warning(msg) attempts += 1 continue runner = MasterCommandRunner(self) try: self.master_ip = runner.get_target_ip() self.device_version = runner.get_device_version() except NetworkError as e: msg = "Failed to get network up: %s" % e logging.warning(msg) attempts += 1 continue lava_proxy = self.context.config.lava_proxy if lava_proxy: logging.info("Setting up http proxy") runner.run("export http_proxy=%s" % lava_proxy, timeout=30) lava_no_proxy = self.context.config.lava_no_proxy if lava_no_proxy: runner.run("export no_proxy=%s" % lava_no_proxy, timeout=30) logging.info("System is in master image now") self.context.test_data.add_result('boot_master_image', 'pass') in_master_image = True if not in_master_image: msg = "Master Image Error: Could not get master image booted properly" logging.error(msg) self.context.test_data.add_result('boot_master_image', 'fail') raise CriticalError(msg)
def power_off(self, proc): finalize_process(self.proc) self.proc = None
def power_off(self, proc): self.bootcontrol.power_off() finalize_process(self.proc)
def boot_master_image(self): """ reboot the system, and check that we are in a master shell """ self.context.client.vm_group.wait_for_vms() boot_attempts = self.config.boot_retries attempts = 0 in_master_image = False while (attempts < boot_attempts) and (not in_master_image): logging.info("Booting the system master image. Attempt: %d", attempts + 1) try: if self.proc: if self.config.connection_command_terminate: self.proc.sendline(self.config.connection_command_terminate) finalize_process(self.proc) self.proc = None self.proc = connect_to_serial(self.context) self.master_ip = None if self.config.hard_reset_command: self._hard_reboot(self.proc) self._load_master_firmware() self._wait_for_master_boot() else: self._soft_reboot(self.proc) self._load_master_firmware() self._wait_for_master_boot() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Resetting platform into master image failed: %s" % e logging.warning(msg) attempts += 1 continue runner = MasterCommandRunner(self) try: self.master_ip = runner.get_target_ip() self.device_version = runner.get_device_version() except NetworkError as e: msg = "Failed to get network up: %s" % e logging.warning(msg) attempts += 1 continue lava_proxy = self.context.config.lava_proxy if lava_proxy: logging.info("Setting up http proxy") runner.run("export http_proxy=%s" % lava_proxy, timeout=30) lava_no_proxy = self.context.config.lava_no_proxy if lava_no_proxy: runner.run("export no_proxy=%s" % lava_no_proxy, timeout=30) logging.info("System is in master image now") self.context.test_data.add_result('boot_master_image', 'pass') in_master_image = True if not in_master_image: msg = "Master Image Error: Could not get master image booted properly" logging.error(msg) self.context.test_data.add_result('boot_master_image', 'fail') raise CriticalError(msg)