def testRootfsUpdateIdleError(self):
        """Test ChromiumOSUpdater.UpdateRootfs with raising exception.

    RootfsUpdateError is raised if the update engine goes to idle state
    after downloading.
    """
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                transfer_class=auto_updater_transfer.LocalTransfer)
            self.prepareRootfsUpdate()
            self.PatchObject(nebraska_wrapper.RemoteNebraskaWrapper, 'Start')
            self.PatchObject(nebraska_wrapper.RemoteNebraskaWrapper, 'GetURL')
            mock_run = self.PatchObject(remote_access.ChromiumOSDevice, 'run')
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             'GetUpdateStatus',
                             side_effect=(
                                 ('UPDATE_STATUS_DOWNLOADING', '0.5'),
                                 ('UPDATE_STATUS_DOWNLOADING', '0.9'),
                                 ('UPDATE_STATUS_FINALIZING', 0),
                                 ('UPDATE_STATUS_IDLE', 0),
                             ))
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             '_FixPayloadPropertiesFile')
            patch_join = mock.patch('os.path.join', return_value='')
            patch_sleep = mock.patch('time.sleep')
            with patch_sleep as mock_sleep, patch_join as _:
                self.assertRaises(auto_updater.RootfsUpdateError,
                                  CrOS_AU.RunUpdate)
                mock_sleep.assert_called()
                mock_run.assert_any_call(['cat', '/var/log/update_engine.log'])
Exemplo n.º 2
0
 def testCheckRestoreStateful(self):
   """Test whether _CheckRestoreStateful is called in update process."""
   precheck_mock = self.StartPatcher(ChromiumOSPreCheckMock())
   with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
     CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir)
     CrOS_AU.RunUpdate()
     self.assertTrue(precheck_mock.patched['_CheckRestoreStateful'].called)
    def testTransferForRootfs(self):
        """Test transfer functions for rootfs update.

    When rootfs update is enabled, update-utils and rootfs update payload are
    transferred. Stateful update payload is not.
    """
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                do_stateful_update=False,
                transfer_class=auto_updater_transfer.LocalTransfer)
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             '_FixPayloadPropertiesFile')
            CrOS_AU.RunUpdate()
            self.assertTrue(
                self._transfer_mock.patched['CheckPayloads'].called)
            self.assertTrue(self._transfer_mock.
                            patched['TransferUpdateUtilsPackage'].called)
            self.assertTrue(
                self._transfer_mock.patched['TransferRootfsUpdate'].called)
            self.assertFalse(
                self._transfer_mock.patched['TransferStatefulUpdate'].called)
    def testRestoreStatefulError(self):
        """Test ChromiumOSUpdater.RestoreStateful with raising exception.

    Nebraska still cannot run after restoring stateful partition will lead
    to ChromiumOSUpdateError.
    """
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(device, None,
                                                     self._payload_dir)
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             'CheckRestoreStateful',
                             return_value=True)
            self.PatchObject(auto_updater.ChromiumOSUpdater, 'RunUpdateRootfs')
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             'PreSetupStatefulUpdate')
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             'TransferStatefulUpdate')
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             'ResetStatefulPartition')
            self.PatchObject(auto_updater.ChromiumOSUpdater, 'UpdateStateful')
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             'PostCheckStatefulUpdate')
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             '_IsUpdateUtilsPackageInstalled')
            self.PatchObject(
                auto_updater.ChromiumOSUpdater,
                '_CheckNebraskaCanRun',
                side_effect=nebraska_wrapper.NebraskaStartupError())
            self.assertRaises(auto_updater.ChromiumOSUpdateError,
                              CrOS_AU.RunUpdate)
    def test_FixPayloadPropertiesFile(self):
        """Tests _FixPayloadPropertiesFile() correctly fixes the properties file."""
        payload_filename = (
            'payloads/chromeos_9334.58.2_reef_stable-'
            'channel_full_test.bin-e6a3290274a5b2ae0b9f491712ae1d8')
        payload_path = os.path.join(self._payload_dir, payload_filename)
        payload_properties_path = payload_path + '.json'
        osutils.WriteFile(payload_path, 'dummy-payload', makedirs=True)
        # Empty properties file.
        osutils.WriteFile(payload_properties_path, json.dumps({}))

        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                payload_filename=payload_filename)
            CrOS_AU._FixPayloadPropertiesFile()  # pylint: disable=protected-access

        # The payload properties file should be updated with new fields.
        props = json.loads(osutils.ReadFile(payload_properties_path))
        expected_props = {
            'appid': '',
            'is_delta': False,
            'size': os.path.getsize(payload_path),
            'target_version': '9334.58.2',
        }
        self.assertEqual(props, expected_props)
    def testPrepareLabPayloadPropsFile(self):
        """Tests that we correctly call ResolveAPPIDMismatchIfAny."""
        self._payload_dir = self.tempdir

        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                staging_server='http://0.0.0.0:8082/')
            lab_xfer = auto_updater_transfer.LabTransfer
            cros_updater = auto_updater.ChromiumOSUpdater

            self.PatchObject(lab_xfer,
                             'GetPayloadPropsFile',
                             return_value='/local/test_update.gz.json')
            self.PatchObject(cros_updater, 'ResolveAPPIDMismatchIfAny')

            CrOS_AU.PreparePayloadPropsFile()

            self.assertTrue(lab_xfer.GetPayloadPropsFile.called)
            self.assertListEqual(
                cros_updater.ResolveAPPIDMismatchIfAny.call_args_list,
                [mock.call('/local/test_update.gz.json')])
    def testRootfsUpdateCmdError(self):
        """Test ChromiumOSUpdater.UpdateRootfs with raising exception.

    RootfsUpdateError is raised if device fails to run rootfs update command
    'update_engine_client ...'.
    """
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                transfer_class=auto_updater_transfer.LocalTransfer)
            self.prepareRootfsUpdate()
            self.PatchObject(nebraska_wrapper.RemoteNebraskaWrapper, 'Start')
            self.PatchObject(nebraska_wrapper.RemoteNebraskaWrapper, 'GetURL')
            self.PatchObject(
                remote_access.ChromiumOSDevice,
                'run',
                side_effect=cros_build_lib.RunCommandError('fail'))
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             'RevertBootPartition')
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             '_FixPayloadPropertiesFile')
            with mock.patch('os.path.join', return_value=''):
                self.assertRaises(auto_updater.RootfsUpdateError,
                                  CrOS_AU.RunUpdate)
    def testStatefulUpdateCmdError(self):
        """Test ChromiumOSUpdater.UpdateStateful with raising exception.

    StatefulUpdateError is raised if device fails to update stateful partition.
    """
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                do_rootfs_update=False,
                transfer_class=auto_updater_transfer.LocalTransfer)
            self.PatchObject(
                remote_access.ChromiumOSDevice,
                'run',
                side_effect=cros_build_lib.RunCommandError('fail'))
            self.PatchObject(stateful_updater.StatefulUpdater,
                             'Update',
                             side_effect=stateful_updater.Error())
            self.PatchObject(stateful_updater.StatefulUpdater,
                             'Reset',
                             side_effect=stateful_updater.Error())
            self.assertRaises(auto_updater.StatefulUpdateError,
                              CrOS_AU.RunUpdate)
    def testRootfsUpdateTrackError(self):
        """Test ChromiumOSUpdater.UpdateRootfs with raising exception.

    RootfsUpdateError is raised if it fails to track device's status by
    GetUpdateStatus.
    """
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                transfer_class=auto_updater_transfer.LocalTransfer)
            self.prepareRootfsUpdate()
            self.PatchObject(nebraska_wrapper.RemoteNebraskaWrapper, 'Start')
            self.PatchObject(nebraska_wrapper.RemoteNebraskaWrapper, 'GetURL')
            self.PatchObject(remote_access.ChromiumOSDevice, 'run')
            self.PatchObject(
                auto_updater.ChromiumOSUpdater,
                'GetUpdateStatus',
                side_effect=ValueError('Cannot get update status'))
            self.PatchObject(auto_updater.ChromiumOSUpdater,
                             '_FixPayloadPropertiesFile')
            with mock.patch('os.path.join', return_value=''):
                self.assertRaises(auto_updater.RootfsUpdateError,
                                  CrOS_AU.RunUpdate)
Exemplo n.º 10
0
 def testRebootAndVerifyWithoutReboot(self):
   """Test RebootAndVerify doesn't run if reboot is unenabled."""
   with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
     CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir,
                                              reboot=False)
     CrOS_AU.RunUpdate()
     self.assertFalse(self.base_updater_mock.patched['RebootAndVerify'].called)
    def test_FixPayloadLabTransfer(self):
        """Tests if correct LabTransfer methods are called."""
        payload_dir = 'nyan_kitty-release/R76-12345.17.0'
        payload_path = os.path.join(self.tempdir, 'test_update.gz')
        payload_properties_path = payload_path + '.json'
        osutils.WriteFile(payload_path, 'dummy-payload', makedirs=True)
        # Empty properties file.
        osutils.WriteFile(payload_properties_path, '{}')

        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                payload_dir=payload_dir,
                transfer_class=auto_updater_transfer.LabTransfer,
                staging_server='http://0.0.0.0:8082')

            self.PatchObject(auto_updater_transfer.LabTransfer,
                             'GetPayloadPropsFile',
                             return_value=payload_properties_path)
            self.PatchObject(auto_updater_transfer.LabTransfer,
                             'GetPayloadProps',
                             return_value={
                                 'size': '123',
                                 'image_version': '99999.9.9'
                             })

            CrOS_AU._FixPayloadPropertiesFile()  # pylint: disable=protected-access
            self.assertTrue(
                auto_updater_transfer.LabTransfer.GetPayloadPropsFile.called)
            self.assertTrue(
                auto_updater_transfer.LabTransfer.GetPayloadProps.called)
    def test_FixPayloadLocalTransfer(self):
        """Tests if correct LocalTransfer methods are called."""
        payload_filename = (
            'payloads/chromeos_9334.58.2_reef_stable-'
            'channel_full_test.bin-e6a3290274a5b2ae0b9f491712ae1d8')
        payload_path = os.path.join(self.tempdir, payload_filename)
        payload_properties_path = payload_path + '.json'
        osutils.WriteFile(payload_path, 'dummy-payload', makedirs=True)
        # Empty properties file.
        osutils.WriteFile(payload_properties_path, '{}')

        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                payload_dir=self._payload_dir,
                payload_filename=payload_filename,
                transfer_class=auto_updater_transfer.LocalTransfer)

            self.PatchObject(auto_updater_transfer.LocalTransfer,
                             'GetPayloadPropsFile',
                             return_value=payload_properties_path)
            self.PatchObject(auto_updater_transfer.LocalTransfer,
                             'GetPayloadProps',
                             return_value={
                                 'size': '123',
                                 'image_version': '99999.9.9'
                             })

            CrOS_AU._FixPayloadPropertiesFile()  # pylint: disable=protected-access
            self.assertTrue(
                auto_updater_transfer.LocalTransfer.GetPayloadPropsFile.called)
            self.assertTrue(
                auto_updater_transfer.LocalTransfer.GetPayloadProps.called)
Exemplo n.º 13
0
 def testNoPomptWithYes(self):
   """Test prompts won't be called if yes is set as True."""
   with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
     CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir,
                                              yes=True)
     self.PatchObject(cros_build_lib, 'BooleanPrompt')
     CrOS_AU.RunUpdate()
     self.assertFalse(cros_build_lib.BooleanPrompt.called)
Exemplo n.º 14
0
 def testRestoreStateful(self):
   """Test RestoreStateful is called when it's required."""
   with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
     CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir)
     self.PatchObject(auto_updater.ChromiumOSUpdater, '_CheckRestoreStateful',
                      return_value=True)
     CrOS_AU.RunUpdate()
     self.assertTrue(self.base_updater_mock.patched['RestoreStateful'].called)
Exemplo n.º 15
0
 def testCheckRestoreStatefulError(self):
   """Test _CheckRestoreStateful fails with raising ChromiumOSUpdateError."""
   with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
     CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir)
     self.PatchObject(cros_build_lib, 'BooleanPrompt', return_value=False)
     self.PatchObject(auto_updater.ChromiumOSUpdater, '_CanRunDevserver',
                      return_value=False)
     self.assertRaises(auto_updater.ChromiumOSUpdateError, CrOS_AU.RunUpdate)
 def testRebootAndVerifyWithRootfsAndReboot(self):
     """Test RebootAndVerify if rootfs update and reboot are enabled."""
     with remote_access.ChromiumOSDeviceHandler(
             remote_access.TEST_IP) as device:
         CrOS_AU = auto_updater.ChromiumOSUpdater(device, None,
                                                  self._payload_dir)
         CrOS_AU.RunUpdate()
         self.assertTrue(
             self._base_updater_mock.patched['RebootAndVerify'].called)
Exemplo n.º 17
0
  def testSetupRootfsUpdateError(self):
    """Test ChromiumOSUpdater.SetupRootfsUpdate with raising exception.

    RootfsUpdateError is raised if it cannot get status from GetUpdateStatus.
    """
    with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
      CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir)
      self.PatchObject(auto_updater.ChromiumOSUpdater, 'GetUpdateStatus',
                       return_value=('cannot_update', ))
      self.assertRaises(auto_updater.RootfsUpdateError, CrOS_AU.RunUpdate)
Exemplo n.º 18
0
 def testVerifyErrorWithRootDevEqualsNone(self):
   """Test RebootAndVerify fails with raising AutoUpdateVerifyError."""
   with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
     CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir,
                                              do_stateful_update=False)
     self.PatchObject(auto_updater.ChromiumOSUpdater, 'SetupRootfsUpdate')
     self.PatchObject(auto_updater.ChromiumOSUpdater, 'UpdateRootfs')
     self.PatchObject(auto_updater.ChromiumOSUpdater, 'GetRootDev',
                      return_value=None)
     self.assertRaises(auto_updater.AutoUpdateVerifyError, CrOS_AU.RunUpdate)
Exemplo n.º 19
0
    def Run(self):
        """Perform remote device update.

    The update process includes:
    1. initialize a device instance for the given remote device.
    2. achieve payload_dir which contains the required payloads for updating.
    3. initialize an auto-updater instance to do RunUpdate().
    4. After auto-update, all temp files and dir will be cleaned up.
    """
        try:
            with remote_access.ChromiumOSDeviceHandler(
                    self.ssh_hostname,
                    port=self.ssh_port,
                    base_dir=self.DEVICE_BASE_DIR,
                    private_key=self.ssh_private_key,
                    ping=self.ping) as device:

                try:
                    # Get payload directory
                    payload_dir = self.GetPayloadDir(device)

                    # Do auto-update
                    chromeos_AU = auto_updater.ChromiumOSUpdater(
                        device=device,
                        build_name=None,
                        payload_dir=payload_dir,
                        tempdir=self.tempdir,
                        do_rootfs_update=self.do_rootfs_update,
                        do_stateful_update=self.do_stateful_update,
                        reboot=self.reboot,
                        disable_verification=self.disable_verification,
                        clobber_stateful=self.clobber_stateful,
                        yes=self.yes,
                        send_payload_in_parallel=self.send_payload_in_parallel,
                        experimental_au=self.experimental_au)
                    chromeos_AU.CheckPayloads()
                    chromeos_AU.PreparePayloadPropsFile()
                    chromeos_AU.RunUpdate()

                except Exception:
                    logging.error('Device update failed.')
                    lsb_entries = sorted(device.lsb_release.items())
                    logging.info(
                        'Following are the LSB version details of the device:\n%s',
                        '\n'.join('%s=%s' % (k, v) for k, v in lsb_entries))
                    raise

                logging.notice('Update performed successfully.')

        except remote_access.RemoteAccessException:
            logging.error('Remote device failed to initialize.')
            raise

        finally:
            self.Cleanup()
Exemplo n.º 20
0
  def testRootfsUpdateDevServerError(self):
    """Test ChromiumOSUpdater.UpdateRootfs with raising exception.

    RootfsUpdateError is raised if devserver cannot start.
    """
    with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
      CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir)
      self.prepareRootfsUpdate()
      self.PatchObject(dev_server_wrapper.RemoteDevServerWrapper, 'Start',
                       side_effect=dev_server_wrapper.DevServerException())
      with mock.patch('os.path.join', return_value=''):
        self.assertRaises(auto_updater.RootfsUpdateError, CrOS_AU.RunUpdate)
Exemplo n.º 21
0
 def setUp(self):
     """Setup an instance of CrOSUpdateTrigger."""
     self._cros_update_trigger = cros_update.CrOSUpdateTrigger(
         'foo-host-name',
         'foo-build-name',
         'foo-static-dir',
         original_build='foo-original-build',
         static_url='foo-static',
         devserver_url='foo-devserver-url')
     self._cros_updater = auto_updater.ChromiumOSUpdater(
         mock.MagicMock(work_dir='foo-dir'), 'foo-build-name',
         'foo-payload-dir')
Exemplo n.º 22
0
  def testStatefulUpdateCmdError(self):
    """Test ChromiumOSUpdater.UpdateStateful with raising exception.

    StatefulUpdateError is raised if device fails to run stateful update
    command 'stateful_update ...'.
    """
    with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
      CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir,
                                               do_rootfs_update=False)
      self.PatchObject(remote_access.ChromiumOSDevice, 'RunCommand',
                       side_effect=cros_build_lib.RunCommandError('fail', ''))
      with mock.patch('os.path.join', return_value=''):
        self.assertRaises(auto_updater.StatefulUpdateError, CrOS_AU.RunUpdate)
Exemplo n.º 23
0
  def testRunStateful(self):
    """Test the update functions are called correctly.

    Only UpdateStateful is called for stateful update.
    """
    with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
      CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir,
                                               do_rootfs_update=False)
      CrOS_AU.RunUpdate()
      self.assertFalse(
          self.base_updater_mock.patched['SetupRootfsUpdate'].called)
      self.assertFalse(self.base_updater_mock.patched['UpdateRootfs'].called)
      self.assertTrue(self.base_updater_mock.patched['UpdateStateful'].called)
Exemplo n.º 24
0
  def testRestoreStatefulError(self):
    """Test ChromiumOSUpdater.RestoreStateful with raising exception.

    Devserver still cannot run after restoring stateful partition will lead
    to ChromiumOSUpdateError.
    """
    with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
      CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir)
      self.PatchObject(auto_updater.ChromiumOSUpdater, 'RunUpdateStateful')
      self.PatchObject(auto_updater.ChromiumOSUpdater, '_CheckRestoreStateful',
                       return_value=True)
      self.PatchObject(auto_updater.ChromiumOSUpdater, '_CanRunDevserver',
                       return_value=False)
      self.assertRaises(auto_updater.ChromiumOSUpdateError, CrOS_AU.RunUpdate)
 def testRebootAndVerifyWithRootfsAndReboot(self):
     """Test RebootAndVerify if rootfs update and reboot are enabled."""
     with remote_access.ChromiumOSDeviceHandler(
             remote_access.TEST_IP) as device:
         CrOS_AU = auto_updater.ChromiumOSUpdater(
             device,
             None,
             self._payload_dir,
             transfer_class=auto_updater_transfer.LocalTransfer)
         self.PatchObject(auto_updater.ChromiumOSUpdater,
                          '_FixPayloadPropertiesFile')
         CrOS_AU.RunUpdate()
         self.assertTrue(
             self._base_updater_mock.patched['RebootAndVerify'].called)
 def testNoPomptWithYes(self):
     """Test prompts won't be called if yes is set as True."""
     with remote_access.ChromiumOSDeviceHandler(
             remote_access.TEST_IP) as device:
         CrOS_AU = auto_updater.ChromiumOSUpdater(
             device,
             None,
             self._payload_dir,
             yes=True,
             transfer_class=auto_updater_transfer.LocalTransfer)
         self.PatchObject(cros_build_lib, 'BooleanPrompt')
         self.PatchObject(auto_updater.ChromiumOSUpdater,
                          '_FixPayloadPropertiesFile')
         CrOS_AU.RunUpdate()
         self.assertFalse(cros_build_lib.BooleanPrompt.called)
Exemplo n.º 27
0
  def testRootfsUpdateCmdError(self):
    """Test ChromiumOSUpdater.UpdateRootfs with raising exception.

    RootfsUpdateError is raised if device fails to run rootfs update command
    'update_engine_client ...'.
    """
    with remote_access.ChromiumOSDeviceHandler('1.1.1.1') as device:
      CrOS_AU = auto_updater.ChromiumOSUpdater(device, self.payload_dir)
      self.prepareRootfsUpdate()
      self.PatchObject(dev_server_wrapper.DevServerWrapper, 'Start')
      self.PatchObject(dev_server_wrapper.DevServerWrapper, 'GetDevServerURL')
      self.PatchObject(remote_access.ChromiumOSDevice, 'RunCommand',
                       side_effect=cros_build_lib.RunCommandError('fail', ''))
      with mock.patch('os.path.join', return_value=''):
        self.assertRaises(auto_updater.RootfsUpdateError, CrOS_AU.RunUpdate)
    def testMatchedAppId(self):
        """Tests if App ID is unchanged when there's a match."""
        self._payload_dir = self.tempdir

        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            CrOS_AU = auto_updater.ChromiumOSUpdater(
                device,
                None,
                self._payload_dir,
                transfer_class=auto_updater_transfer.LocalTransfer)
            type(
                CrOS_AU.device).app_id = mock.PropertyMock(return_value='same')
            resolved_appid = CrOS_AU.ResolveAPPIDMismatchIfAny('same')
            self.assertEqual(resolved_appid, 'same')
 def testRetryCommand(self):
     """Ensures that _RetryCommand can take both string and list args for cmd."""
     with remote_access.ChromiumOSDeviceHandler(
             remote_access.TEST_IP) as device:
         CrOS_AU = auto_updater.ChromiumOSUpdater(
             device,
             None,
             None,
             reboot=False,
             transfer_class=auto_updater_transfer.LocalTransfer)
         # pylint: disable=protected-access
         CrOS_AU._RetryCommand(['some', 'list', 'command'])
         self.assertCommandContains(['some', 'list', 'command'])
         CrOS_AU._RetryCommand('some string command')
         self.assertCommandContains('some string command')
 def testCheckRestoreStatefulError(self):
     """Test CheckRestoreStateful fails with raising ChromiumOSUpdateError."""
     with remote_access.ChromiumOSDeviceHandler(
             remote_access.TEST_IP) as device:
         CrOS_AU = auto_updater.ChromiumOSUpdater(device, None,
                                                  self._payload_dir)
         self.PatchObject(cros_build_lib,
                          'BooleanPrompt',
                          return_value=False)
         self.PatchObject(
             auto_updater.ChromiumOSUpdater,
             '_CheckNebraskaCanRun',
             side_effect=nebraska_wrapper.NebraskaStartupError())
         self.assertRaises(auto_updater.ChromiumOSUpdateError,
                           CrOS_AU.RunUpdate)