| 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, re | 5 import logging, os, re |
| 6 from autotest_lib.client.bin import site_log_reader, site_utils, test | 6 from autotest_lib.client.bin import site_log_reader, site_utils, test |
| 7 from autotest_lib.client.common_lib import error, utils | 7 from autotest_lib.client.common_lib import error, utils |
| 8 | 8 |
| 9 | 9 |
| 10 class CrashTest(test.test): | 10 class CrashTest(test.test): |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 | 106 |
| 107 def write_crash_dir_entry(self, name, contents): | 107 def write_crash_dir_entry(self, name, contents): |
| 108 entry = os.path.join(self._SYSTEM_CRASH_DIR, name) | 108 entry = os.path.join(self._SYSTEM_CRASH_DIR, name) |
| 109 if not os.path.exists(self._SYSTEM_CRASH_DIR): | 109 if not os.path.exists(self._SYSTEM_CRASH_DIR): |
| 110 os.makedirs(self._SYSTEM_CRASH_DIR) | 110 os.makedirs(self._SYSTEM_CRASH_DIR) |
| 111 utils.open_write_close(entry, contents) | 111 utils.open_write_close(entry, contents) |
| 112 return entry | 112 return entry |
| 113 | 113 |
| 114 | 114 |
| 115 def write_fake_meta(self, name, exec_name): | 115 def write_fake_meta(self, name, exec_name, payload, complete=True): |
| 116 last_line = '' |
| 117 if complete: |
| 118 last_line = 'done=1\n' |
| 116 return self.write_crash_dir_entry(name, | 119 return self.write_crash_dir_entry(name, |
| 117 'exec_name=%s\n' | 120 'exec_name=%s\n' |
| 118 'ver=my_ver\n' | 121 'ver=my_ver\n' |
| 119 'done=1\n' % exec_name) | 122 'payload=%s\n' |
| 123 '%s' % (exec_name, payload, |
| 124 last_line)) |
| 120 | 125 |
| 121 | 126 |
| 122 def _prepare_sender_one_crash(self, | 127 def _prepare_sender_one_crash(self, |
| 123 send_success, | 128 send_success, |
| 124 reports_enabled, | 129 reports_enabled, |
| 125 username, | 130 username, |
| 126 report): | 131 report): |
| 127 self._set_sending_mock(mock_enabled=True, send_success=send_success) | 132 self._set_sending_mock(mock_enabled=True, send_success=send_success) |
| 128 self._set_consent(reports_enabled) | 133 self._set_consent(reports_enabled) |
| 129 if report is None: | 134 if report is None: |
| 130 self.write_crash_dir_entry('fake.dmp', '') | 135 payload = self.write_crash_dir_entry('fake.dmp', '') |
| 131 report = self.write_fake_meta('fake.meta', 'fake') | 136 report = self.write_fake_meta('fake.meta', 'fake', payload) |
| 132 return report | 137 return report |
| 133 | 138 |
| 134 | 139 |
| 135 def _parse_sender_output(self, output): | 140 def _parse_sender_output(self, output): |
| 136 """Parse the log output from the crash_sender script. | 141 """Parse the log output from the crash_sender script. |
| 137 | 142 |
| 138 This script can run on the logs from either a mocked or true | 143 This script can run on the logs from either a mocked or true |
| 139 crash send. | 144 crash send. |
| 140 | 145 |
| 141 Args: | 146 Args: |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 self._initialize_crash_reporter() | 325 self._initialize_crash_reporter() |
| 321 # Disable crash_sender from running, kill off any running ones, but | 326 # Disable crash_sender from running, kill off any running ones, but |
| 322 # set environment so crash_sender may run as a child process. | 327 # set environment so crash_sender may run as a child process. |
| 323 self._set_system_sending(False) | 328 self._set_system_sending(False) |
| 324 self._set_child_sending(True) | 329 self._set_child_sending(True) |
| 325 self._kill_running_sender() | 330 self._kill_running_sender() |
| 326 self._reset_rate_limiting() | 331 self._reset_rate_limiting() |
| 327 if clear_spool_first: | 332 if clear_spool_first: |
| 328 self._clear_spooled_crashes() | 333 self._clear_spooled_crashes() |
| 329 getattr(self, '_test_' + test_name)() | 334 getattr(self, '_test_' + test_name)() |
| OLD | NEW |