Skip to content

Commit 2722ff5

Browse files
author
Martin
committed
TEST: stub clients for mmio/jt write-guard paths; fix suite
1 parent 5b91d6f commit 2722ff5

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

bridge/tests/unit/test_enable_writes_flag.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def is_instruction_sentinel(self, raw: int) -> bool:
1212
return False
1313

1414
def probe_function(self, client, ptr: int, code_min: int, code_max: int):
15+
# Simuliere validen Thumb-Treffer
1516
return "Thumb", ptr
1617

1718

@@ -46,6 +47,11 @@ def set_decompiler_comment(self, addr, comment):
4647
return True
4748

4849

50+
def _has_note(payload: dict, phrase: str) -> bool:
51+
notes = payload.get("notes", [])
52+
return any(phrase in note for note in notes)
53+
54+
4955
@pytest.mark.parametrize("dry_run", [True, False])
5056
def test_jt_slot_process_gates_writes_when_disabled(dry_run):
5157
client = DummyJTClient()
@@ -64,6 +70,7 @@ def test_jt_slot_process_gates_writes_when_disabled(dry_run):
6470
writes_enabled=False,
6571
)
6672

73+
# hat ein Wort gelesen
6774
assert client.read_addrs == [0x400004]
6875

6976
if dry_run:
@@ -81,14 +88,21 @@ def test_jt_slot_process_gates_writes_when_disabled(dry_run):
8188
assert client.comment_calls == 0
8289

8390

84-
def _has_note(payload: dict, phrase: str) -> bool:
85-
notes = payload.get("notes", [])
86-
return any(phrase in note for note in notes)
91+
class DummyMMIOClient:
92+
def __init__(self):
93+
self.calls = []
94+
95+
def disassemble_function(self, address):
96+
self.calls.append(address)
97+
return ["00500000: NOP"]
98+
99+
def set_disassembly_comment(self, address, comment):
100+
return True
87101

88102

89103
def test_mmio_annotate_returns_note_when_writes_disabled_and_dry_run_false():
90104
payload = mmio.annotate(
91-
object(),
105+
DummyMMIOClient(),
92106
function_addr=0x500000,
93107
dry_run=False,
94108
writes_enabled=False,
@@ -99,18 +113,6 @@ def test_mmio_annotate_returns_note_when_writes_disabled_and_dry_run_false():
99113
assert any("writes disabled" in note for note in payload["notes"])
100114

101115

102-
class DummyMMIOClient:
103-
def __init__(self):
104-
self.calls = []
105-
106-
def disassemble_function(self, address):
107-
self.calls.append(address)
108-
return ["00500000: NOP"]
109-
110-
def set_disassembly_comment(self, address, comment): # pragma: no cover - not used here
111-
return True
112-
113-
114116
def test_mmio_annotate_allows_dry_run_with_writes_disabled():
115117
client = DummyMMIOClient()
116118

0 commit comments

Comments
 (0)