| 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 logging, os, time, utils | 5 import logging, os, time, utils |
| 6 from autotest_lib.client.bin import site_login, test | 6 from autotest_lib.client.bin import 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_LogoutProcessCleanup(test.test): | 9 class login_LogoutProcessCleanup(test.test): |
| 10 version = 1 | 10 version = 1 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 def setup(self): | 72 def setup(self): |
| 73 site_login.setup_autox(self) | 73 site_login.setup_autox(self) |
| 74 | 74 |
| 75 | 75 |
| 76 def run_once(self, script='autox_script.json', is_control=False, | 76 def run_once(self, script='autox_script.json', is_control=False, |
| 77 timeout=10): | 77 timeout=10): |
| 78 logged_in = site_login.logged_in() | 78 logged_in = site_login.logged_in() |
| 79 | 79 |
| 80 # Require that we start the test logged in | 80 # Require that we start the test logged in |
| 81 if not logged_in: | 81 if not logged_in: |
| 82 if not site_login.attempt_login(self, script): | 82 site_login.attempt_login(self, script) |
| 83 raise error.TestError('Could not login') | |
| 84 | 83 |
| 85 # Start a process as chronos. This should get killed when logging out. | 84 # Start a process as chronos. This should get killed when logging out. |
| 86 bg_job = utils.BgJob('su chronos -c "sleep 3600"') | 85 bg_job = utils.BgJob('su chronos -c "sleep 3600"') |
| 87 | 86 |
| 88 session_manager = self.get_session_manager_pid() | 87 session_manager = self.get_session_manager_pid() |
| 89 if session_manager == "": | 88 if session_manager == "": |
| 90 raise error.TestError('Could not find session manager pid') | 89 raise error.TestError('Could not find session manager pid') |
| 91 | 90 |
| 92 if not self.has_chronos_processes(session_manager): | 91 if not self.has_chronos_processes(session_manager): |
| 93 raise error.TestFail('Expected to find processes owned by chronos ' | 92 raise error.TestFail('Expected to find processes owned by chronos ' |
| 94 'that were not started by the session manager while logged in.') | 93 'that were not started by the session manager while logged in.') |
| 95 | 94 |
| 96 if not site_login.attempt_logout(): | 95 site_login.attempt_logout() |
| 97 raise error.TestError('Could not logout') | |
| 98 | 96 |
| 99 logging.info('Logged out, searching for processes that should be dead') | 97 logging.info('Logged out, searching for processes that should be dead') |
| 100 | 98 |
| 101 # Wait until we have a new session manager. At that point, all | 99 # Wait until we have a new session manager. At that point, all |
| 102 # old processes should be dead. | 100 # old processes should be dead. |
| 103 old_session_manager = session_manager | 101 old_session_manager = session_manager |
| 104 while session_manager == "" or session_manager == old_session_manager: | 102 while session_manager == "" or session_manager == old_session_manager: |
| 105 time.sleep(0.1) | 103 time.sleep(0.1) |
| 106 session_manager = self.get_session_manager_pid() | 104 session_manager = self.get_session_manager_pid() |
| 107 | 105 |
| 108 if self.has_chronos_processes(session_manager): | 106 if self.has_chronos_processes(session_manager): |
| 109 # Make sure the test job we started is dead. | 107 # Make sure the test job we started is dead. |
| 110 if bg_job.sp.returncode == None: | 108 if bg_job.sp.returncode == None: |
| 111 bg_job.sp.kill() | 109 bg_job.sp.kill() |
| 112 raise error.TestFail('Expected NOT to find processes owned by ' | 110 raise error.TestFail('Expected NOT to find processes owned by ' |
| 113 'chronos that were not started by the session manager ' | 111 'chronos that were not started by the session manager ' |
| 114 'while logged out.') | 112 'while logged out.') |
| 115 | 113 |
| 116 # Reset the logged in state to how we started | 114 # Reset the logged in state to how we started |
| 117 if logged_in: | 115 if logged_in: |
| 118 if not site_login.attempt_login(self, script): | 116 site_login.attempt_login(self, script) |
| 119 raise error.TestError('Could not login') | |
| OLD | NEW |