fix: classify ICDB repair outcomes and gate released recovery

This commit is contained in:
阿白叔 committed 2026-11-02 18:14:38 +08:00
1 parent 44b808b8e2
commit aa760c2839
12 files changed
+751 -27

No files matched your search

+30
View File
@@ -156,3 +156,33 @@ def test_failed_startup_rejects_unrelated_failure_dialog(tmp_path, monkeypatch,
'pid': pid, 'phase': phase, 'error_code': 'MENTOR_DATABASE_LOAD_FAILED'})+'\n')
assert failed_session.close_failed_startup(job, 12, timeout_seconds=0)['status'] == 'RETAINED'
assert not messages
@pytest.mark.parametrize('exits', [True, False])
def test_startup_close_waits_for_launcher_after_empty_pcb_exit(tmp_path, monkeypatch, exits):
from types import SimpleNamespace
job, records, messages = startup_fixture(tmp_path, monkeypatch)
ticks = [0.0]
launcher = SimpleNamespace(pid=11, poll=lambda: 0 if exits and ticks[0] >= .4 else None)
monkeypatch.setattr(failed_session, 'time', SimpleNamespace(
monotonic=lambda: ticks[0], sleep=lambda seconds: ticks.__setitem__(0, ticks[0]+seconds)))
result = failed_session.close_failed_startup(job, 12, launcher_process=launcher, timeout_seconds=1)
assert ticks[0] >= .4
assert result['status'] == ('CLOSED' if exits else 'RETAINED')
assert result['release']['launcher_exited'] is exits
assert result['release']['pcb_exited'] is True
assert len(messages) == 1
def test_startup_exit_does_not_hide_late_database_address(tmp_path, monkeypatch):
import win32gui
job, records, messages = startup_fixture(tmp_path, monkeypatch)
def close(*args):
records.clear()
address = tmp_path/'database/cdbsvr/sAddress.adr'
address.parent.mkdir(parents=True)
address.write_text('still owned')
monkeypatch.setattr(win32gui, 'PostMessage', close)
result = failed_session.close_failed_startup(job, 12, timeout_seconds=0)
assert result['status'] == 'RETAINED'
assert result['release']['addresses']