e4981aa2f6
AGENTS.md stopped being the store of record for build steps, Python env, hardware pins, doc conventions, log cost and task ownership. Those facts already live in docs, skills and role files; the entry file now only points at them. This commit moves every reference that used to name the entry file to the authoritative landing point, so a reader who follows a link arrives at the fact instead of at a sentence that no longer exists. What changed is links and prose, not behaviour. Code, scripts and tests only have comment and docstring lines touched; the only non-comment edit in the whole changeset is one note string inside the generated pin table JSON, and its generator was changed in the same step so the two stay byte-identical. New landing points created before the references were retargeted: - The console single-writer log design doc, section 7.1, is now the single authority for log cost: about 90 B flash and 216 B stack per DBG_ line, and the rule that deep call chains must predefine DBG_LINE_BUF_MAX. It also carries the full list of the twelve translation units that have tightened it, plus the grep command that decides the truth if the list and the code ever disagree. - The document writing standard, section 2, now holds the BOM list. - keil-build skill gains an exit code table: 0 success, 1 build failure, 2 BuildEnvError, 3 usage, 4 build lock held. This corrects a belief that was never actually written down anywhere: exit 2 does not simply mean environment error, argparse also exits 2 and the wrapper script was remapped so the two no longer collide. Regenerated and checked byte for byte: - The end-to-end architecture SVG in docs/images from its generator. - tools/netlist_semantics/pinout_kb.json from gen_kb.py. Both are idempotent; running the generators again produces no diff. Deliberately not touched, because machines read them: - scripts/check_bom_drift.py joins every line containing BOM and asserts four paths are present, so the entry file BOM line must stay one line. - scripts/gen_task_table.py reads the TASK_TABLE anchors directly. - scripts/rename_maps and scripts/archive keep their historical wording; they describe what happened, not what is true now. Verified: doc links report the same six pre-existing findings as the base commit and no new ones, generated-fresh passes, bom drift is clean across 101 files, and AGENTS.md itself is unchanged in this commit.
59 lines
3.0 KiB
Python
59 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""NET 层挂起 recv / 挂起 send(net_pending)主机侧纯逻辑单元测试运行器(纯标准库)。
|
||
|
||
做什么:
|
||
用本机 MSVC 编译 test/host/net_pending/net_pending_test.c(以 #include 纳入生产源
|
||
Drivers/BSP/NET/net_pending.c 与共享假芯片 test/host/common/ch395f_fake.c),在 PC
|
||
上离线验证两条挂起队列:注册闸门、错误码经任务通知值回传、收数据到达/截断/超时、
|
||
会话塌掉的四条收尾分支、settle_close 语义、发送侧分块上限与停滞判定与 deadline
|
||
续期。工具链与判定委托 test/host/common/unit_test_harness.py。
|
||
|
||
为什么要主机侧单测(而不是只用台架):
|
||
本模块的核心契约是"跨上下文回传"——net_msg_t 按值拷入队列,netTask 改的是自己那份
|
||
副本,错误码只能搭任务通知值回来(也绝不能给 net_msg_t 加回传字段,否则调用方读到
|
||
栈垃圾)。台架根本读不到通知值,所以这条契约在真机上只表现为"偶发拿到 0 或正数却
|
||
不知道为何"。另外:收尾四条分支少一条就是"对端已断而我方任务还挂着"或"最后一包数据
|
||
被丢掉";发送分块上限踩错会写爆芯片 FIFO;deadline 续期写错会把 FTP 大文件在传输
|
||
中途掐死——这些都要能精确数着字节与毫秒测。
|
||
|
||
桩的边界:net_pending.h / net_types.h / net_config.h / net_listener.h 用真实头
|
||
(TaskHandle_t 入参与 NET_PENDING_REGISTERED、NET_SEND_TIMEOUT_MS、net_listener_req_t
|
||
一改即编译期报错);net_socket.h 是桩(net_set_errno 与 NET_ERR_RETURN_1 照抄真实头
|
||
同名宏);ch395f.h 只转发到共享假芯片(缓冲尺寸宏链与真实头同构转抄,
|
||
NET_SEND_CHUNK_MAX 因此是真值 1024);FreeRTOS.h / task.h 是宿主等价壳,但把
|
||
xTaskNotify 做成**可观测**假件——没有它,本模块最重要的那条契约根本无法验证。
|
||
|
||
用法(仓库根目录):
|
||
python test/host/net_pending/run_unit_test.py
|
||
|
||
退出码:0=PASS / 1=测试失败 / 2=环境错误。
|
||
|
||
设计依据:模块约定(错误码经任务通知值回传,见 docs/网络/网络自愈架构设计.md §4.10)、
|
||
docs/网络/Net层阻塞模型架构设计.md、docs/测试说明/单元测试/主机单测覆盖率口径.md §9
|
||
创建日期:2026-10-23
|
||
"""
|
||
import os
|
||
import sys
|
||
|
||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
|
||
sys.path.insert(0, os.path.join(ROOT, "test", "host", "common"))
|
||
|
||
from unit_test_harness import TestBuild, run_host_unit_test # noqa: E402
|
||
|
||
BUILD = TestBuild(
|
||
name="NET Pending Tests",
|
||
src=os.path.join(HERE, "net_pending_test.c"),
|
||
include_dirs=[
|
||
os.path.join(HERE, "stub"),
|
||
os.path.join(ROOT, "test", "host", "common"),
|
||
os.path.join(ROOT, "Drivers", "BSP", "NET"),
|
||
HERE,
|
||
],
|
||
summary_marker="=== NET Pending Tests:",
|
||
)
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(run_host_unit_test(BUILD))
|