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: snapshot/win/end_to_end_test.py

Issue 1391023006: Fix for cdb tests (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 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 | « 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright 2015 The Crashpad Authors. All rights reserved. 3 # Copyright 2015 The Crashpad Authors. All rights reserved.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return app_path 74 return app_path
75 return None 75 return None
76 76
77 77
78 def GetDumpFromCrashyProgram(out_dir, pipe_name): 78 def GetDumpFromCrashyProgram(out_dir, pipe_name):
79 """Initialize a crash database, run crashpad_handler, run crashy_program 79 """Initialize a crash database, run crashpad_handler, run crashy_program
80 connecting to the crash_handler. Returns the minidump generated by 80 connecting to the crash_handler. Returns the minidump generated by
81 crash_handler for further testing. 81 crash_handler for further testing.
82 """ 82 """
83 test_database = MakeTempDir() 83 test_database = MakeTempDir()
84 handler = None
84 85
85 try: 86 try:
86 if subprocess.call( 87 if subprocess.call(
87 [os.path.join(out_dir, 'crashpad_database_util.exe'), '--create', 88 [os.path.join(out_dir, 'crashpad_database_util.exe'), '--create',
88 '--database=' + test_database]) != 0: 89 '--database=' + test_database]) != 0:
89 print 'could not initialize report database' 90 print 'could not initialize report database'
90 return None 91 return None
91 92
92 handler = subprocess.Popen([ 93 handler = subprocess.Popen([
93 os.path.join(out_dir, 'crashpad_handler.exe'), 94 os.path.join(out_dir, 'crashpad_handler.exe'),
94 '--pipe-name=' + pipe_name, 95 '--pipe-name=' + pipe_name,
95 '--database=' + test_database 96 '--database=' + test_database
96 ]) 97 ])
97 98
98 subprocess.call([os.path.join(out_dir, 'crashy_program.exe'), pipe_name]) 99 subprocess.call([os.path.join(out_dir, 'crashy_program.exe'), pipe_name])
99 100
100 out = subprocess.check_output([ 101 out = subprocess.check_output([
101 os.path.join(out_dir, 'crashpad_database_util.exe'), 102 os.path.join(out_dir, 'crashpad_database_util.exe'),
102 '--database=' + test_database, 103 '--database=' + test_database,
103 '--show-completed-reports', 104 '--show-completed-reports',
104 '--show-all-report-info', 105 '--show-all-report-info',
105 ]) 106 ])
106 for line in out.splitlines(): 107 for line in out.splitlines():
107 if line.strip().startswith('Path:'): 108 if line.strip().startswith('Path:'):
108 return line.partition(':')[2].strip() 109 return line.partition(':')[2].strip()
109
110 finally: 110 finally:
111 if handler: 111 if handler:
112 handler.kill() 112 handler.kill()
113 113
114 114
115 class CdbRun(object): 115 class CdbRun(object):
116 """Run cdb.exe passing it a cdb command and capturing the output. 116 """Run cdb.exe passing it a cdb command and capturing the output.
117 `Check()` searches for regex patterns in sequence allowing verification of 117 `Check()` searches for regex patterns in sequence allowing verification of
118 expected output. 118 expected output.
119 """ 119 """
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 out.Check(r'ExceptionList:\s+[0-9a-fA-F]+', 'some valid teb data') 170 out.Check(r'ExceptionList:\s+[0-9a-fA-F]+', 'some valid teb data')
171 out.Check(r'LastErrorValue:\s+2', 'correct LastErrorValue') 171 out.Check(r'LastErrorValue:\s+2', 'correct LastErrorValue')
172 172
173 out = CdbRun(cdb_path, dump_path, '!gle') 173 out = CdbRun(cdb_path, dump_path, '!gle')
174 out.Check('LastErrorValue: \(Win32\) 0x2 \(2\) - The system cannot find the ' 174 out.Check('LastErrorValue: \(Win32\) 0x2 \(2\) - The system cannot find the '
175 'file specified.', '!gle gets last error') 175 'file specified.', '!gle gets last error')
176 out.Check('LastStatusValue: \(NTSTATUS\) 0xc000000f - {File Not Found} The ' 176 out.Check('LastStatusValue: \(NTSTATUS\) 0xc000000f - {File Not Found} The '
177 'file %hs does not exist.', '!gle gets last ntstatus') 177 'file %hs does not exist.', '!gle gets last ntstatus')
178 178
179 # Locks. 179 # Locks.
180 out = CdbRun(cdb_path, dump_path, '!locks') 180 if False: # The code for these isn't landed yet.
181 out.Check(r'CritSec crashy_program!crashpad::`anonymous namespace\'::' 181 out = CdbRun(cdb_path, dump_path, '!locks')
182 r'g_test_critical_section', 'lock was captured') 182 out.Check(r'CritSec crashy_program!crashpad::`anonymous namespace\'::'
183 out.Check(r'\*\*\* Locked', 'lock debug info was captured, and is locked') 183 r'g_test_critical_section', 'lock was captured')
184 out.Check(r'\*\*\* Locked', 'lock debug info was captured, and is locked')
184 185
185 186
186 def main(args): 187 def main(args):
187 try: 188 try:
188 if len(args) != 1: 189 if len(args) != 1:
189 print >>sys.stderr, 'must supply out dir' 190 print >>sys.stderr, 'must supply out dir'
190 return 1 191 return 1
191 192
192 cdb_path = GetCdbPath() 193 cdb_path = GetCdbPath()
193 if not cdb_path: 194 if not cdb_path:
194 print >>sys.stderr, 'could not find cdb' 195 print >>sys.stderr, 'could not find cdb'
195 return 1 196 return 1
196 197
197 pipe_name = r'\\.\pipe\end-to-end_%s_%s' % ( 198 pipe_name = r'\\.\pipe\end-to-end_%s_%s' % (
198 os.getpid(), str(random.getrandbits(64))) 199 os.getpid(), str(random.getrandbits(64)))
199 200
200 dump_path = GetDumpFromCrashyProgram(args[0], pipe_name) 201 dump_path = GetDumpFromCrashyProgram(args[0], pipe_name)
201 if not dump_path: 202 if not dump_path:
202 return 1 203 return 1
203 204
204 RunTests(cdb_path, dump_path, pipe_name) 205 RunTests(cdb_path, dump_path, pipe_name)
205 206
206 return 0 207 return 0
207 finally: 208 finally:
208 CleanUpTempDirs() 209 CleanUpTempDirs()
209 210
210 211
211 if __name__ == '__main__': 212 if __name__ == '__main__':
212 sys.exit(main(sys.argv[1:])) 213 sys.exit(main(sys.argv[1:]))
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