Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: client/site_tests/logging_CrashSender/logging_CrashSender.py

Issue 5763003: autotest: Test that logs can be sent when processes crash (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: Respond to review Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/bin/site_crash_test.py ('k') | client/site_tests/logging_UserCrash/logging_UserCrash.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
63 log=log_path)
64 self._check_simple_minidump_send(meta_path, log_path)
65
66
56 def _shift_file_mtime(self, path, delta): 67 def _shift_file_mtime(self, path, delta):
57 statinfo = os.stat(path) 68 statinfo = os.stat(path)
58 os.utime(path, (statinfo.st_atime, 69 os.utime(path, (statinfo.st_atime,
59 statinfo.st_mtime + delta)) 70 statinfo.st_mtime + delta))
60 71
61 72
62 def _test_sender_simple_old_minidump(self): 73 def _test_sender_simple_old_minidump(self):
63 """Test that old minidumps and metadata are sent.""" 74 """Test that old minidumps and metadata are sent."""
64 dmp_path = self.write_crash_dir_entry('fake.dmp', '') 75 dmp_path = self.write_crash_dir_entry('fake.dmp', '')
65 meta_path = self.write_fake_meta('fake.meta', 'fake', dmp_path) 76 meta_path = self.write_fake_meta('fake.meta', 'fake', dmp_path)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 result = self._parse_sender_output(crash_sender_log) 266 result = self._parse_sender_output(crash_sender_log)
256 logging.debug('Result of crash send: %s' % result) 267 logging.debug('Result of crash send: %s' % result)
257 if not result['send_attempt'] or not result['send_success']: 268 if not result['send_attempt'] or not result['send_success']:
258 raise error.TestFail('Cron simple run test failed') 269 raise error.TestFail('Cron simple run test failed')
259 270
260 271
261 def run_once(self): 272 def run_once(self):
262 self.run_crash_tests([ 273 self.run_crash_tests([
263 'sender_simple_minidump', 274 'sender_simple_minidump',
264 'sender_simple_old_minidump', 275 'sender_simple_old_minidump',
276 'sender_simple_minidump_with_log',
265 'sender_simple_kernel_crash', 277 'sender_simple_kernel_crash',
266 'sender_pausing', 278 'sender_pausing',
267 'sender_reports_disabled', 279 'sender_reports_disabled',
268 'sender_rate_limiting', 280 'sender_rate_limiting',
269 'sender_single_instance', 281 'sender_single_instance',
270 'sender_send_fails', 282 'sender_send_fails',
271 'sender_orphaned_files', 283 'sender_orphaned_files',
272 'sender_incomplete_metadata', 284 'sender_incomplete_metadata',
273 'sender_missing_payload', 285 'sender_missing_payload',
274 'cron_runs']) 286 'cron_runs'])
OLDNEW
« no previous file with comments | « client/bin/site_crash_test.py ('k') | client/site_tests/logging_UserCrash/logging_UserCrash.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698