Завершать DAP при потере остановленного MAME
This commit is contained in:
@@ -18,10 +18,13 @@ class DummyModel:
|
||||
|
||||
|
||||
class DummyBridge:
|
||||
def __init__(self): self.calls = []
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
self.state = 'stopped'
|
||||
def close(self): pass
|
||||
def request(self, command, **arguments):
|
||||
self.calls.append((command, arguments))
|
||||
if command == 'snapshot': return {'state': self.state}
|
||||
if command == 'console_print': return {'printed': True}
|
||||
raise AssertionError(command)
|
||||
|
||||
@@ -37,6 +40,10 @@ class DummySession:
|
||||
def attach(self):
|
||||
return {'build_id': 'test', 'location': {'status': 'mapped'}}
|
||||
|
||||
def where(self, snapshot=None):
|
||||
return {'status': 'mapped', 'pc': 0x8100, 'link_address': 0x8100,
|
||||
'sources': [{'file': '/src/main.c', 'line': 3}]}
|
||||
|
||||
def break_line(self, filename, line, enabled=True):
|
||||
if line == 99:
|
||||
raise SessionError('нет адреса')
|
||||
@@ -131,6 +138,7 @@ class WaitingBridge:
|
||||
"""Машинный over ожидает внешний ввод, но pause должен остаться доступен."""
|
||||
def __init__(self):
|
||||
self.paused = False
|
||||
self.started = False
|
||||
self.calls = []
|
||||
|
||||
def close(self): pass
|
||||
@@ -138,11 +146,12 @@ class WaitingBridge:
|
||||
def request(self, command, **arguments):
|
||||
self.calls.append(command)
|
||||
if command == 'snapshot':
|
||||
return {'state': 'stopped' if self.paused else 'running'}
|
||||
return {'state': 'running' if self.started and not self.paused else 'stopped'}
|
||||
if command == 'pause':
|
||||
self.paused = True
|
||||
return {'accepted': True}
|
||||
if command == 'step_over':
|
||||
self.started = True
|
||||
return {'accepted': True}
|
||||
raise AssertionError(command)
|
||||
|
||||
@@ -180,6 +189,37 @@ class ServerTests(unittest.TestCase):
|
||||
server.close()
|
||||
controller.close()
|
||||
|
||||
def test_idle_snapshot_detects_invalidation(self):
|
||||
session = DummySession()
|
||||
controller = SessionController(session)
|
||||
try:
|
||||
session.bridge.state = 'invalidated'
|
||||
with controller.changed:
|
||||
self.assertTrue(controller.changed.wait_for(lambda: controller.closed,
|
||||
timeout=2))
|
||||
self.assertEqual(controller.events[-1]['event'], 'invalidated')
|
||||
self.assertEqual(controller.events[-1]['body']['reason'], 'reset_or_load')
|
||||
finally:
|
||||
controller.close()
|
||||
|
||||
def test_native_debugger_continue_is_reported(self):
|
||||
session = DummySession()
|
||||
controller = SessionController(session)
|
||||
try:
|
||||
session.bridge.state = 'running'
|
||||
with controller.changed:
|
||||
self.assertTrue(controller.changed.wait_for(lambda: controller.running,
|
||||
timeout=2))
|
||||
self.assertEqual(controller.events[-1]['event'], 'continued')
|
||||
self.assertEqual(controller.events[-1]['body']['reason'], 'external')
|
||||
session.bridge.state = 'stopped'
|
||||
with controller.changed:
|
||||
self.assertTrue(controller.changed.wait_for(lambda: not controller.running,
|
||||
timeout=2))
|
||||
self.assertEqual(controller.events[-1]['event'], 'stopped')
|
||||
finally:
|
||||
controller.close()
|
||||
|
||||
def test_source_breakpoints_replace_and_rollback(self):
|
||||
session = DummySession()
|
||||
controller = SessionController(session)
|
||||
|
||||
Reference in New Issue
Block a user