Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ jobs:
run: py -c "import windows.generated_def"
tests:
# Not a real dependency : but starting tests when ctypes generation is broken is not useful
needs: generate_ctypes
runs-on: windows-2019
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
runs-on: [windows-2019, windows-latest]
python-version: [2.7, 3.6, 3.11]
python-architecture: [x86, x64]
include:
Expand All @@ -35,6 +33,10 @@ jobs:
- python-bitness-to-test: 64
python-architecture: x64

needs: generate_ctypes
timeout-minutes: 15
runs-on: ${{ matrix.runs-on }}

steps:
- uses: actions/checkout@v4
# Pfw testing need both 32b & 64b of tested python version for cross-bitness python injection tests
Expand Down
49 changes: 32 additions & 17 deletions tests/test_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ctypes
import os
import time
import traceback

import windows
import windows.debug
Expand Down Expand Up @@ -426,24 +427,34 @@ def on_exception(self, exc):
@pytest.mark.parametrize("bptype", [windows.debug.FunctionParamDumpHXBP, windows.debug.FunctionParamDumpBP])
def test_standard_breakpoint_remove(proc32_64_debug, bptype):
data = set()

thread_exception = []
def do_check():
time.sleep(1)
print("[==================] LOADING PYTHON")
proc32_64_debug.execute_python_unsafe("1").wait()
print("[==================] OPEN FILENAME1")
proc32_64_debug.execute_python_unsafe("open(u'FILENAME1')").wait()
time.sleep(0.1)
print("[==================] OPEN FILENAME2")
proc32_64_debug.execute_python_unsafe("open(u'FILENAME2')").wait()
time.sleep(0.1)
print("[==================] RM BP")
d.del_bp(the_bp)
print("[==================] OPEN FILENAME3")
proc32_64_debug.execute_python_unsafe("open(u'FILENAME3')").wait()
time.sleep(0.1)
print("[==================] KILLING TARGET")
proc32_64_debug.exit()
try:
print("[==================] LOADING PYTHON")
assert list(d.breakpoints.values())[0]
proc32_64_debug.execute_python_unsafe("1").wait()
print("[==================] OPEN FILENAME1")
assert list(d.breakpoints.values())[0]
proc32_64_debug.execute_python_unsafe("open(u'FILENAME1')").wait()
time.sleep(0.1)
print("[==================] OPEN FILENAME2")
assert list(d.breakpoints.values())[0]
proc32_64_debug.execute_python_unsafe("open(u'FILENAME2')").wait()
time.sleep(0.1)
print("[==================] RM BP")
assert list(d.breakpoints.values())[0]
d.del_bp(the_bp)
assert not list(d.breakpoints.values())[0]
print("[==================] OPEN FILENAME3")
proc32_64_debug.execute_python_unsafe("open(u'FILENAME3')").wait()
time.sleep(0.1)
print("[==================] KILLING TARGET")
except Exception as e:
traceback.print_exc()
thread_exception.append(e)
finally:
proc32_64_debug.exit()

class TSTBP(bptype):
TARGET = windows.winproxy.CreateFileW
Expand All @@ -460,8 +471,12 @@ def trigger(self, dbg, exc):
# import pdb;pdb.set_trace()
d.add_bp(the_bp)
time.sleep(0.1)
threading.Thread(target=do_check).start()
t = threading.Thread(target=do_check)
t.start()
d.loop()
assert not t.is_alive()
if thread_exception:
raise thread_exception[0]
assert data >= set([u"FILENAME1", u"FILENAME2"])
assert u"FILENAME3" not in data

Expand Down