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, test | |
7 from autotest_lib.client.common_lib import error, utils | 6 from autotest_lib.client.common_lib import error, utils |
8 from autotest_lib.client.cros import ui_test | 7 from autotest_lib.client.cros import log_reader, ui_test |
9 | 8 |
10 _CRASH_PATH = '/sbin/crash_reporter' | 9 _CRASH_PATH = '/sbin/crash_reporter' |
11 _PENDING_SHUTDOWN_PATH = '/var/lib/crash_reporter/pending_clean_shutdown' | 10 _PENDING_SHUTDOWN_PATH = '/var/lib/crash_reporter/pending_clean_shutdown' |
12 _UNCLEAN_SHUTDOWN_DETECTED_PATH = '/tmp/unclean-shutdown-detected' | 11 _UNCLEAN_SHUTDOWN_DETECTED_PATH = '/tmp/unclean-shutdown-detected' |
13 _UNCLEAN_SHUTDOWN_MESSAGE = 'Last shutdown was not clean' | 12 _UNCLEAN_SHUTDOWN_MESSAGE = 'Last shutdown was not clean' |
14 | 13 |
15 class logging_UncleanShutdown(ui_test.UITest): | 14 class logging_UncleanShutdown(ui_test.UITest): |
16 version = 1 | 15 version = 1 |
17 auto_login = False | 16 auto_login = False |
18 | 17 |
19 | 18 |
20 def run_once(self): | 19 def run_once(self): |
21 if not os.path.exists(_PENDING_SHUTDOWN_PATH): | 20 if not os.path.exists(_PENDING_SHUTDOWN_PATH): |
22 raise error.TestFail('pending shutdown file, %s, not found' % | 21 raise error.TestFail('pending shutdown file, %s, not found' % |
23 _PENDING_SHUTDOWN_PATH) | 22 _PENDING_SHUTDOWN_PATH) |
24 | 23 |
25 log_reader = site_log_reader.LogReader() | 24 log_reader = log_reader.LogReader() |
26 log_reader.set_start_by_reboot(-1) | 25 log_reader.set_start_by_reboot(-1) |
27 | 26 |
28 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): | 27 if log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): |
29 raise error.TestFail( | 28 raise error.TestFail( |
30 'Unexpectedly detected unclean shutdown during boot') | 29 'Unexpectedly detected unclean shutdown during boot') |
31 | 30 |
32 if os.path.exists(_UNCLEAN_SHUTDOWN_DETECTED_PATH): | 31 if os.path.exists(_UNCLEAN_SHUTDOWN_DETECTED_PATH): |
33 raise error.TestFail('an unclean shutdown file was detected') | 32 raise error.TestFail('an unclean shutdown file was detected') |
34 | 33 |
35 # Log in and out twice to make sure that doesn't cause | 34 # Log in and out twice to make sure that doesn't cause |
(...skipping 28 matching lines...) Expand all Loading... |
64 log_reader.set_start_by_current() | 63 log_reader.set_start_by_current() |
65 utils.system('%s --init' % _CRASH_PATH) | 64 utils.system('%s --init' % _CRASH_PATH) |
66 | 65 |
67 if not log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): | 66 if not log_reader.can_find(_UNCLEAN_SHUTDOWN_MESSAGE): |
68 raise error.TestFail('Did not signal unclean shutdown when should') | 67 raise error.TestFail('Did not signal unclean shutdown when should') |
69 | 68 |
70 if not os.path.exists(_UNCLEAN_SHUTDOWN_DETECTED_PATH): | 69 if not os.path.exists(_UNCLEAN_SHUTDOWN_DETECTED_PATH): |
71 raise error.TestFail('Did not touch unclean shutdown file') | 70 raise error.TestFail('Did not touch unclean shutdown file') |
72 | 71 |
73 os.remove(_UNCLEAN_SHUTDOWN_DETECTED_PATH) | 72 os.remove(_UNCLEAN_SHUTDOWN_DETECTED_PATH) |
OLD | NEW |