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

Side by Side Diff: client/cros/crash_test.py

Issue 6557003: Modify autotest to support preserving minidumps generated during tests. (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: Created 9 years, 10 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
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, shutil 5 import logging, os, re, shutil
6 import common 6 import common
7 import cros_logging 7 import cros_logging
8 from autotest_lib.client.bin import test, utils 8 from autotest_lib.client.bin import test, utils
9 from autotest_lib.client.common_lib import error 9 from autotest_lib.client.common_lib import error
10 10
11 11
12 class CrashTest(test.test): 12 class CrashTest(test.test):
13 13
14 _CONSENT_FILE = '/home/chronos/Consent To Send Stats' 14 _CONSENT_FILE = '/home/chronos/Consent To Send Stats'
15 _CORE_PATTERN = '/proc/sys/kernel/core_pattern' 15 _CORE_PATTERN = '/proc/sys/kernel/core_pattern'
16 _CRASH_REPORTER_PATH = '/sbin/crash_reporter' 16 _CRASH_REPORTER_PATH = '/sbin/crash_reporter'
17 _CRASH_SENDER_PATH = '/sbin/crash_sender' 17 _CRASH_SENDER_PATH = '/sbin/crash_sender'
18 _CRASH_SENDER_RATE_DIR = '/var/lib/crash_sender' 18 _CRASH_SENDER_RATE_DIR = '/var/lib/crash_sender'
19 _CRASH_SENDER_RUN_PATH = '/var/run/crash_sender.pid' 19 _CRASH_SENDER_RUN_PATH = '/var/run/crash_sender.pid'
20 _CRASH_TEST_IN_PROGRESS = '/tmp/crash-test-in-progress'
kmixter1 2011/02/23 02:00:39 This is similar in use to _MOCK_CRASH_SENDING. I
ericli 2011/02/23 04:49:34 any reason why not in constants.py? On 2011/02/23
thieule 2011/03/03 01:27:41 _MOCK_CRASH_SENDING is set after the crash but bef
thieule 2011/03/03 01:27:41 I'm going to leave this constant in this file to b
20 _MOCK_CRASH_SENDING = '/tmp/mock-crash-sending' 21 _MOCK_CRASH_SENDING = '/tmp/mock-crash-sending'
21 _PAUSE_FILE = '/var/lib/crash_sender_paused' 22 _PAUSE_FILE = '/var/lib/crash_sender_paused'
22 _SYSTEM_CRASH_DIR = '/var/spool/crash' 23 _SYSTEM_CRASH_DIR = '/var/spool/crash'
23 _USER_CRASH_DIR = '/home/chronos/user/crash' 24 _USER_CRASH_DIR = '/home/chronos/user/crash'
24 25
25 def _set_system_sending(self, is_enabled): 26 def _set_system_sending(self, is_enabled):
26 """Sets whether or not the system crash_sender is allowed to run. 27 """Sets whether or not the system crash_sender is allowed to run.
27 28
28 crash_sender may still be allowed to run if _set_child_sending is 29 crash_sender may still be allowed to run if _set_child_sending is
29 called with true and it is run as a child process.""" 30 called with true and it is run as a child process."""
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 75
75 76
76 def _set_consent(self, has_consent): 77 def _set_consent(self, has_consent):
77 if has_consent: 78 if has_consent:
78 utils.open_write_close(self._CONSENT_FILE, 'test-consent') 79 utils.open_write_close(self._CONSENT_FILE, 'test-consent')
79 logging.info('Created ' + self._CONSENT_FILE) 80 logging.info('Created ' + self._CONSENT_FILE)
80 else: 81 else:
81 utils.system('rm -f "%s"' % (self._CONSENT_FILE)) 82 utils.system('rm -f "%s"' % (self._CONSENT_FILE))
82 83
83 84
85 def _set_crash_test_in_progress(self, in_progress):
86 if in_progress:
87 utils.open_write_close(self._CRASH_TEST_IN_PROGRESS, 'in-progress')
88 logging.info('Created ' + self._CRASH_TEST_IN_PROGRESS)
89 else:
90 utils.system('rm -f "%s"' % (self._CRASH_TEST_IN_PROGRESS))
91
92
84 def _get_pushed_consent_file_path(self): 93 def _get_pushed_consent_file_path(self):
85 return os.path.join(self.bindir, 'pushed_consent') 94 return os.path.join(self.bindir, 'pushed_consent')
86 95
87 96
88 def _push_consent(self): 97 def _push_consent(self):
89 if os.path.exists(self._CONSENT_FILE): 98 if os.path.exists(self._CONSENT_FILE):
90 shutil.move(self._CONSENT_FILE, 99 shutil.move(self._CONSENT_FILE,
91 self._get_pushed_consent_file_path()) 100 self._get_pushed_consent_file_path())
92 101
93 102
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 def disable_crash_filtering(self): 315 def disable_crash_filtering(self):
307 self._replace_crash_reporter_filter_in('') 316 self._replace_crash_reporter_filter_in('')
308 317
309 318
310 def initialize(self): 319 def initialize(self):
311 test.test.initialize(self) 320 test.test.initialize(self)
312 self._log_reader = cros_logging.LogReader() 321 self._log_reader = cros_logging.LogReader()
313 self._leave_crash_sending = True 322 self._leave_crash_sending = True
314 self._automatic_consent_saving = True 323 self._automatic_consent_saving = True
315 self.enable_crash_filtering('none') 324 self.enable_crash_filtering('none')
325 self._set_crash_test_in_progress(True)
316 326
317 327
318 def cleanup(self): 328 def cleanup(self):
319 self._reset_rate_limiting() 329 self._reset_rate_limiting()
320 self._clear_spooled_crashes() 330 self._clear_spooled_crashes()
321 self._set_system_sending(self._leave_crash_sending) 331 self._set_system_sending(self._leave_crash_sending)
322 self._set_sending_mock(mock_enabled=False) 332 self._set_sending_mock(mock_enabled=False)
323 if self._automatic_consent_saving: 333 if self._automatic_consent_saving:
324 self._pop_consent() 334 self._pop_consent()
325 self.disable_crash_filtering() 335 self.disable_crash_filtering()
336 self._set_crash_test_in_progress(False)
326 test.test.cleanup(self) 337 test.test.cleanup(self)
327 338
328 339
329 def run_crash_tests(self, 340 def run_crash_tests(self,
330 test_names, 341 test_names,
331 initialize_crash_reporter=False, 342 initialize_crash_reporter=False,
332 clear_spool_first=True, 343 clear_spool_first=True,
333 must_run_all=True): 344 must_run_all=True):
334 """Run crash tests defined in this class. 345 """Run crash tests defined in this class.
335 346
(...skipping 20 matching lines...) Expand all
356 self._initialize_crash_reporter() 367 self._initialize_crash_reporter()
357 # Disable crash_sender from running, kill off any running ones, but 368 # Disable crash_sender from running, kill off any running ones, but
358 # set environment so crash_sender may run as a child process. 369 # set environment so crash_sender may run as a child process.
359 self._set_system_sending(False) 370 self._set_system_sending(False)
360 self._set_child_sending(True) 371 self._set_child_sending(True)
361 self._kill_running_sender() 372 self._kill_running_sender()
362 self._reset_rate_limiting() 373 self._reset_rate_limiting()
363 if clear_spool_first: 374 if clear_spool_first:
364 self._clear_spooled_crashes() 375 self._clear_spooled_crashes()
365 getattr(self, '_test_' + test_name)() 376 getattr(self, '_test_' + test_name)()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698