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

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

Issue 2786823002: hackhack test jochen cl
Patch Set: . Created 3 years, 8 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
« no previous file with comments | « content/shell/BUILD.gn ('k') | testing/buildbot/chromium.win.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 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 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Integration test for breakpad in content shell. 7 """Integration test for breakpad in content shell.
8 8
9 This test checks that content shell and breakpad are correctly hooked up, as 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.""" 10 well as that the tools can symbolize a stack trace."""
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 if not os.access(options.binary, os.X_OK): 51 if not os.access(options.binary, os.X_OK):
52 print "Cannot find %s." % options.binary 52 print "Cannot find %s." % options.binary
53 return 1 53 return 1
54 54
55 failure = '' 55 failure = ''
56 56
57 # Create a temporary directory to store the crash dumps and symbols in. 57 # Create a temporary directory to store the crash dumps and symbols in.
58 crash_dir = tempfile.mkdtemp() 58 crash_dir = tempfile.mkdtemp()
59 59
60 crash_service = None
61
60 try: 62 try:
61 print "# Generate symbols." 63 if sys.platform == 'win32':
62 breakpad_tools_dir = os.path.join( 64 print "# Starting crash service."
63 os.path.dirname(__file__), '..', '..', '..', 65 crash_service_exe = os.path.join(options.build_dir,
64 'components', 'crash', 'content', 'tools') 66 'content_shell_crash_service.exe')
65 generate_symbols = os.path.join( 67 cmd = [crash_service_exe, '--dumps-dir=%s' % crash_dir]
66 breakpad_tools_dir, 'generate_breakpad_symbols.py') 68 if options.verbose:
67 symbols_dir = os.path.join(crash_dir, 'symbols') 69 print ' '.join(cmd)
68 cmd = [generate_symbols, 70 failure = 'Failed to start crash service.'
69 '--build-dir=%s' % options.build_dir, 71 crash_service = subprocess.Popen(cmd)
70 '--binary=%s' % options.binary, 72 else:
71 '--symbols-dir=%s' % symbols_dir, 73 print "# Generate symbols."
72 '--jobs=%d' % options.jobs] 74 breakpad_tools_dir = os.path.join(
73 if options.verbose: 75 os.path.dirname(__file__), '..', '..', '..',
74 cmd.append('--verbose') 76 'components', 'crash', 'content', 'tools')
75 print ' '.join(cmd) 77 generate_symbols = os.path.join(
76 failure = 'Failed to run generate_breakpad_symbols.py.' 78 breakpad_tools_dir, 'generate_breakpad_symbols.py')
77 subprocess.check_call(cmd) 79 symbols_dir = os.path.join(crash_dir, 'symbols')
80 cmd = [generate_symbols,
81 '--build-dir=%s' % options.build_dir,
82 '--binary=%s' % options.binary,
83 '--symbols-dir=%s' % symbols_dir,
84 '--jobs=%d' % options.jobs]
85 if options.verbose:
86 cmd.append('--verbose')
87 print ' '.join(cmd)
88 failure = 'Failed to run generate_breakpad_symbols.py.'
89 subprocess.check_call(cmd)
78 90
79 print "# Run content_shell and make it crash." 91 print "# Run content_shell and make it crash."
80 cmd = [options.binary, 92 cmd = [options.binary,
81 '--run-layout-test', 93 '--run-layout-test',
82 'chrome://crash', 94 'chrome://crash',
83 '--enable-crash-reporter', 95 '--enable-crash-reporter',
84 '--crash-dumps-dir=%s' % crash_dir] 96 '--crash-dumps-dir=%s' % crash_dir]
85 if options.verbose: 97 if options.verbose:
86 print ' '.join(cmd) 98 print ' '.join(cmd)
87 failure = 'Failed to run content_shell.' 99 failure = 'Failed to run content_shell.'
88 if options.verbose: 100 if options.verbose:
89 subprocess.check_call(cmd) 101 subprocess.check_call(cmd)
90 else: 102 else:
91 with open(os.devnull, 'w') as devnull: 103 with open(os.devnull, 'w') as devnull:
92 subprocess.check_call(cmd, stdout=devnull, stderr=devnull) 104 subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
93 105
106 if sys.platform == 'win32':
107 print "# Stopping crash service"
108 failure = 'Failed to stop crash service.'
109 crash_service.terminate()
110 crash_service = None
111
94 print "# Retrieve crash dump." 112 print "# Retrieve crash dump."
95 dmp_files = glob.glob(os.path.join(crash_dir, '*.dmp')) 113 dmp_files = glob.glob(os.path.join(crash_dir, '*.dmp'))
96 failure = 'Expected 1 crash dump, found %d.' % len(dmp_files) 114 failure = 'Expected 1 crash dump, found %d.' % len(dmp_files)
97 if len(dmp_files) != 1: 115 if len(dmp_files) != 1:
98 raise Exception(failure) 116 raise Exception(failure)
99 dmp_file = dmp_files[0] 117 dmp_file = dmp_files[0]
100 minidump = os.path.join(crash_dir, 'minidump')
101 118
102 dmp_to_minidump = os.path.join(breakpad_tools_dir, 'dmp2minidump.py') 119 if sys.platform != 'win32':
103 cmd = [dmp_to_minidump, dmp_file, minidump] 120 minidump = os.path.join(crash_dir, 'minidump')
104 if options.verbose: 121 dmp_to_minidump = os.path.join(breakpad_tools_dir, 'dmp2minidump.py')
105 print ' '.join(cmd) 122 cmd = [dmp_to_minidump, dmp_file, minidump]
106 failure = 'Failed to run dmp_to_minidump.' 123 if options.verbose:
107 subprocess.check_call(cmd) 124 print ' '.join(cmd)
125 failure = 'Failed to run dmp_to_minidump.'
126 subprocess.check_call(cmd)
108 127
109 print "# Symbolize crash dump." 128 print "# Symbolize crash dump."
110 minidump_stackwalk = os.path.join(options.build_dir, 'minidump_stackwalk') 129 if sys.platform == 'win32':
111 cmd = [minidump_stackwalk, minidump, symbols_dir] 130 os.chdir(os.path.join(options.build_dir, 'cdb'))
112 if options.verbose: 131 cdb_exe = 'cdb.exe'
113 print ' '.join(cmd) 132 cmd = [cdb_exe, '-y', '..', '-c', '.lines;.excr;k30;q',
114 failure = 'Failed to run minidump_stackwalk.' 133 '-z', dmp_file]
115 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 134 if options.verbose:
116 stack = proc.communicate()[0] 135 print ' '.join(cmd)
136 failure = 'Failed to run cdb.exe.'
137 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
138 stderr=subprocess.PIPE)
139 stack = proc.communicate()[0]
140 else:
141 minidump_stackwalk = os.path.join(options.build_dir, 'minidump_stackwalk')
142 cmd = [minidump_stackwalk, minidump, symbols_dir]
143 if options.verbose:
144 print ' '.join(cmd)
145 failure = 'Failed to run minidump_stackwalk.'
146 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
147 stderr=subprocess.PIPE)
148 stack = proc.communicate()[0]
117 149
118 # Check whether the stack contains a CrashIntentionally symbol. 150 # Check whether the stack contains a CrashIntentionally symbol.
119 found_symbol = 'CrashIntentionally' in stack 151 found_symbol = 'CrashIntentionally' in stack
120 152
121 if options.no_symbols: 153 if options.no_symbols:
122 if found_symbol: 154 if found_symbol:
123 if options.verbose: 155 if options.verbose:
124 print stack 156 print stack
125 failure = 'Found unexpected reference to CrashIntentionally in stack' 157 failure = 'Found unexpected reference to CrashIntentionally in stack'
126 raise Exception(failure) 158 raise Exception(failure)
(...skipping 13 matching lines...) Expand all
140 return 1 172 return 1
141 173
142 else: 174 else:
143 print "PASS: Breakpad integration test ran successfully." 175 print "PASS: Breakpad integration test ran successfully."
144 if options.json: 176 if options.json:
145 with open(options.json, 'w') as json_file: 177 with open(options.json, 'w') as json_file:
146 json.dump([], json_file) 178 json.dump([], json_file)
147 return 0 179 return 0
148 180
149 finally: 181 finally:
182 if crash_service:
183 crash_service.terminate()
150 try: 184 try:
151 shutil.rmtree(crash_dir) 185 shutil.rmtree(crash_dir)
152 except: 186 except:
153 print 'Failed to delete temp directory "%s".' % crash_dir 187 print 'Failed to delete temp directory "%s".' % crash_dir
154 188
155 189
156 if '__main__' == __name__: 190 if '__main__' == __name__:
157 sys.exit(main()) 191 sys.exit(main())
OLDNEW
« no previous file with comments | « content/shell/BUILD.gn ('k') | testing/buildbot/chromium.win.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698