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