33import ctypes
44import os
55import time
6+ import traceback
67
78import windows
89import windows .debug
@@ -426,24 +427,34 @@ def on_exception(self, exc):
426427@pytest .mark .parametrize ("bptype" , [windows .debug .FunctionParamDumpHXBP , windows .debug .FunctionParamDumpBP ])
427428def test_standard_breakpoint_remove (proc32_64_debug , bptype ):
428429 data = set ()
429-
430+ thread_exception = []
430431 def do_check ():
431432 time .sleep (1 )
432- print ("[==================] LOADING PYTHON" )
433- proc32_64_debug .execute_python_unsafe ("1" ).wait ()
434- print ("[==================] OPEN FILENAME1" )
435- proc32_64_debug .execute_python_unsafe ("open(u'FILENAME1')" ).wait ()
436- time .sleep (0.1 )
437- print ("[==================] OPEN FILENAME2" )
438- proc32_64_debug .execute_python_unsafe ("open(u'FILENAME2')" ).wait ()
439- time .sleep (0.1 )
440- print ("[==================] RM BP" )
441- d .del_bp (the_bp )
442- print ("[==================] OPEN FILENAME3" )
443- proc32_64_debug .execute_python_unsafe ("open(u'FILENAME3')" ).wait ()
444- time .sleep (0.1 )
445- print ("[==================] KILLING TARGET" )
446- proc32_64_debug .exit ()
433+ try :
434+ print ("[==================] LOADING PYTHON" )
435+ assert list (d .breakpoints .values ())[0 ]
436+ proc32_64_debug .execute_python_unsafe ("1" ).wait ()
437+ print ("[==================] OPEN FILENAME1" )
438+ assert list (d .breakpoints .values ())[0 ]
439+ proc32_64_debug .execute_python_unsafe ("open(u'FILENAME1')" ).wait ()
440+ time .sleep (0.1 )
441+ print ("[==================] OPEN FILENAME2" )
442+ assert list (d .breakpoints .values ())[0 ]
443+ proc32_64_debug .execute_python_unsafe ("open(u'FILENAME2')" ).wait ()
444+ time .sleep (0.1 )
445+ print ("[==================] RM BP" )
446+ assert list (d .breakpoints .values ())[0 ]
447+ d .del_bp (the_bp )
448+ assert not list (d .breakpoints .values ())[0 ]
449+ print ("[==================] OPEN FILENAME3" )
450+ proc32_64_debug .execute_python_unsafe ("open(u'FILENAME3')" ).wait ()
451+ time .sleep (0.1 )
452+ print ("[==================] KILLING TARGET" )
453+ except Exception as e :
454+ traceback .print_exc ()
455+ thread_exception .append (e )
456+ finally :
457+ proc32_64_debug .exit ()
447458
448459 class TSTBP (bptype ):
449460 TARGET = windows .winproxy .CreateFileW
@@ -460,8 +471,12 @@ def trigger(self, dbg, exc):
460471 # import pdb;pdb.set_trace()
461472 d .add_bp (the_bp )
462473 time .sleep (0.1 )
463- threading .Thread (target = do_check ).start ()
474+ t = threading .Thread (target = do_check )
475+ t .start ()
464476 d .loop ()
477+ assert not t .is_alive ()
478+ if thread_exception :
479+ raise thread_exception [0 ]
465480 assert data >= set ([u"FILENAME1" , u"FILENAME2" ])
466481 assert u"FILENAME3" not in data
467482
0 commit comments