fix: address PCB access review in CLI and desktop
This commit is contained in:
1 parent
2d6acc1180
commit
7c239e123b
11 files changed
+151
-16
No files matched your search
@@ -193,6 +193,14 @@ Windows 版本判断以 Build 为准:`22000` 及以上归为 Win11,`10240–
|
||||
|
||||
GUI 中状态为 `绿色 / Ready` 的条目不能勾选、也不会进入批量队列。
|
||||
|
||||
### PCB 读写确认
|
||||
|
||||
桌面普通校验默认在读写确认弹窗无人应答 3 秒后核验占用。可在高级设置取消勾选「无人应答时自动核验 PCB 读写占用」,本次启动的后续批次便会在无人应答时跳过该项。手动选择继续也会核验占用。
|
||||
|
||||
命令行使用 `--batch-lmc` 时,加 `--auto-confirm-pcb-open` 可对已识别的读写确认执行同样的核验。带此参数的无界面运行发现该弹窗后立即开始检查。版本选择和 ICDB 维护分别使用各自的入口。
|
||||
|
||||
程序核对当前工程、LMC、布局和共享数据库。出现身份不符、实际占用、无法绑定的地址记录、绝对或不唯一的 iCDBDir,以及需要维护的库时,报告会记录具体原因。双击表格备注可查看并复制全文。
|
||||
|
||||
### 批量状态桥(只读、默认启用)
|
||||
|
||||
`tools/status_bridge/bin/CbbStatusBridge32.exe` 是与 Mentor EE 7.9 x86/MFC ABI
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# 工单 #19 审查后续验证
|
||||
|
||||
## 合入与发布
|
||||
|
||||
PR #18 的目标为 main,PR #20 叠在 PR #18 的分支上。计划先合入 #18,再将 #20 的变更合入 main。发版前在 main 核对两轮改动和测试证据,从最终提交构建新测试版。现有 beta.5 标签对应提交 `3efeaed`。其中不含 PR #20 的目录扫描、读写确认和完整备注改动。
|
||||
|
||||
## 占用验证
|
||||
|
||||
- 在 Windows 上保留实际文件探测,分别验证共享数据库由独占句柄持有和释放后的选择。另用存在地址记录的工作目录覆盖原生只读检查的调度、正反回执解析和再次探测。该用例替换 Mentor 回执来源。
|
||||
- 在隔离工程 1GPHY_RTL8211F 上,以之前捕获的项目地址记录调用实际 Mentor Project Backup。原生结果为 `NOT_IN_USE`、`repair_required=true`、`inspection_only=true`、`repair_requested=false`,退出码 0。程序拒绝自动继续。工程地址、工程数据库和共享符号数据库的哈希保持一致,原生检查进程已退出。原始回执 SHA-256 为 `22812c4423bc06fedce4eb9c89ee17e1fe10452fde76aff02ae0380a4505d1d6`。
|
||||
- 批次回归核对前项保持 SKIPPED,释放复核成功后实际调度同库下一项。工单原先的 5 个工程、364 项生产库及 Win10/SMB 仍待现场复验。
|
||||
|
||||
最终全量 Python 测试 2,526 项通过,用时 366.39 秒,退出码 0。编译和差异检查通过。本轮未复现审查机的文件探测挂起。
|
||||
@@ -143,6 +143,8 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser.add_argument('--collect-failure-logs', type=Path, help=argparse.SUPPRESS)
|
||||
parser.add_argument('--batch-lmc', type=Path, help=argparse.SUPPRESS)
|
||||
parser.add_argument('--block', action='append', default=[], help=argparse.SUPPRESS)
|
||||
parser.add_argument('--auto-confirm-pcb-open', action='store_true',
|
||||
help='With --batch-lmc, continue through the known PCB prompt after checking resource access')
|
||||
parser.add_argument('--limit', type=_positive_int, help='Maximum requested CBB names for --batch-lmc (default: all)')
|
||||
parser.add_argument('--libspec', default='', help=argparse.SUPPRESS)
|
||||
parser.add_argument('--dms-login-config', default='', help=argparse.SUPPRESS)
|
||||
@@ -203,7 +205,8 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
mentor_bin=args.mentor_bin, logging_context=context,
|
||||
mapped_drive=lease.drive,
|
||||
mapped_remote_root=lease.remote_root,
|
||||
native_lm_verify=native_lm_verify_enabled())
|
||||
native_lm_verify=native_lm_verify_enabled(),
|
||||
auto_confirm_pcb_open=args.auto_confirm_pcb_open)
|
||||
for name in names]
|
||||
def retain_mapping(reason):
|
||||
lease.retain_for_recovery()
|
||||
|
||||
@@ -43,7 +43,9 @@ def _cancel_target(snapshot):
|
||||
from .post_repair_consent import exact_prompt
|
||||
from .dialog_rules import pcb_version_choice
|
||||
if exact_prompt(snapshot):
|
||||
return 'read_write_access', next(c for c in snapshot.controls if c.control_id == 7)
|
||||
no = next((c for c in snapshot.controls if c.class_name == 'Button'
|
||||
and c.control_id == 7 and c.enabled), None)
|
||||
return ('read_write_access', no) if no is not None else None
|
||||
text = ' '.join(' '.join(c.name for c in snapshot.controls
|
||||
if c.class_name == 'Static').split())
|
||||
buttons = [c for c in snapshot.controls if c.class_name == 'Button']
|
||||
|
||||
@@ -145,9 +145,10 @@ def resource_guard(job, allowed_pids, *, require_complete_proof=False):
|
||||
|
||||
|
||||
class OpenController:
|
||||
def __init__(self, job, *, auto_confirm=False):
|
||||
def __init__(self, job, *, auto_confirm=False, require_complete_proof=False):
|
||||
self.job = job
|
||||
self.auto_confirm = auto_confirm
|
||||
self.require_complete_proof = require_complete_proof or auto_confirm
|
||||
self.choice = None
|
||||
self.original = self.owner = None
|
||||
self.sent = False
|
||||
@@ -165,7 +166,12 @@ class OpenController:
|
||||
self.owner, self.original = owner, snapshot
|
||||
self.choice = OpenChoice(self.job['block_name'], self.job['lmc_file'],
|
||||
auto_confirm=self.auto_confirm)
|
||||
show(self.choice)
|
||||
if show is not None:
|
||||
show(self.choice)
|
||||
elif self.auto_confirm:
|
||||
self.choice.choose('continue', origin='headless_opt_in')
|
||||
else:
|
||||
raise ValueError('PCB_OPEN_CONFIRMATION_REQUIRED')
|
||||
if (owner != self.owner or snapshot.hwnd != self.original.hwnd
|
||||
or _prompt_identity(snapshot) != _prompt_identity(self.original)):
|
||||
raise ValueError('PCB_OPEN_IDENTITY_CHANGED')
|
||||
@@ -181,7 +187,7 @@ class OpenController:
|
||||
if decision == 'continue':
|
||||
allowed = {target_pid, launcher_pid, worker_pid, self.job.get('supervisor_pid')}
|
||||
try:
|
||||
guard = (resource_guard(self.job, allowed, require_complete_proof=True) if self.auto_confirm
|
||||
guard = (resource_guard(self.job, allowed, require_complete_proof=True) if self.require_complete_proof
|
||||
else resource_guard(self.job, allowed))
|
||||
with guard:
|
||||
pass
|
||||
@@ -191,7 +197,7 @@ class OpenController:
|
||||
except QueueCancelled:
|
||||
decision, skipped_detail = 'cancel', '校验已取消。'
|
||||
except Exception as error:
|
||||
if not self.auto_confirm:
|
||||
if not self.require_complete_proof:
|
||||
raise
|
||||
decision, skipped_detail = 'skip', str(error)
|
||||
if validate_owner(self.job, target_pid, launcher_pid, worker_pid) != owner:
|
||||
|
||||
@@ -176,6 +176,9 @@ class MainWindow(QWidget):
|
||||
self.native_lm_verify_check.setChecked(native_lm_verify_enabled())
|
||||
self.native_lm_verify_check.setToolTip(
|
||||
'仅在 Win10 兼容测试时启用;默认仍使用已验证的 ReusableCircuit 直接流程。')
|
||||
self.auto_confirm_pcb_open_check = QCheckBox('无人应答时自动核验 PCB 读写占用')
|
||||
self.auto_confirm_pcb_open_check.setChecked(True)
|
||||
self.auto_confirm_pcb_open_check.setToolTip('普通校验中,3 秒后检查占用,确认可写后继续。关闭后默认跳过本项。')
|
||||
self.advanced_toggle = QToolButton(); self.advanced_toggle.setText('高级设置')
|
||||
self.advanced_toggle.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_TitleBarUnshadeButton))
|
||||
self.advanced_toggle.setCheckable(True); self.advanced_toggle.setChecked(False)
|
||||
@@ -185,6 +188,7 @@ class MainWindow(QWidget):
|
||||
advanced_layout.addRow('DMS 登录配置', self.dms_edit)
|
||||
advanced_layout.addRow('Mentor bin', self.mentor_bin_edit)
|
||||
advanced_layout.addRow('触发方式', self.native_lm_verify_check)
|
||||
advanced_layout.addRow('读写确认', self.auto_confirm_pcb_open_check)
|
||||
self.advanced_panel.setVisible(False)
|
||||
self.advanced_toggle.toggled.connect(self.advanced_panel.setVisible)
|
||||
self.cbb_table = QTableWidget(0, 4)
|
||||
@@ -543,7 +547,7 @@ class MainWindow(QWidget):
|
||||
current_library = _path_key(self.mentor_lmc_path or self.lmc_edit.text()) if self.lmc_edit.text().strip() else None
|
||||
notice = ('上次操作结果待复查,执行前将重新检查占用。'
|
||||
if self._management_library_unsafe(current_library) else '')
|
||||
notice = '旧表已失效,请重新读取中心库。' if self._stale_table else notice
|
||||
notice = '当前显示上次读取结果(已失效)· 请重新读取中心库。' if self._stale_table else notice
|
||||
self.library_notice.setText(notice)
|
||||
self.library_notice.setVisible(bool(notice))
|
||||
for widget in (self.lmc_edit, self.browse_button, self.load_button,
|
||||
@@ -1813,6 +1817,8 @@ class MainWindow(QWidget):
|
||||
requests = ([request for request in request_snapshot if request.block_name in names] if request_snapshot is not None
|
||||
else [replace(self._request(name), maintenance=maintenance, auto_repair=False) for name in names])
|
||||
if not requests: return
|
||||
auto_confirm = self.auto_confirm_pcb_open_check.isChecked()
|
||||
requests = [replace(request, auto_confirm_pcb_open=auto_confirm) for request in requests]
|
||||
library = requests[0].lmc_file
|
||||
if any(job.active and job.kind == 'verify' and job.requests == tuple(requests)
|
||||
and _path_key(job.context.library) == _path_key(library) for job in self._jobs.values()): return
|
||||
@@ -1839,7 +1845,7 @@ class MainWindow(QWidget):
|
||||
def action():
|
||||
from cbb_refresh_verify.verify_runner import read_library_flag_if_available, run_verify
|
||||
verify = self.verifier or (lambda req: run_verify(
|
||||
replace(req, auto_confirm_pcb_open=not maintenance),
|
||||
req,
|
||||
progress=lambda e: self._emit_job(job, 'event', e),
|
||||
flag_reader=read_library_flag_if_available,
|
||||
version_prompt=lambda choice: self._emit_job(job, 'version_choice', choice), stop=job.context.stop))
|
||||
|
||||
@@ -83,7 +83,9 @@ class VerifyRequest:
|
||||
maintenance: bool = False
|
||||
post_repair_proof: object | None = field(default=None, repr=False, compare=False)
|
||||
diagnostic_only: bool = False
|
||||
auto_confirm_pcb_open: bool = False
|
||||
# Explicit True/False selects ordinary Verify's complete access proof.
|
||||
# None preserves the manual confirmation policy for other callers.
|
||||
auto_confirm_pcb_open: bool | None = None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -1206,15 +1208,18 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
diagnostic_closing = True
|
||||
from .dialog_supervisor import DialogPollResult
|
||||
dialog_result = DialogPollResult(activity=False)
|
||||
if (version_prompt is not None and consent is None and dialog_agent is not None
|
||||
if ((version_prompt is not None or request.auto_confirm_pcb_open)
|
||||
and consent is None and dialog_agent is not None
|
||||
and not request.diagnostic_only and not request.native_lm_verify
|
||||
and not request.maintenance and not request.interactive_input
|
||||
and dialog_result.error_code == 'DATABASE_RECOVERY_REQUIRED'
|
||||
and dialog_result.snapshot is not None):
|
||||
from .pcb_open_consent import OpenController, exact_prompt
|
||||
if exact_prompt(dialog_result.snapshot):
|
||||
if open_controller is None:
|
||||
open_controller = OpenController(job, auto_confirm=(
|
||||
request.auto_confirm_pcb_open and not request.maintenance))
|
||||
open_controller = OpenController(
|
||||
job, auto_confirm=request.auto_confirm_pcb_open is True,
|
||||
require_complete_proof=request.auto_confirm_pcb_open is not None)
|
||||
dialog_result = open_controller.handle(dialog_result.snapshot, dialog_result.observed_snapshots,
|
||||
target_pid=target_pid, launcher_pid=launcher_pid, worker_pid=process.pid,
|
||||
show=version_prompt, perform=dialog_supervisor.backend.perform)
|
||||
|
||||
@@ -60,11 +60,13 @@ def test_supervisor_acknowledged_failed_open_can_close_empty_shell_with_address(
|
||||
|
||||
|
||||
@pytest.mark.parametrize('aliased', [False, True])
|
||||
def test_late_release_is_rechecked_before_later_same_library_item(tmp_path, monkeypatch, aliased):
|
||||
@pytest.mark.parametrize('first_status', ['FAIL', 'SKIPPED'])
|
||||
def test_late_release_is_rechecked_before_later_same_library_item(tmp_path, monkeypatch, aliased, first_status):
|
||||
library = tmp_path/'lib.lmc'
|
||||
calls, checks = [], []
|
||||
failed = verify_runner.VerifyResult('FAIL', stderr='bad database', safe_to_continue=False,
|
||||
evidence_path=tmp_path/'result.json', error_category='MENTOR_DATABASE_LOAD_FAILED')
|
||||
failed = verify_runner.VerifyResult(first_status, stderr='native operation declined', safe_to_continue=False,
|
||||
evidence_path=tmp_path/'result.json',
|
||||
error_category='PCB_OPEN_SKIPPED' if first_status == 'SKIPPED' else 'MENTOR_DATABASE_LOAD_FAILED')
|
||||
def verify(request):
|
||||
calls.append(request.block_name)
|
||||
return failed if request.block_name == 'Bad' else verify_runner.VerifyResult('PASS')
|
||||
@@ -78,7 +80,7 @@ def test_late_release_is_rechecked_before_later_same_library_item(tmp_path, monk
|
||||
results = verify_runner.run_batch([verify_runner.VerifyRequest(library, n, tmp_path)
|
||||
for n in ('Bad','Good')], verifier=verify)
|
||||
assert calls == ['Bad','Good']
|
||||
assert [r.status for r in results] == ['FAIL','PASS']
|
||||
assert [r.status for r in results] == [first_status,'PASS']
|
||||
assert results[0].safe_to_continue
|
||||
|
||||
|
||||
|
||||
@@ -228,6 +228,37 @@ def test_unattended_readwrite_checks_actual_shared_database_handle(tmp_path, mon
|
||||
assert not resumed.error_code
|
||||
assert (evidence/'pcb-open-resource-proof.json').is_file()
|
||||
|
||||
from cbb_refresh_verify import native_repair
|
||||
address = work/'database/cdbsvr/sAddress.adr'
|
||||
address.parent.mkdir()
|
||||
address.write_text('recorded address')
|
||||
verdict = 'NOT_IN_USE'
|
||||
inspected = []
|
||||
|
||||
def inspect(target, root, **kwargs):
|
||||
assert kwargs['inspection_only'] is True
|
||||
assert target.project == project and target.database == address.parent.parent
|
||||
inspected.append(target.database)
|
||||
output = (f'Loading project file [{project}].\nChecking if project is in use.\n'
|
||||
+ ("Project is not in use. Full iCDB Project Backup's functionality is available.\n"
|
||||
"Backup information loaded correctly." if verdict == 'NOT_IN_USE' else 'Project is in use.'))
|
||||
return dict(status=verdict, repair_required=False, inspection_only=True,
|
||||
repair_requested=False, native_pid=100, native_exit_code=0,
|
||||
native_identity=dict(pid=100, created_handle=1, image='iCDBProjectBackup.exe',
|
||||
owner_sid='test', session_id=1),
|
||||
release={'native_exited': True}, project=str(project),
|
||||
database=str(target.database), output=output)
|
||||
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', inspect)
|
||||
unoccupied, _ = run('address-checked-unoccupied', 6)
|
||||
assert not unoccupied.error_code and inspected == [address.parent.parent]
|
||||
verdict = 'IN_USE'
|
||||
occupied, _ = run('address-checked-occupied', 7)
|
||||
assert occupied.error_code == 'PCB_OPEN_SKIPPED' and 'PCB_OPEN_DATABASE_IN_USE' in occupied.detail
|
||||
assert inspected == [address.parent.parent]*2
|
||||
assert address.read_text() == 'recorded address'
|
||||
address.unlink()
|
||||
|
||||
project.write_text('KEY PCBDesignPath "PCB/A.pcb"\nKEY iCDBDir "../../../outside"\n')
|
||||
unbound, _ = run('wrong-project-database', 7)
|
||||
assert 'iCDBDir' in unbound.detail
|
||||
@@ -261,3 +292,31 @@ def test_stop_during_receipt_never_sends_native_yes(tmp_path, monkeypatch):
|
||||
controller.handle(snapshot(), (snapshot(),), **options)
|
||||
shown[0].choose('continue')
|
||||
assert controller.handle(snapshot(), (snapshot(),), **options).error_code == 'USER_CANCELLED'
|
||||
|
||||
|
||||
def test_headless_opt_in_checks_resources_without_presenting_dialog(tmp_path, monkeypatch):
|
||||
import json
|
||||
from cbb_refresh_verify import pcb_open_consent as consent
|
||||
|
||||
monkeypatch.setattr(consent, 'validate_owner', lambda *_: {'target': 'bound'})
|
||||
checked = []
|
||||
|
||||
def guard(_, __, *, require_complete_proof):
|
||||
checked.append(require_complete_proof)
|
||||
return nullcontext()
|
||||
|
||||
monkeypatch.setattr(consent, 'resource_guard', guard)
|
||||
controller = consent.OpenController(dict(root=str(tmp_path), block_name='A', lmc_file='lib.lmc',
|
||||
project='A.prj', pcb='A.pcb', desktop='CbbVerify_test'), auto_confirm=True)
|
||||
actions = []
|
||||
|
||||
def perform(_, action, phase):
|
||||
actions.append(action['target']['control_id'])
|
||||
return SimpleNamespace(error_code='', accepted_controls=tuple(actions), detail='', channel='win32_button_click')
|
||||
|
||||
result = controller.handle(snapshot(), (snapshot(),), target_pid=20, launcher_pid=10, worker_pid=5,
|
||||
show=None, perform=perform)
|
||||
assert not result.error_code
|
||||
assert checked == [True] and actions == [6]
|
||||
receipt = json.loads((tmp_path/'pcb-open-user-choice.json').read_text(encoding='utf-8'))
|
||||
assert receipt['decision_origin'] == 'headless_opt_in'
|
||||
@@ -166,3 +166,17 @@ def test_retained_mapping_logs_context_and_confirmed_release_guidance(batch_cli,
|
||||
assert 'Z:' in notice and r'\\server\share' in notice
|
||||
assert '释放残留会话' in notice and '确认' in notice
|
||||
assert 'net use' not in notice.lower()
|
||||
|
||||
|
||||
def test_batch_cli_can_enable_verified_pcb_open(batch_cli, monkeypatch):
|
||||
app, runner, _, _, _ = batch_cli
|
||||
received = []
|
||||
|
||||
def run(requests, **kwargs):
|
||||
received.extend(request.auto_confirm_pcb_open for request in requests)
|
||||
return [VerifyResult('PASS') for _ in requests]
|
||||
|
||||
monkeypatch.setattr(runner, 'run_batch', run)
|
||||
assert app.main(['--batch-lmc', 'lib.lmc', '--block', 'One']) == 0
|
||||
assert app.main(['--batch-lmc', 'lib.lmc', '--block', 'One', '--auto-confirm-pcb-open']) == 0
|
||||
assert received == [False, True]
|
||||
@@ -320,3 +320,20 @@ def test_double_click_shows_complete_skipped_reason(qtbot, tmp_path, monkeypatch
|
||||
qtbot.mouseClick(copy, Qt.LeftButton)
|
||||
assert QApplication.clipboard().text() == reason
|
||||
dialog.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('enabled', [False, True])
|
||||
def test_pcb_open_option_is_bound_only_to_ordinary_verify(qtbot, tmp_path, monkeypatch, enabled):
|
||||
requests = []
|
||||
|
||||
def verify(request):
|
||||
requests.append(request)
|
||||
return VerifyResult('SKIPPED')
|
||||
|
||||
window = load_window(qtbot, tmp_path, monkeypatch, verifier=verify)
|
||||
window.auto_confirm_pcb_open_check.setChecked(enabled)
|
||||
assert window._request('Beta').auto_confirm_pcb_open is None
|
||||
window._run(['Beta'])
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert len(requests) == 1
|
||||
assert requests[0].auto_confirm_pcb_open is enabled
|
||||
Reference in new issue
Block a user