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 | 5 import logging, os, time |
6 from autotest_lib.client.bin import site_log_reader, site_ui_test, test | 6 from autotest_lib.client.bin import site_log_reader, site_ui_test, test |
7 from autotest_lib.client.common_lib import error, utils | 7 from autotest_lib.client.common_lib import error, utils |
8 | 8 |
9 _CRASH_PATH = '/sbin/crash_reporter' | 9 _CRASH_PATH = '/sbin/crash_reporter' |
10 _PENDING_SHUTDOWN_PATH = '/var/lib/crash_reporter/pending_clean_shutdown' | 10 _PENDING_SHUTDOWN_PATH = '/var/lib/crash_reporter/pending_clean_shutdown' |
11 _UNCLEAN_SHUTDOWN_MESSAGE = 'Last shutdown was not clean' | 11 _UNCLEAN_SHUTDOWN_MESSAGE = 'Last shutdown was not clean' |
12 | 12 |
13 class logging_KernelCrash(site_ui_test.UITest): | 13 class logging_UncleanShutdown(site_ui_test.UITest): |
14 version = 1 | 14 version = 1 |
15 auto_login = False | 15 auto_login = False |
16 | 16 |
17 | 17 |
18 def run_once(self): | 18 def run_once(self): |
19 if not os.path.exists(_PENDING_SHUTDOWN_PATH): | 19 if not os.path.exists(_PENDING_SHUTDOWN_PATH): |
20 raise error.TestFail('pending shutdown file, %s, not found' % | 20 raise error.TestFail('pending shutdown file, %s, not found' % |
21 _PENDING_SHUTDOWN_PATH) | 21 _PENDING_SHUTDOWN_PATH) |
22 | 22 |
23 log_reader = site_log_reader.LogReader() | 23 log_reader = site_log_reader.LogReader() |
24 log_reader.set_start_by_reboot(-1) | 24 log_reader.set_start_by_reboot(-1) |
25 | 25 |
26 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): | 26 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): |
27 raise error.TestFail( | 27 raise error.TestFail( |
28 'Unexpectedly detected kernel crash during boot') | 28 'Unexpectedly detected kernel crash during boot') |
29 | 29 |
30 » # Log in and out twice to make sure that doesn't cause | 30 # Log in and out twice to make sure that doesn't cause |
31 » # an unclean shutdown message. | 31 # an unclean shutdown message. |
32 » for i in range(2): | 32 for i in range(2): |
33 » self.login() | 33 self.login() |
34 » time.sleep(5) | 34 time.sleep(5) |
35 » self.logout() | 35 self.logout() |
36 » time.sleep(5) | 36 time.sleep(5) |
37 | 37 |
38 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): | 38 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): |
39 logging.info('Unexpected logs: ', log_reader.get_logs()) | 39 logging.info('Unexpected logs: ', log_reader.get_logs()) |
40 raise error.TestFail( | 40 raise error.TestFail( |
41 'Unexpectedly detected kernel crash during login/logout') | 41 'Unexpectedly detected kernel crash during login/logout') |
42 | 42 |
43 # Run the shutdown and verify it does not complain of unclean | 43 # Run the shutdown and verify it does not complain of unclean |
44 # shutdown. | 44 # shutdown. |
45 | 45 |
46 log_reader.set_start_by_current() | 46 log_reader.set_start_by_current() |
47 utils.system('%s --clean_shutdown' % _CRASH_PATH) | 47 utils.system('%s --clean_shutdown' % _CRASH_PATH) |
48 utils.system('%s --init' % _CRASH_PATH) | 48 utils.system('%s --init' % _CRASH_PATH) |
49 | 49 |
50 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): | 50 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): |
51 raise error.TestFail('Incorrectly signalled unclean shutdown') | 51 raise error.TestFail('Incorrectly signalled unclean shutdown') |
52 | 52 |
53 # Now simulate an unclean shutdown and test handling. | 53 # Now simulate an unclean shutdown and test handling. |
54 | 54 |
55 log_reader.set_start_by_current() | 55 log_reader.set_start_by_current() |
56 utils.system('%s --init' % _CRASH_PATH) | 56 utils.system('%s --init' % _CRASH_PATH) |
57 | 57 |
58 if not log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): | 58 if not log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): |
59 raise error.TestFail('Did not signal unclean shutdown when should') | 59 raise error.TestFail('Did not signal unclean shutdown when should') |
OLD | NEW |