feat: integrate native diagnostics and coordinated CBB transactions
This commit is contained in:
1 parent
9e230e1a46
commit
da67de026f
91 files changed
+14370
-435
No files matched your search
@@ -0,0 +1,46 @@
|
||||
"""Foreign PCB windows must not become this scan's evidence or cleanup targets."""
|
||||
from dataclasses import replace
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize('suffix,flag', [('.backup', '-ReusableCircuit'), ('', '-ReusableCircuitOther')])
|
||||
def test_reusable_pcb_binding_requires_exact_path_and_switch(tmp_path, suffix, flag):
|
||||
from cbb_refresh_verify.mentor_adapter import is_reusable_circuit_pcb
|
||||
pcb = tmp_path/'Board.pcb'
|
||||
assert not is_reusable_circuit_pcb('C:/Mentor/ExpeditionPCB.exe',
|
||||
f'ExpeditionPCB.exe "{pcb}{suffix}" {flag}', pcb)
|
||||
|
||||
|
||||
def test_agent_roundtrip_applies_pid_scope_and_rejects_window_changed_to_foreign_owner(tmp_path):
|
||||
from test_dialog_agent import running_protocol, snapshot, FakeExecutor
|
||||
from cbb_refresh_verify.dialog_models import DialogPhase, stable_fingerprint
|
||||
class Probe:
|
||||
value = snapshot()
|
||||
scopes = []
|
||||
def capture(self, phase, *, pids=None):
|
||||
self.scopes.append(pids)
|
||||
return (self.value,) if self.value.pid in pids else ()
|
||||
def matches_identity(self, expected):
|
||||
return self.value.pid == expected.pid
|
||||
probe, executor = Probe(), FakeExecutor()
|
||||
client, _, thread = running_protocol(tmp_path, probe, executor)
|
||||
try:
|
||||
assert client.observe(DialogPhase.PCB_STARTING, pids={99}) == ()
|
||||
owned = client.observe(DialogPhase.PCB_STARTING, pids={20})[0]
|
||||
probe.value = replace(probe.value, pid=99)
|
||||
result = client.perform(hwnd=owned.hwnd, fingerprint=stable_fingerprint(owned),
|
||||
action={'action': 'confirm', 'channels': ['win32_button_click']}, phase=DialogPhase.PCB_STARTING)
|
||||
assert result.error_code == 'STALE_DIALOG' and not executor.calls
|
||||
finally:
|
||||
client.close(); thread.join(2)
|
||||
|
||||
|
||||
def test_process_watch_polls_bound_handles_without_wmi(monkeypatch):
|
||||
from cbb_refresh_verify import owner_probe
|
||||
from cbb_refresh_verify.pcb_bridge import ProcessWatch
|
||||
monkeypatch.setattr(owner_probe, 'query_owners', lambda *a, **kw: pytest.fail('Polled WMI during COM attach'))
|
||||
with ProcessWatch({os.getpid()}) as watch:
|
||||
assert all(watch.alive() for _ in range(20))
|
||||
Reference in new issue
Block a user