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 | 5 import logging, os |
6 from autotest_lib.client.bin import site_log_reader | |
7 from autotest_lib.client.bin import utils | 6 from autotest_lib.client.bin import utils |
8 from autotest_lib.client.common_lib import error, utils | 7 from autotest_lib.client.common_lib import error |
9 from autotest_lib.client.cros import constants as chromeos_constants | 8 from autotest_lib.client.cros import constants as chromeos_constants |
10 from autotest_lib.client.cros import ui_test | 9 from autotest_lib.client.cros import cros_logging, cros_ui_test |
11 | 10 |
12 _SESSION_MANAGER_DEST='org.chromium.SessionManager' | 11 _SESSION_MANAGER_DEST='org.chromium.SessionManager' |
13 _SESSION_MANAGER_OBJECT='org.chromium.SessionManagerInterface' | 12 _SESSION_MANAGER_OBJECT='org.chromium.SessionManagerInterface' |
14 _SESSION_MANAGER_PATH='/org/chromium/SessionManager' | 13 _SESSION_MANAGER_PATH='/org/chromium/SessionManager' |
15 | 14 |
16 class login_DBusCalls(ui_test.UITest): | 15 class login_DBusCalls(cros_ui_test.UITest): |
17 version = 1 | 16 version = 1 |
18 | 17 |
| 18 |
| 19 def initialize(self, creds = '$default'): |
| 20 cros_ui_test.UITest.initialize(self, creds) |
| 21 |
| 22 |
19 def _call_session_manager_method(self, method, user='chronos'): | 23 def _call_session_manager_method(self, method, user='chronos'): |
20 """Call session manager dbus method as given user. | 24 """Call session manager dbus method as given user. |
21 | 25 |
22 We assume the method exists and succeeds. | 26 We assume the method exists and succeeds. |
23 | 27 |
24 Args: | 28 Args: |
25 method: name of method | 29 method: name of method |
26 user: system user to run as | 30 user: system user to run as |
27 Returns: | 31 Returns: |
28 None | 32 None |
29 """ | 33 """ |
30 utils.system('su %s -c \'dbus-send --system --type=method_call ' | 34 utils.system('su %s -c \'dbus-send --system --type=method_call ' |
31 '--print-reply --dest=%s %s %s.%s\'' % | 35 '--print-reply --dest=%s %s %s.%s\'' % |
32 (user, _SESSION_MANAGER_DEST, _SESSION_MANAGER_PATH, | 36 (user, _SESSION_MANAGER_DEST, _SESSION_MANAGER_PATH, |
33 _SESSION_MANAGER_OBJECT, method)) | 37 _SESSION_MANAGER_OBJECT, method)) |
34 | 38 |
35 | 39 |
36 def _test_restart_entd(self): | 40 def _test_restart_entd(self): |
37 """Test the RestartEntd method.""" | 41 """Test the RestartEntd method.""" |
38 message_log = site_log_reader.LogReader() | 42 message_log = cros_logging.LogReader() |
39 message_log.set_start_by_current() | 43 message_log.set_start_by_current() |
40 ui_log = site_log_reader.LogReader(chromeos_constants.UI_LOG) | 44 ui_log = cros_logging.LogReader(chromeos_constants.UI_LOG) |
41 ui_log.set_start_by_current() | 45 ui_log.set_start_by_current() |
42 # Make sure we can call RestartEntd from user chronos. | 46 # Make sure we can call RestartEntd from user chronos. |
43 self._call_session_manager_method('RestartEntd') | 47 self._call_session_manager_method('RestartEntd') |
44 try: | 48 try: |
45 utils.poll_for_condition( | 49 utils.poll_for_condition( |
46 lambda: ui_log.can_find('Restart was successful'), | 50 lambda: ui_log.can_find('Restart was successful'), |
47 timeout=30, | 51 timeout=30, |
48 exception=error.TestFail( | 52 exception=error.TestFail( |
49 'Found no ui log message about attempting to restart entd')) | 53 'Found no ui log message about attempting to restart entd')) |
50 finally: | 54 finally: |
51 logging.debug('UI log from RestartEntd: ' + | 55 logging.debug('UI log from RestartEntd: ' + |
52 ui_log.get_logs()) | 56 ui_log.get_logs()) |
53 | 57 |
54 grep_bait = 'entdwife.sh: Username: ' + self.username | 58 grep_bait = 'entdwife.sh: Username: ' + self.username |
55 try: | 59 try: |
56 utils.poll_for_condition( | 60 utils.poll_for_condition( |
57 lambda: message_log.can_find(grep_bait), | 61 lambda: message_log.can_find(grep_bait), |
58 timeout=30, | 62 timeout=30, |
59 exception=error.TestFail('Did not find %s in message log' % | 63 exception=error.TestFail('Did not find %s in message log' % |
60 grep_bait)) | 64 grep_bait)) |
61 finally: | 65 finally: |
62 logging.debug('Message log from RestartEntd: ' + | 66 logging.debug('Message log from RestartEntd: ' + |
63 message_log.get_logs()) | 67 message_log.get_logs()) |
64 | 68 |
65 | 69 |
66 def run_once(self): | 70 def run_once(self): |
67 self.login() | 71 self.login() |
68 self._test_restart_entd() | 72 self._test_restart_entd() |
OLD | NEW |