def test_get_available_firmware_on_update_with_failure(self): """Test _get_available_firmware when update script exit_status=1.""" result = utils.CmdResult(exit_status=1) host = mock.Mock() host.run.return_value = result fw = cros_firmware._get_available_firmware(host, 'lumpy') self.assertIsNone(fw)
def test_get_available_firmware_returns_none(self): """_get_available_firmware returns None.""" result = utils.CmdResult(stdout=NO_VERSION_OUTPUT, exit_status=0) host = mock.Mock() host.run.return_value = result fw = cros_firmware._get_available_firmware(host, 'lumpy') self.assertIsNone(fw)
def test_get_available_firmware_returns_version(self): """_get_available_firmware returns BIOS version.""" result = utils.CmdResult(stdout=VERSION_OUTPUT, exit_status=0) host = mock.Mock() host.run.return_value = result fw = cros_firmware._get_available_firmware(host, 'lumpy') self.assertEqual(fw, 'Google_Lumpy.2.111.0')
def fastboot_run(self, command, **kwargs): """No-op, emulators do not support fastboot. @param command: command to not execute @param kwargs: additional arguments to ignore @return: empty CmdResult object """ return utils.CmdResult()
def run(self, cmd_line, *args, **kwargs): """Run command(s) on host. @param cmd_line command to run on the host. @return CmdResult object. """ cmds = re.split("&&", cmd_line) for cmd in cmds: self._run_single_cmd(cmd) return utils.CmdResult(exit_status=0)
def _execute_daemon(self, timeout, stderr_redirector, client_disconnect_timeout): monitor_dir = self.host.get_tmp_dir() daemon_cmd = self.get_daemon_cmd(monitor_dir) # grab the location for the server-side client log file client_log_prefix = self.get_client_log() client_log_path = os.path.join(self.results_dir, 'debug', client_log_prefix + '.log') client_log = open(client_log_path, 'w', 0) self.copy_client_config_file(client_log_prefix) stdout_read = stderr_read = 0 self.host.job.push_execution_context(self.results_dir) try: self.host.run(daemon_cmd, ignore_status=True, timeout=timeout) disconnect_warnings = [] while True: monitor_cmd = self.get_monitor_cmd(monitor_dir, stdout_read, stderr_read) try: result = self.host.run(monitor_cmd, ignore_status=True, timeout=timeout, stdout_tee=client_log, stderr_tee=stderr_redirector) except error.AutoservRunError, e: result = e.result_obj result.exit_status = None disconnect_warnings.append(e.description) stderr_redirector.log_warning( "Autotest client was disconnected: %s" % e.description, "NETWORK") except error.AutoservSSHTimeout: result = utils.CmdResult(monitor_cmd, "", "", None, 0) stderr_redirector.log_warning( "Attempt to connect to Autotest client timed out", "NETWORK") stdout_read += len(result.stdout) stderr_read += len(self._strip_stderr_prologue(result.stderr)) if result.exit_status is not None: # TODO (crosbug.com/38224)- sbasi: Remove extra logging. logging.debug('Result exit status is %d.', result.exit_status) return result elif not self.host.wait_up(client_disconnect_timeout): raise error.AutoservSSHTimeout( "client was disconnected, reconnect timed out")
def test_get_available_firmware_unibuild(self): """_get_available_firmware on unibuild board with multiple models.""" result = utils.CmdResult(stdout=UNIBUILD_VERSION_OUTPUT, exit_status=0) host = mock.Mock() host.run.return_value = result fw = cros_firmware._get_available_firmware(host, 'astronaut') self.assertEqual(fw, 'Google_Coral.10068.37.0') fw = cros_firmware._get_available_firmware(host, 'blue') self.assertEqual(fw, 'Google_Coral.10068.39.0') fw = cros_firmware._get_available_firmware(host, 'bruce') self.assertIsNone(fw)