Beispiel #1
0
 def testTargetStatefulUpdateFileDoNotExist(self):
     """Tests that we raise error if the target stateful file doesn't exist."""
     with remote_access.ChromiumOSDeviceHandler(
             remote_access.TEST_IP) as device:
         updater = stateful_updater.StatefulUpdater(device)
         with self.assertRaises(stateful_updater.Error):
             updater.Update('/foo/path')
Beispiel #2
0
 def testInvalidUpdateType(self):
     """Tests we raise error on invalid given update type."""
     with remote_access.ChromiumOSDeviceHandler(
             remote_access.TEST_IP) as device:
         updater = stateful_updater.StatefulUpdater(device)
         with self.assertRaises(stateful_updater.Error):
             updater._MarkUpdateType('foo')
Beispiel #3
0
 def ResetStatefulPartition(self):
     """Clear any pending stateful update request."""
     logging.debug('Resetting stateful partition...')
     try:
         stateful_updater.StatefulUpdater(self.device).Reset()
     except stateful_updater.Error as e:
         raise StatefulUpdateError(e)
Beispiel #4
0
    def testUpdateFailed(self, _):
        """Tests Update function fails to untar the payload."""
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            updater = stateful_updater.StatefulUpdater(
                device, stateful_dir=self._stateful_dir)

            with self.assertRaises(stateful_updater.Error):
                updater.Update(self._payload)
Beispiel #5
0
    def testUpdateStandard(self):
        """Tests Update function with default arguments."""
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            updater = stateful_updater.StatefulUpdater(
                device, stateful_dir=self._stateful_dir)

            updater.Update(self._payload)
            self.assertEqual(
                osutils.ReadFile(
                    os.path.join(self._stateful_dir,
                                 updater._UPDATE_TYPE_FILE)), '')
Beispiel #6
0
    def testReset(self):
        """Tests Reset function."""
        with remote_access.ChromiumOSDeviceHandler(
                remote_access.TEST_IP) as device:
            updater = stateful_updater.StatefulUpdater(
                device, stateful_dir=self._stateful_dir)
            expected_files = (os.path.join(self.tempdir, 'target', f)
                              for f in (updater._VAR_DIR,
                                        updater._DEV_IMAGE_DIR,
                                        updater._UPDATE_TYPE_FILE))

            updater.Update(self._payload)

            for f in expected_files:
                self.assertExists(f)

            updater.Reset()

            # These files/directories should be deleted after the reset.
            for f in expected_files:
                self.assertNotExists(f)
Beispiel #7
0
    def UpdateStateful(self):
        """Update the stateful partition of the device."""
        try:
            stateful_update_payload = os.path.join(
                self.device.work_dir, auto_updater_transfer.STATEFUL_FILENAME)

            updater = stateful_updater.StatefulUpdater(self.device)
            updater.Update(
                stateful_update_payload,
                update_type=(
                    stateful_updater.StatefulUpdater.UPDATE_TYPE_CLOBBER
                    if self._clobber_stateful else None))

            # Delete the stateful update file on success so it doesn't occupy extra
            # disk space. On failure it will get cleaned up.
            self.device.DeletePath(stateful_update_payload)
        except stateful_updater.Error as e:
            error_msg = 'Stateful update failed with error: %s' % str(e)
            logging.exception(error_msg)
            self.ResetStatefulPartition()
            raise StatefulUpdateError(error_msg)