OLD | NEW |
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import errno, logging, os, re, shutil, signal, subprocess, time | 5 import errno, logging, os, re, shutil, signal, subprocess, time |
6 import common | 6 import common |
7 import constants, cros_logging, cros_ui, cryptohome | 7 import constants, cros_logging, cros_ui, cryptohome |
8 from autotest_lib.client.bin import utils | 8 from autotest_lib.client.bin import utils |
9 from autotest_lib.client.common_lib import error | 9 from autotest_lib.client.common_lib import error |
10 | 10 |
11 | 11 |
12 _DEFAULT_TIMEOUT = 30 | 12 _DEFAULT_TIMEOUT = 30 |
13 _DEFAULT_OWNERSHIP_TIMEOUT = 300 # Ownership is an inherently random process. | |
14 | 13 |
15 # Log messages used to signal when we're in a logout situation. Used to detect | 14 # Log messages used to signal when we're in a logout situation. Used to detect |
16 # crashes by cros_ui_test.UITest. | 15 # crashes by cros_ui_test.UITest. |
17 LOGOUT_ATTEMPT_MSG = 'cros/login.py: Attempting logout...' | 16 LOGOUT_ATTEMPT_MSG = 'cros/login.py: Attempting logout...' |
18 LOGOUT_COMPLETE_MSG = 'cros/login.py: Logout complete.' | 17 LOGOUT_COMPLETE_MSG = 'cros/login.py: Logout complete.' |
19 | 18 |
20 | 19 |
21 class TimeoutError(error.TestError): | 20 class TimeoutError(error.TestError): |
22 """Error raised when we time out while waiting on a condition.""" | 21 """Error raised when we time out while waiting on a condition.""" |
23 pass | 22 pass |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 wait_for_condition( | 308 wait_for_condition( |
310 lambda: os.access( | 309 lambda: os.access( |
311 constants.CHROME_WINDOW_MAPPED_MAGIC_FILE, os.F_OK), | 310 constants.CHROME_WINDOW_MAPPED_MAGIC_FILE, os.F_OK), |
312 'Timed out waiting for initial Chrome window', | 311 'Timed out waiting for initial Chrome window', |
313 timeout=timeout, | 312 timeout=timeout, |
314 process='chrome', | 313 process='chrome', |
315 log_reader=log_reader, | 314 log_reader=log_reader, |
316 crash_msg='Chrome crashed before first tab rendered.') | 315 crash_msg='Chrome crashed before first tab rendered.') |
317 | 316 |
318 | 317 |
319 def wait_for_ownership(timeout=_DEFAULT_OWNERSHIP_TIMEOUT): | 318 def wait_for_ownership(timeout=constants.DEFAULT_OWNERSHIP_TIMEOUT): |
320 log_reader = cros_logging.LogReader() | 319 log_reader = cros_logging.LogReader() |
321 log_reader.set_start_by_current() | 320 log_reader.set_start_by_current() |
322 wait_for_condition( | 321 wait_for_condition( |
323 condition=lambda: os.access(constants.OWNER_KEY_FILE, os.F_OK), | 322 condition=lambda: os.access(constants.OWNER_KEY_FILE, os.F_OK), |
324 timeout_msg='Timed out waiting for ownership', | 323 timeout_msg='Timed out waiting for ownership', |
325 timeout=timeout, | 324 timeout=timeout, |
326 process=constants.BROWSER, | 325 process=constants.BROWSER, |
327 log_reader=log_reader, | 326 log_reader=log_reader, |
328 crash_msg='Chrome crashed before ownership could be taken.') | 327 crash_msg='Chrome crashed before ownership could be taken.') |
329 | 328 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 except (IOError, OSError) as err: | 389 except (IOError, OSError) as err: |
391 logging.error(err) | 390 logging.error(err) |
392 | 391 |
393 # Restart the UI. | 392 # Restart the UI. |
394 nuke_login_manager() | 393 nuke_login_manager() |
395 utils.poll_for_condition( | 394 utils.poll_for_condition( |
396 lambda: __session_manager_restarted(oldpid), | 395 lambda: __session_manager_restarted(oldpid), |
397 TimeoutError('Timed out waiting for logout'), | 396 TimeoutError('Timed out waiting for logout'), |
398 timeout) | 397 timeout) |
399 wait_for_login_prompt() | 398 wait_for_login_prompt() |
OLD | NEW |