def PrepareTest(self): """Pre-test modification to the image and env to setup test.""" logging.info('Setting up the image %s for vm testing.', self.image_path) vm_path = vm.CreateVMImage(image=self.image_path, board=self.board, updatable=False) logging.info('Making copy of the vm image %s to manipulate.', vm_path) self.working_image_path = os.path.join(self.tmpdir, os.path.basename(vm_path)) shutil.copyfile(vm_path, self.working_image_path) logging.debug('Copy of vm image stored at %s.', self.working_image_path) logging.info('Wiping /usr/local/bin from the image.') self._WipeDevInstall() self.vm = vm.VMInstance(self.working_image_path, tempdir=self.tmpdir) logging.info('Starting the vm on port %d.', self.vm.port) self.vm.Start() self.device = remote_access.ChromiumOSDevice(remote_access.LOCALHOST, port=self.vm.port, base_dir=self.tmpdir) if not self.binhost: logging.info('Starting the devserver.') self.devserver = dev_server_wrapper.DevServerWrapper() self.devserver.Start() self.binhost = self.devserver.GetURL( sub_dir='static/pkgroot/%s/packages' % self.board) logging.info('Using binhost %s', self.binhost)
def _StartSsh(self): """Starts an SSH session or executes a remote command. Also creates |self.device| if it doesn't yet exist. It's created once and saved so that if the user wants to use the default device, we only have to go through the discovery procedure the first time. Requires that _ReadOptions() has already been called to provide the SSH configuration. Returns: The SSH return code. Raises: SSHConnectionError on SSH connect failure. """ # Create the ChromiumOSDevice the first time through this function. if not self.device: # Set |base_dir| to None to avoid the SSH setup commands which # could require the user to enter a password multiple times. We don't # need any of the additional functionality that |base_dir| enables. self.device = remote_access.ChromiumOSDevice( self.ssh_hostname, port=self.ssh_port, username=self.ssh_username, base_dir=None, private_key=self.ssh_private_key, ping=False) return self.device.BaseRunCommand( self.command, connect_settings=self._ConnectSettings(), error_code_ok=True, mute_output=False, redirect_stderr=True, capture_output=False).returncode
def __init__(self, options, tempdir, staging_dir): """Initialize the class. Args: options: options object. tempdir: Scratch space for the class. Caller has responsibility to clean it up. staging_dir: Directory to stage the files to. """ self.tempdir = tempdir self.options = options self.staging_dir = staging_dir if not self.options.staging_only: if options.device: hostname = options.device.hostname port = options.device.port else: hostname = options.to port = options.port self.device = remote.ChromiumOSDevice( hostname, port=port, ping=options.ping, private_key=options.private_key, include_dev_paths=False) self._root_dir_is_still_readonly = multiprocessing.Event() self._deployment_name = 'lacros' if options.lacros else 'chrome' self.copy_paths = chrome_util.GetCopyPaths(self._deployment_name) self.chrome_dir = LACROS_DIR if self.options.lacros else _CHROME_DIR # Whether UI was stopped during setup. self._stopped_ui = False
def ProcessOptions(self): """Process self.options. It sets reuse_repo, reuse_build and reuse_eval if self.options.reuse is set. It also resolves self.options.board from DUT if it is not assigned. """ if self.options.reuse: self.options.reuse_repo = True self.options.reuse_build = True self.options.reuse_eval = True if not self.options.board: dut = remote_access.ChromiumOSDevice(self.options.remote.hostname) self.options.board = dut.board if not self.options.board: raise Exception('Unable to obtain board name from DUT.') else: logging.info('Obtained board name "%s" from DUT.', self.options.board)