Index: third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py |
diff --git a/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py b/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py |
index 42999df8a2bb15f480b0e3fcd64c906789e57b36..5afdac38ab7c43d19d83a5334a59ae66e1bddcf6 100755 |
--- a/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py |
+++ b/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py |
@@ -22,6 +22,7 @@ import subprocess |
import sys |
import tempfile |
import time |
+import win32con |
g_temp_dirs = [] |
@@ -80,23 +81,23 @@ def GetCdbPath(): |
return None |
-def GetDumpFromProgram(out_dir, pipe_name, executable_name, *args): |
+def GetDumpFromProgram( |
+ out_dir, pipe_name, executable_name, expect_exit_code, *args): |
"""Initialize a crash database, and run |executable_name| connecting to a |
crash handler. If pipe_name is set, crashpad_handler will be started first. If |
pipe_name is empty, the executable is responsible for starting |
crashpad_handler. *args will be passed after other arguments to |
- executable_name. Returns the minidump generated by crashpad_handler for |
- further testing. |
+ executable_name. If the child process does not exit with |expect_exit_code|, |
+ an exception will be raised. Returns the path to the minidump generated by |
+ crashpad_handler for further testing. |
""" |
test_database = MakeTempDir() |
handler = None |
try: |
- if subprocess.call( |
+ subprocess.check_call( |
[os.path.join(out_dir, 'crashpad_database_util.exe'), '--create', |
- '--database=' + test_database]) != 0: |
- print 'could not initialize report database' |
- return None |
+ '--database=' + test_database]) |
if pipe_name is not None: |
handler = subprocess.Popen([ |
@@ -113,12 +114,16 @@ def GetDumpFromProgram(out_dir, pipe_name, executable_name, *args): |
printed = True |
time.sleep(0.1) |
- subprocess.call([os.path.join(out_dir, executable_name), pipe_name] + |
- list(args)) |
+ exit_code = subprocess.call( |
+ [os.path.join(out_dir, executable_name), pipe_name] + list(args)) |
else: |
- subprocess.call([os.path.join(out_dir, executable_name), |
- os.path.join(out_dir, 'crashpad_handler.com'), |
- test_database] + list(args)) |
+ exit_code = subprocess.call( |
+ [os.path.join(out_dir, executable_name), |
+ os.path.join(out_dir, 'crashpad_handler.com'), |
+ test_database] + |
+ list(args)) |
+ if exit_code != expect_exit_code: |
+ raise CalledProcessError(exit_code, executable_name) |
out = subprocess.check_output([ |
os.path.join(out_dir, 'crashpad_database_util.exe'), |
@@ -135,24 +140,38 @@ def GetDumpFromProgram(out_dir, pipe_name, executable_name, *args): |
def GetDumpFromCrashyProgram(out_dir, pipe_name): |
- return GetDumpFromProgram(out_dir, pipe_name, 'crashy_program.exe') |
+ return GetDumpFromProgram(out_dir, |
+ pipe_name, |
+ 'crashy_program.exe', |
+ win32con.EXCEPTION_ACCESS_VIOLATION) |
def GetDumpFromOtherProgram(out_dir, pipe_name, *args): |
- return GetDumpFromProgram(out_dir, pipe_name, 'crash_other_program.exe', |
- *args) |
+ return GetDumpFromProgram( |
+ out_dir, pipe_name, 'crash_other_program.exe', 0, *args) |
def GetDumpFromSignal(out_dir, pipe_name, *args): |
- return GetDumpFromProgram(out_dir, pipe_name, 'crashy_signal.exe', *args) |
+ STATUS_FATAL_APP_EXIT = 0x40000015 # Not known by win32con. |
+ return GetDumpFromProgram(out_dir, |
+ pipe_name, |
+ 'crashy_signal.exe', |
+ STATUS_FATAL_APP_EXIT, |
+ *args) |
def GetDumpFromSelfDestroyingProgram(out_dir, pipe_name): |
- return GetDumpFromProgram(out_dir, pipe_name, 'self_destroying_program.exe') |
+ return GetDumpFromProgram(out_dir, |
+ pipe_name, |
+ 'self_destroying_program.exe', |
+ win32con.EXCEPTION_BREAKPOINT) |
def GetDumpFromZ7Program(out_dir, pipe_name): |
- return GetDumpFromProgram(out_dir, pipe_name, 'crashy_z7_loader.exe') |
+ return GetDumpFromProgram(out_dir, |
+ pipe_name, |
+ 'crashy_z7_loader.exe', |
+ win32con.EXCEPTION_ACCESS_VIOLATION) |
class CdbRun(object): |