Index: client/cros/login.py |
diff --git a/client/cros/login.py b/client/cros/login.py |
index fa5a8ddadafd8e462d755aac6ade7cfc724196ef..60ad0371ca5a8c5921aa80ddd262c30863433b1c 100644 |
--- a/client/cros/login.py |
+++ b/client/cros/login.py |
@@ -11,6 +11,11 @@ from autotest_lib.client.common_lib import error |
_DEFAULT_TIMEOUT = 30 |
+# Log messages used to signal when we're in a logout situation. Used to detect |
+# crashes by cros_ui_test.UITest. |
+LOGOUT_ATTEMPT_MSG = 'cros/login.py: Attempting logout...' |
+LOGOUT_COMPLETE_MSG = 'cros/login.py: Logout complete.' |
+ |
class TimeoutError(error.TestError): |
"""Error raised when we time out while waiting on a condition.""" |
@@ -181,24 +186,31 @@ def attempt_logout(timeout=_DEFAULT_TIMEOUT): |
if not logged_in(): |
raise UnexpectedCondition('Already logged out') |
- oldpid = __get_session_manager_pid() |
- |
- # Mark /var/log/messages now; we'll run through all subsequent log messages |
- # if we couldn't TERM and restart the session manager. |
- |
- log_reader = cros_logging.LogReader() |
- log_reader.set_start_by_current() |
- |
- # Gracefully exiting the session manager causes the user's session to end. |
- utils.system('pkill -TERM -o ^%s$' % constants.SESSION_MANAGER) |
+ # Log what we're about to do to /var/log/messages. Used to log crashes later |
+ # in cleanup by cros_ui_test.UITest. |
+ utils.system('logger "%s"' % LOGOUT_ATTEMPT_MSG) |
- wait_for_condition( |
- condition=lambda: __session_manager_restarted(oldpid), |
- timeout_msg='Timed out waiting for logout', |
- timeout=timeout, |
- process='session_manager', |
- log_reader=log_reader, |
- crash_msg='session_manager crashed while shutting down.') |
+ try: |
+ oldpid = __get_session_manager_pid() |
+ |
+ # Mark /var/log/messages now; we'll run through all subsequent log |
+ # messages if we couldn't TERM and restart the session manager. |
+ |
+ log_reader = cros_logging.LogReader() |
+ log_reader.set_start_by_current() |
+ |
+ # Gracefully exiting the session manager causes the user's session to end. |
+ utils.system('pkill -TERM -o ^%s$' % constants.SESSION_MANAGER) |
+ |
+ wait_for_condition( |
+ condition=lambda: __session_manager_restarted(oldpid), |
+ timeout_msg='Timed out waiting for logout', |
+ timeout=timeout, |
+ process='session_manager', |
+ log_reader=log_reader, |
+ crash_msg='session_manager crashed while shutting down.') |
+ finally: |
+ utils.system('logger "%s"' % LOGOUT_COMPLETE_MSG) |
def wait_for_browser(timeout=_DEFAULT_TIMEOUT): |