Beispiel #1
0
    def run_once(self):
        # Ensure the UI is running.
        logging.debug('Restarting UI to ensure that it\'s running.')
        cros_ui.stop(allow_fail=True)
        cros_ui.start(wait_for_login_prompt=False)

        # Nuke the UI continuously until it stops respawning.
        respawned_at_least_once = False
        attempt = 0
        timeout_seconds = 10
        start_time = time.time()
        try:
            for attempt in range(self.UNREASONABLY_HIGH_RESPAWN_COUNT):
                self._nuke_ui_with_prejudice_and_wait(timeout_seconds)
                respawned_at_least_once = True
        except utils.TimeoutError as te:
            start_time += timeout_seconds
            pass
        logging.info("Respawned UI %d times in %d seconds", attempt,
                     time.time() - start_time)

        if cros_ui.is_up():
            raise error.TestFail(
                'Respawning should have stopped before %d attempts' %
                self.UNREASONABLY_HIGH_RESPAWN_COUNT)
        if not respawned_at_least_once:
            raise error.TestFail('Should have respawned at least once')
Beispiel #2
0
 def _nuke_browser_with_prejudice_and_check_for_ui_stop(self):
     """Nuke the browser with prejudice, check to see if the UI is down."""
     try:
         utils.nuke_process_by_name(constants.BROWSER, with_prejudice=True)
     except error.AutoservPidAlreadyDeadError:
         pass
     return not cros_ui.is_up()
Beispiel #3
0
def restart_ui_to_clear_ownership_files():
    """Remove on-disk state related to device ownership.

    The UI must be stopped while we do this, or the session_manager will
    write the policy and key files out again.
    """
    cros_ui.stop(allow_fail=not cros_ui.is_up())
    clear_ownership_files_no_restart()
    cros_ui.start()
Beispiel #4
0
def clear_ownership_files_no_restart():
    """Remove on-disk state related to device ownership.

    The UI must be stopped while we do this, or the session_manager will
    write the policy and key files out again.
    """
    if cros_ui.is_up():
        raise error.TestError("Tried to clear ownership with UI running.")
    __unlink(constants.OWNER_KEY_FILE)
    __unlink(constants.SIGNED_POLICY_FILE)
    __unlink(os.path.join(constants.USER_DATA_DIR, 'Local State'))