Skip to content

Commit ab4a456

Browse files
committed
Trying to improve stability of test_standard_breakpoint_X_remove
1 parent db8d782 commit ab4a456

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

tests/test_debugger.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -376,22 +376,28 @@ def trigger(self, dbg, exc):
376376
@pytest.mark.parametrize("bptype", [windows.debug.FunctionParamDumpHXBP, windows.debug.FunctionParamDumpBP])
377377
def test_standard_breakpoint_self_remove(proc32_64_debug, bptype):
378378
data = set()
379-
379+
thread_exception = []
380380
def do_check():
381381
time.sleep(1)
382-
print("[==================] LOADING PYTHON")
383-
proc32_64_debug.execute_python_unsafe("1").wait()
384-
print("[==================] OPEN SELF_FILENAME1")
385-
proc32_64_debug.execute_python_unsafe("open(u'SELF_FILENAME1')").wait()
386-
time.sleep(0.1)
387-
print("[==================] OPEN SELF_FILENAME2")
388-
proc32_64_debug.execute_python_unsafe("open(u'SELF_FILENAME2')").wait()
389-
time.sleep(0.1)
390-
print("[==================] OPEN SELF_FILENAME3")
391-
proc32_64_debug.execute_python_unsafe("open(u'SELF_FILENAME3')").wait()
392-
time.sleep(0.1)
393-
print("[==================] KILLING TARGET")
394-
proc32_64_debug.exit()
382+
try:
383+
assert proc32_64_debug.peb.Ldr[0].Initialized, "peb.Ldr not yet Initialized"
384+
print("[==================] LOADING PYTHON")
385+
proc32_64_debug.execute_python_unsafe("1").wait()
386+
print("[==================] OPEN SELF_FILENAME1")
387+
proc32_64_debug.execute_python_unsafe("open(u'SELF_FILENAME1')").wait()
388+
time.sleep(0.1)
389+
print("[==================] OPEN SELF_FILENAME2")
390+
proc32_64_debug.execute_python_unsafe("open(u'SELF_FILENAME2')").wait()
391+
time.sleep(0.1)
392+
print("[==================] OPEN SELF_FILENAME3")
393+
proc32_64_debug.execute_python_unsafe("open(u'SELF_FILENAME3')").wait()
394+
time.sleep(0.1)
395+
print("[==================] KILLING TARGET")
396+
except Exception as e:
397+
traceback.print_exc()
398+
thread_exception.append(e)
399+
finally:
400+
proc32_64_debug.exit()
395401

396402
class TSTBP(bptype):
397403
TARGET = windows.winproxy.CreateFileW
@@ -407,8 +413,13 @@ def trigger(self, dbg, exc):
407413

408414
d = windows.debug.Debugger(proc32_64_debug)
409415
d.add_bp(TSTBP("kernelbase!CreateFileW"))
410-
threading.Thread(target=do_check).start()
416+
t = threading.Thread(target=do_check)
417+
t.start()
411418
d.loop()
419+
assert not t.is_alive()
420+
if thread_exception:
421+
raise thread_exception[0]
422+
412423
assert data >= set([u"SELF_FILENAME1", u"SELF_FILENAME2"])
413424
assert u"SELF_FILENAME3" not in data
414425

@@ -431,6 +442,7 @@ def test_standard_breakpoint_remove(proc32_64_debug, bptype):
431442
def do_check():
432443
time.sleep(1)
433444
try:
445+
assert proc32_64_debug.peb.Ldr[0].Initialized, "peb.Ldr not yet Initialized"
434446
print("[==================] LOADING PYTHON")
435447
assert list(d.breakpoints.values())[0]
436448
proc32_64_debug.execute_python_unsafe("1").wait()

0 commit comments

Comments
 (0)