| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 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 os, time | 5 import os, time |
| 6 from autotest_lib.client.bin import site_cryptohome, site_login, test | 6 from autotest_lib.client.bin import site_cryptohome, site_login, test |
| 7 from autotest_lib.client.common_lib import error | 7 from autotest_lib.client.common_lib import error |
| 8 | 8 |
| 9 class login_CryptohomeUnmounted(test.test): | 9 class login_CryptohomeUnmounted(test.test): |
| 10 version = 1 | 10 version = 1 |
| 11 | 11 |
| 12 def setup(self): | 12 def setup(self): |
| 13 site_login.setup_autox(self) | 13 site_login.setup_autox(self) |
| 14 | 14 |
| 15 def run_once(self, script = 'autox_script.json', is_control = False): | 15 def run_once(self, script = 'autox_script.json', is_control = False): |
| 16 logged_in = site_login.logged_in() | 16 logged_in = site_login.logged_in() |
| 17 | 17 |
| 18 # Require that the cryptohome is mounted before testing that | 18 # Require that the cryptohome is mounted before testing that |
| 19 # logging out will unmount it. This requires logging in. | 19 # logging out will unmount it. This requires logging in. |
| 20 if not logged_in: | 20 if not logged_in: |
| 21 if not site_login.attempt_login(self, script): | 21 site_login.attempt_login(self, script) |
| 22 raise error.TestError('Could not login') | |
| 23 | 22 |
| 24 if not site_cryptohome.is_mounted(allow_fail = is_control): | 23 if not site_cryptohome.is_mounted(allow_fail = is_control): |
| 25 raise error.TestFail('Expected cryptohome to be mounted') | 24 raise error.TestFail('Expected cryptohome to be mounted') |
| 26 | 25 |
| 27 if not site_login.attempt_logout(): | 26 site_login.attempt_logout() |
| 28 raise error.TestError('Could not logout') | |
| 29 | 27 |
| 30 # allow the command to fail, so we can handle the error here | 28 # allow the command to fail, so we can handle the error here |
| 31 if site_cryptohome.is_mounted(allow_fail = True): | 29 if site_cryptohome.is_mounted(allow_fail = True): |
| 32 raise error.TestFail('Expected cryptohome NOT to be mounted') | 30 raise error.TestFail('Expected cryptohome NOT to be mounted') |
| 33 | 31 |
| 34 # If we started logged in, reset the state. | 32 # If we started logged in, reset the state. |
| 35 if logged_in: | 33 if logged_in: |
| 36 if not site_login.attempt_login(self, script): | 34 site_login.attempt_login(self, script) |
| 37 raise error.TestError('Could not login') | |
| OLD | NEW |