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

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

Issue 3119046: Test crash report enqueue limit (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 4 months 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 | « no previous file | no next file » | 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 grp, logging, os, pwd, re, stat, subprocess 5 import grp, logging, os, pwd, re, stat, subprocess
6 from signal import SIGSEGV 6 from signal import SIGSEGV
7 from autotest_lib.client.bin import site_crash_test, site_utils, test 7 from autotest_lib.client.bin import site_crash_test, site_utils, test
8 from autotest_lib.client.common_lib import error, utils 8 from autotest_lib.client.common_lib import error, utils
9 9
10 _CORE_PATTERN = '/proc/sys/kernel/core_pattern' 10 _CORE_PATTERN = '/proc/sys/kernel/core_pattern'
11 _LEAVE_CORE_PATH = '/root/.leave_core' 11 _LEAVE_CORE_PATH = '/root/.leave_core'
12 _MAX_CRASH_DIRECTORY_SIZE = 8
12 13
13 14
14 class logging_UserCrash(site_crash_test.CrashTest): 15 class logging_UserCrash(site_crash_test.CrashTest):
15 version = 1 16 version = 1
16 17
17 18
18 def setup(self): 19 def setup(self):
19 os.chdir(self.srcdir) 20 os.chdir(self.srcdir)
20 utils.make('clean all') 21 utils.make('clean all')
21 22
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 174
174 # Wait until no crash_reporter is running. 175 # Wait until no crash_reporter is running.
175 site_utils.poll_for_condition( 176 site_utils.poll_for_condition(
176 lambda: utils.system('pgrep crash_reporter', 177 lambda: utils.system('pgrep crash_reporter',
177 ignore_status=True) != 0, 178 ignore_status=True) != 0,
178 timeout=10, 179 timeout=10,
179 exception=error.TestError( 180 exception=error.TestError(
180 'Timeout waiting for crash_reporter to finish: ' + 181 'Timeout waiting for crash_reporter to finish: ' +
181 self._log_reader.get_logs())) 182 self._log_reader.get_logs()))
182 183
184 logging.debug('crash_reporter_caught message: ' + expected_message)
183 crash_reporter_caught = self._log_reader.can_find(expected_message) 185 crash_reporter_caught = self._log_reader.can_find(expected_message)
184 186
185 result = {'crashed': crasher.returncode == expected_result, 187 result = {'crashed': crasher.returncode == expected_result,
186 'crash_reporter_caught': crash_reporter_caught, 188 'crash_reporter_caught': crash_reporter_caught,
187 'output': output, 189 'output': output,
188 'returncode': crasher.returncode} 190 'returncode': crasher.returncode}
189 logging.debug('Crasher process result: %s' % result) 191 logging.debug('Crasher process result: %s' % result)
190 return result 192 return result
191 193
192 194
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 def _test_root_breakpad_crasher(self): 354 def _test_root_breakpad_crasher(self):
353 """Test a user space crash when running as root is handled.""" 355 """Test a user space crash when running as root is handled."""
354 self._check_crashing_process('root', True) 356 self._check_crashing_process('root', True)
355 357
356 358
357 def _test_root_nobreakpad_crasher(self): 359 def _test_root_nobreakpad_crasher(self):
358 """Test a user space crash when running as root is handled.""" 360 """Test a user space crash when running as root is handled."""
359 self._check_crashing_process('root', False) 361 self._check_crashing_process('root', False)
360 362
361 363
364 def _test_max_enqueued_crashes(self):
365 """Test that _MAX_CRASH_DIRECTORY_SIZE is enforced."""
366 self._log_reader.set_start_by_current()
367 username = 'root'
368
369 crash_dir = self._get_crash_dir(username)
370 full_message = ('Crash directory %s already full with %d pending '
371 'reports' % (crash_dir, _MAX_CRASH_DIRECTORY_SIZE))
372
373 # Fill up the queue.
374 for i in range(0, _MAX_CRASH_DIRECTORY_SIZE):
375 result = self._run_crasher_process(username, with_breakpad=False)
376 if not result['crashed']:
377 raise error.TestFail('failure while setting up queue: %d' %
378 result['returncode'])
379 if self._log_reader.can_find(full_message):
380 raise error.TestFail('unexpected full message: ' + full_message)
381
382 crash_dir_size = len(os.listdir(crash_dir))
383 # For debugging
384 utils.system('ls -l %s' % crash_dir)
385 logging.info('Crash directory had %d entries' % crash_dir_size)
386
387 # Crash a bunch more times, but make sure no new reports
388 # are enqueued.
389 for i in range(0, 10):
390 self._log_reader.set_start_by_current()
391 result = self._run_crasher_process(username, with_breakpad=False)
392 logging.info('New log messages: %s' % self._log_reader.get_logs())
393 if not result['crashed']:
394 raise error.TestFail('failure after setting up queue: %d' %
395 result['returncode'])
396 if not self._log_reader.can_find(full_message):
397 raise error.TestFail('expected full message: ' + full_message)
398
399 if crash_dir_size != len(os.listdir(crash_dir)):
400 utils.system('ls -l %s' % crash_dir)
401 raise error.TestFail('expected no new files (now %d were %d)',
402 len(os.listdir(crash_dir)),
403 crash_dir_size)
404
405
362 def _check_core_file_persisting(self, expect_persist): 406 def _check_core_file_persisting(self, expect_persist):
363 self._log_reader.set_start_by_current() 407 self._log_reader.set_start_by_current()
364 408
365 result = self._run_crasher_process('root', with_breakpad=False) 409 result = self._run_crasher_process('root', with_breakpad=False)
366 410
367 if not result['crashed']: 411 if not result['crashed']:
368 raise error.TestFail('crasher did not crash') 412 raise error.TestFail('crasher did not crash')
369 413
370 crash_contents = os.listdir(self._get_crash_dir('root')) 414 crash_contents = os.listdir(self._get_crash_dir('root'))
371 415
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 # non-root, non-chronos user. 467 # non-root, non-chronos user.
424 468
425 def run_once(self): 469 def run_once(self):
426 self.run_crash_tests(['reporter_startup', 470 self.run_crash_tests(['reporter_startup',
427 'reporter_shutdown', 471 'reporter_shutdown',
428 'no_crash', 472 'no_crash',
429 'chronos_breakpad_crasher', 473 'chronos_breakpad_crasher',
430 'chronos_nobreakpad_crasher', 474 'chronos_nobreakpad_crasher',
431 'root_breakpad_crasher', 475 'root_breakpad_crasher',
432 'root_nobreakpad_crasher', 476 'root_nobreakpad_crasher',
477 'max_enqueued_crashes',
433 'core_file_persists_in_debug', 478 'core_file_persists_in_debug',
434 'core_file_removed_in_production'], 479 'core_file_removed_in_production'],
435 initialize_crash_reporter = True) 480 initialize_crash_reporter = True)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698