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, signal | 5 import logging, os, time, utils, signal |
6 from autotest_lib.client.common_lib import error, utils | 6 from autotest_lib.client.common_lib import error, utils |
7 from autotest_lib.client.cros import ui_test | 7 from autotest_lib.client.cros import cros_ui_test |
8 | 8 |
9 class TestProcess: | 9 class TestProcess: |
10 | 10 |
11 def __init__(self, command, pattern): | 11 def __init__(self, command, pattern): |
12 self.command = command | 12 self.command = command |
13 self.pattern = pattern | 13 self.pattern = pattern |
14 self.pid_su = '' | 14 self.pid_su = '' |
15 self.pid_bash = '' | 15 self.pid_bash = '' |
16 | 16 |
17 def __wait_for_subprocess(self): | 17 def __wait_for_subprocess(self): |
(...skipping 19 matching lines...) Expand all Loading... |
37 sub-process to start, and fails if this does not happen.""" | 37 sub-process to start, and fails if this does not happen.""" |
38 | 38 |
39 # Start process as user chronos. | 39 # Start process as user chronos. |
40 self.pid_su = utils.BgJob('su chronos -c "%s"' % self.command) | 40 self.pid_su = utils.BgJob('su chronos -c "%s"' % self.command) |
41 # Get pid of bash sub-process. Even though utils.BgJob() has exited, | 41 # Get pid of bash sub-process. Even though utils.BgJob() has exited, |
42 # the su-process may not have created its sub-process yet. | 42 # the su-process may not have created its sub-process yet. |
43 self.__wait_for_subprocess() | 43 self.__wait_for_subprocess() |
44 return self.pid_bash != '' | 44 return self.pid_bash != '' |
45 | 45 |
46 | 46 |
47 class login_LogoutProcessCleanup(ui_test.UITest): | 47 class login_LogoutProcessCleanup(cros_ui_test.UITest): |
48 version = 1 | 48 version = 1 |
49 | 49 |
50 def __get_session_manager_pid(self): | 50 def __get_session_manager_pid(self): |
51 """Get the PID of the session manager.""" | 51 """Get the PID of the session manager.""" |
52 | 52 |
53 return utils.system_output('pgrep "^session_manager$"', | 53 return utils.system_output('pgrep "^session_manager$"', |
54 ignore_status = True) | 54 ignore_status = True) |
55 | 55 |
56 | 56 |
57 def __get_chronos_pids(self): | 57 def __get_chronos_pids(self): |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 logging.info('Found pre-logout chronos process pid=%s (%s) ' | 170 logging.info('Found pre-logout chronos process pid=%s (%s) ' |
171 'still alive.' % (p, proc_args)) | 171 'still alive.' % (p, proc_args)) |
172 # If p is something we started, kill it. | 172 # If p is something we started, kill it. |
173 for test in test_processes: | 173 for test in test_processes: |
174 if (p == test.pid_su or p == test.pid_bash): | 174 if (p == test.pid_su or p == test.pid_bash): |
175 utils.signal_pid(p, signal.SIGKILL) | 175 utils.signal_pid(p, signal.SIGKILL) |
176 | 176 |
177 if old_pid_count > 0: | 177 if old_pid_count > 0: |
178 raise error.TestFail('Found %s chronos processes that survived ' | 178 raise error.TestFail('Found %s chronos processes that survived ' |
179 'logout.' % old_pid_count) | 179 'logout.' % old_pid_count) |
OLD | NEW |