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_crash_test, site_utils, test | 6 from autotest_lib.client.bin import site_crash_test, 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 _25_HOURS_AGO = -25 * 60 * 60 | 9 _25_HOURS_AGO = -25 * 60 * 60 |
10 _CRASH_SENDER_CRON_PATH = '/etc/cron.hourly/crash_sender.hourly' | 10 _CRASH_SENDER_CRON_PATH = '/etc/cron.hourly/crash_sender.hourly' |
(...skipping 14 matching lines...) Expand all Loading... | |
25 raise error.TestFail('Missing board name %s in output' % | 25 raise error.TestFail('Missing board name %s in output' % |
26 board_match.group(1)) | 26 board_match.group(1)) |
27 # Get hwid | 27 # Get hwid |
28 hwclass = 'undefined' | 28 hwclass = 'undefined' |
29 if os.path.exists(_HWCLASS_PATH): | 29 if os.path.exists(_HWCLASS_PATH): |
30 hwclass = utils.read_file(_HWCLASS_PATH) | 30 hwclass = utils.read_file(_HWCLASS_PATH) |
31 if not ('HWClass: %s' % hwclass) in result['output']: | 31 if not ('HWClass: %s' % hwclass) in result['output']: |
32 raise error.TestFail('Expected hwclass %s in output' % hwclass) | 32 raise error.TestFail('Expected hwclass %s in output' % hwclass) |
33 | 33 |
34 | 34 |
35 def _check_simple_minidump_send(self, report): | 35 def _check_simple_minidump_send(self, report, log_path=None): |
36 result = self._call_sender_one_crash(report=report) | 36 result = self._call_sender_one_crash(report=report) |
37 if (result['report_exists'] or | 37 if (result['report_exists'] or |
38 result['rate_count'] != 1 or | 38 result['rate_count'] != 1 or |
39 not result['send_attempt'] or | 39 not result['send_attempt'] or |
40 not result['send_success'] or | 40 not result['send_success'] or |
41 result['sleep_time'] < 0 or | 41 result['sleep_time'] < 0 or |
42 result['sleep_time'] >= _SECONDS_SEND_SPREAD or | 42 result['sleep_time'] >= _SECONDS_SEND_SPREAD or |
43 result['report_kind'] != 'minidump' or | 43 result['report_kind'] != 'minidump' or |
44 result['report_payload'] != '/var/spool/crash/fake.dmp' or | 44 result['report_payload'] != '/var/spool/crash/fake.dmp' or |
45 result['exec_name'] != 'fake' or | 45 result['exec_name'] != 'fake' or |
46 not 'Version: my_ver' in result['output']): | 46 not 'Version: my_ver' in result['output']): |
47 raise error.TestFail('Simple minidump send failed') | 47 raise error.TestFail('Simple minidump send failed') |
48 if log_path and not ('log: @%s' % log_path) in result['output']: | |
49 raise error.TestFail('Minidump send missing log') | |
48 self._check_hardware_info(result) | 50 self._check_hardware_info(result) |
49 | 51 |
50 | 52 |
51 def _test_sender_simple_minidump(self): | 53 def _test_sender_simple_minidump(self): |
52 """Test sending a single minidump crash report.""" | 54 """Test sending a single minidump crash report.""" |
53 self._check_simple_minidump_send(None) | 55 self._check_simple_minidump_send(None) |
54 | 56 |
55 | 57 |
58 def _test_sender_simple_minidump_with_log(self): | |
59 """Test that a minidump report with an auxiliary log is sent.""" | |
60 dmp_path = self.write_crash_dir_entry('fake.dmp', '') | |
61 log_path = self.write_crash_dir_entry('fake.log', '') | |
62 meta_path = self.write_fake_meta('fake.meta', 'fake', dmp_path, log=log_ path) | |
petkov
2010/12/13 19:44:09
80 chars
| |
63 self._check_simple_minidump_send(meta_path, log_path) | |
64 | |
65 | |
56 def _shift_file_mtime(self, path, delta): | 66 def _shift_file_mtime(self, path, delta): |
57 statinfo = os.stat(path) | 67 statinfo = os.stat(path) |
58 os.utime(path, (statinfo.st_atime, | 68 os.utime(path, (statinfo.st_atime, |
59 statinfo.st_mtime + delta)) | 69 statinfo.st_mtime + delta)) |
60 | 70 |
61 | 71 |
62 def _test_sender_simple_old_minidump(self): | 72 def _test_sender_simple_old_minidump(self): |
63 """Test that old minidumps and metadata are sent.""" | 73 """Test that old minidumps and metadata are sent.""" |
64 dmp_path = self.write_crash_dir_entry('fake.dmp', '') | 74 dmp_path = self.write_crash_dir_entry('fake.dmp', '') |
65 meta_path = self.write_fake_meta('fake.meta', 'fake', dmp_path) | 75 meta_path = self.write_fake_meta('fake.meta', 'fake', dmp_path) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 result = self._parse_sender_output(crash_sender_log) | 265 result = self._parse_sender_output(crash_sender_log) |
256 logging.debug('Result of crash send: %s' % result) | 266 logging.debug('Result of crash send: %s' % result) |
257 if not result['send_attempt'] or not result['send_success']: | 267 if not result['send_attempt'] or not result['send_success']: |
258 raise error.TestFail('Cron simple run test failed') | 268 raise error.TestFail('Cron simple run test failed') |
259 | 269 |
260 | 270 |
261 def run_once(self): | 271 def run_once(self): |
262 self.run_crash_tests([ | 272 self.run_crash_tests([ |
263 'sender_simple_minidump', | 273 'sender_simple_minidump', |
264 'sender_simple_old_minidump', | 274 'sender_simple_old_minidump', |
275 'sender_simple_minidump_with_log', | |
265 'sender_simple_kernel_crash', | 276 'sender_simple_kernel_crash', |
266 'sender_pausing', | 277 'sender_pausing', |
267 'sender_reports_disabled', | 278 'sender_reports_disabled', |
268 'sender_rate_limiting', | 279 'sender_rate_limiting', |
269 'sender_single_instance', | 280 'sender_single_instance', |
270 'sender_send_fails', | 281 'sender_send_fails', |
271 'sender_orphaned_files', | 282 'sender_orphaned_files', |
272 'sender_incomplete_metadata', | 283 'sender_incomplete_metadata', |
273 'sender_missing_payload', | 284 'sender_missing_payload', |
274 'cron_runs']) | 285 'cron_runs']) |
OLD | NEW |