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

Side by Side Diff: content/shell/tools/breakpad_integration_test.py

Issue 293993017: Add a breakpad / content_shell integration test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 7 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
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """Integration test for breakpad in content shell.
8
9 This test checks that content shell and breakpad are correctly hooked up, as
10 well as that the tools can symbolize a stack trace."""
11
12
13 import glob
14 import optparse
15 import os
16 import shutil
17 import subprocess
18 import sys
19 import tempfile
20
21
22 CONCURRENT_TASKS=4
23
24
25 def main():
26 parser = optparse.OptionParser()
27 parser.add_option('', '--build-dir', default='',
28 help='The build output directory.')
29 parser.add_option('', '--binary', default='',
30 help='The path of the binary to generate symbols for.')
31 parser.add_option('', '--no-symbols', default=False, action='store_true',
32 help='Symbols are not expected to work.')
33 parser.add_option('-j', '--jobs', default=CONCURRENT_TASKS, action='store',
34 type='int', help='Number of parallel tasks to run.')
35 parser.add_option('-v', '--verbose', action='store_true',
36 help='Print verbose status output.')
37
38 (options, _) = parser.parse_args()
39
40 if not options.build_dir:
41 print "Required option --build-dir missing."
42 return 1
43
44 if not options.binary:
45 print "Required option --binary missing."
46 return 1
47
48 if not os.access(options.binary, os.X_OK):
49 print "Cannot find %s." % options.binary
50 return 1
51
52 failure = ''
53
54 # Create a temporary directory to store the crash dumps and symbols in.
55 crash_dir = tempfile.mkdtemp()
56
57 try:
58 print "# Generate symbols."
59 generate_symbols = os.path.join(
60 os.path.dirname(__file__), '..', '..', '..',
61 'components', 'breakpad', 'tools', 'generate_breakpad_symbols.py')
62 symbols_dir = os.path.join(crash_dir, 'symbols')
63 cmd = [generate_symbols,
64 '--build-dir=%s' % options.build_dir,
65 '--binary=%s' % options.binary,
66 '--symbols-dir=%s' % symbols_dir,
67 '--jobs=%d' % options.jobs]
68 if options.verbose:
69 cmd.append('--verbose')
70 print ' '.join(cmd)
71 failure = 'Failed to run generate_breakpad_symbols.py.'
72 subprocess.check_call(cmd)
73
74 print "# Run content_shell and make it crash."
75 cmd = [options.binary,
76 '--dump-render-tree',
77 'chrome://crash',
78 '--enable-crash-reporter',
79 '--crash-dumps-dir=%s' % crash_dir]
80 if options.verbose:
81 print ' '.join(cmd)
82 failure = 'Failed to run content_shell.'
83 if options.verbose:
84 subprocess.check_call(cmd)
85 else:
86 with open(os.devnull, 'w') as devnull:
87 subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
88
89 print "# Retrieve crash dump."
90 dmp_files = glob.glob(os.path.join(crash_dir, '*.dmp'))
91 failure = 'Expected 1 crash dump, found %d.' % len(dmp_files)
92 if len(dmp_files) != 1:
93 raise Exception(failure)
94 dmp_file = dmp_files[0]
95 minidump = os.path.join(crash_dir, 'minidump')
96
97 dmp_to_minidump = os.path.join(
98 os.path.dirname(__file__), '..', '..', '..',
99 'components', 'breakpad', 'tools', 'dmp2minidump.py')
Lei Zhang 2014/05/23 07:32:15 maybe figure out the path to component/breakpad/to
100 cmd = [dmp_to_minidump, dmp_file, minidump]
101 if options.verbose:
102 print ' '.join(cmd)
103 failure = 'Failed to run dmp_to_minidump.'
104 subprocess.check_call(cmd)
105
106 print "# Symbolize crash dump."
107 minidump_stackwalk = os.path.join(options.build_dir, 'minidump_stackwalk')
108 cmd = [minidump_stackwalk, minidump, symbols_dir]
109 if options.verbose:
110 print ' '.join(cmd)
111 failure = 'Failed to run minidump_stackwalk.'
112 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
113 stack = proc.communicate()[0]
114
115 # Check whether the stack contains a CrashIntentionally symbol.
116 found_symbol = stack.find('CrashIntentionally') != -1
Lei Zhang 2014/05/23 07:32:15 Since we don't care about the position, how about:
117
118 if options.no_symbols:
119 if found_symbol:
120 if options.verbose:
121 print stack
122 failure = 'Found unexpected reference to CrashIntentionally in stack'
123 raise Exception(failure)
124 else:
125 if not found_symbol:
126 if options.verbose:
127 print stack
128 failure = 'Could not find reference to CrashIntentionally in stack.'
129 raise Exception(failure)
130
131 except:
132 print "FAIL: %s" % failure
133 return 1
134
135 else:
136 print "PASS: Breakpad integration test ran successfully."
137 return 0
138
139 finally:
140 try:
141 shutil.rmtree(crash_dir)
142 except:
143 print 'Failed to delete temp directory.'
Lei Zhang 2014/05/23 07:32:15 print the name of the temp dir.
144
145
146 if '__main__' == __name__:
147 sys.exit(main())
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