test(host): 断言字面量统一纯 ASCII,30 文件 1535 行

用户裁定「统一」。口径就是 AGENTS 铁律:字符串字面量必须纯 ASCII
(无 BOM 文件里奇数个汉字会吞掉结束引号,偶数才侥幸通过),中文只写注释。
四名队友按目录分四组并行、写范围互斥:net_socket 418 行(6 文件)、
console_log/sys_log_mcu/soe_store/cfg_file_store_mcu 268 行(4 文件)、
11 个存量套件 404 行 + adc_input 89 行、iec104 与 lftpd 与 NET 四套等 356 行
(9 文件)。runner 的 .py 文档串不在口径内(Python 源不经 ARMCC 代码页)。

两套口径必须分清:粗口径(按行切引号)普查 = 34 文件 / 1,552 行;严格口径
(状态机剥掉块/行注释与字符常量后再取字符串字面量)= 30 文件 / 1,535 行。
差值那 4 个文件的命中全在注释里(ns_peers.c、net_socket/stub/ns_rtos.h、
common/ch395f_fake.h、common/fatfs_fake.c)——按口径一处都不该改,改了等于
把中文从注释里搬走、正好违背口径。粗口径绝不能当交付判据,否则要么白改
注释、要么留下「这行为什么没改」的悬案。

Lead 独立终检(不采信自报)五条硬判据,结果 30 文件漂移 0:① 每文件 TC 号
集合与 HEAD 逐字相同 ② 断言宏调用点数不变 ③ 行数与 HEAD 完全相等(专抓
整文件回写把尾部含 main() 吃掉的截断,第 1 轮真发生过两次)④ 剥注释后代码区
非 ASCII 字符 = 0 ⑤ 字节卫生(BOM 与 HEAD 一致、无 CR、无 U+FFFD、单尾换行)。
另用「逐行把字面量整体替换成空串后与 HEAD 必须逐行相等」机械证明只改了字面量;
各套 --module 覆盖率与断言数逐字不变(net_socket 887/889·53/53、console_log
199/200·16/16、sys_log_mcu 324/326·13/13、adc_input 103/103、sys_clock 100/100)
→ 生产码零改动,基线不需重登。

闸拦下一处真实回归(我的验收器没抓到):ns_s6_edges.c 翻译时把一个上一轮
已整改成平实描述的编号又写回了 CHECK 标签。原因很清楚:「只改字面量」并不
等于「只改无害内容」,标签里完全可以带进未登记族的编号形态;而 Lead 的自动
验收器只比对了 TC 形 id 集合,未覆盖 L/E/N/S/TRAP 等族。教训:批量改标签的
守卫必须加一条「新串不得出现任何已登记前缀族之外的编号形态」,且结构不变式
只覆盖自己想到的维度时不能替代真闸。
Lead 自查另清掉 126 处写坏的反斜杠(JS→Python 转义层数翻倍,把 markdown
反引号写成反斜杠+反引号),恰好发生在记录这条教训的那一节里。

文档:docs/测试说明/主机单测覆盖率口径.md §9 新增「第 2 轮」小节(两套口径对照
表、五条终检判据、六条手法含「转换说明符序列必须逐位相同」取代「禁止裸 %」、
三条协作纪律含先改板再派工与临时文件带组前缀、后续项 3 条)+ 变更记录一行。

后续项(本轮不做):把剥注释词法扫描器收进 scripts 当门禁(需用户点头并先定
test/ 是否纳入 coding-standard);iec104 的简写编号归族(牵 id_registry,
不能顺手做);替换器加「编号形态白名单」校验。

gate: pre-commit run --all-files -> 39 hooks, 37 Passed; failed = mem-numbers +
mem-budget(受管快照与本树 .map 的漂移,属第 1 轮生产码改动的遗留,非本批
增量)。本批只碰 test/host/**,不进 Keil 编译面也不进模拟器 CMake,**RAM/Flash
增量 = 0**;实测水位 RW_IRAM1 57.4%、RW_CCM 87.9%,均低于 92% 红线。
id-check 0 台账外新账(可判定 84.63% > 基线 82.6%);test-coverage 33/33 全绿;
cppcheck / coding-standard / bsp-err / layer-deps / doc-links 全 Passed。
按仓内分支约定 --no-verify 提交,台账 --write 回填留待主工作树合并后。
This commit is contained in:
2026-10-24 20:57:46 +08:00
parent 5a806d8a26
commit 924ac3d428
31 changed files with 1626 additions and 1542 deletions
+7 -7
View File
@@ -118,7 +118,7 @@ void ns_rtos_post_notify(TaskHandle_t to, uint32_t v)
return;
}
}
printf("FATAL: ns_rtos_post_notify 收到未知任务句柄\n");
printf("FATAL: ns_rtos_post_notify got an unknown task handle\n");
exit(2);
}
@@ -185,7 +185,7 @@ osStatus_t osDelay(uint32_t ticks)
g_ns_tick += ticks;
if (++guard > 20000) {
printf("FATAL: osDelay 跑飞(%d 次)—— 等待条件永不满足\n", guard);
printf("FATAL: osDelay runaway (%d calls) - the wait condition is never met\n", guard);
exit(2);
}
if (guard > 0) {
@@ -212,7 +212,7 @@ BaseType_t xTaskNotify(TaskHandle_t xTaskToNotify, uint32_t ulValue,
g_ns_notify_last_val = ulValue;
g_ns_notify_last_to = xTaskToNotify;
if (p == NULL) {
printf("FATAL: xTaskNotify 收到未知任务句柄\n");
printf("FATAL: xTaskNotify got an unknown task handle\n");
exit(2);
}
p->val = ulValue;
@@ -228,7 +228,7 @@ BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry,
ns_notify_slot_t *p = slot_of(g_ns_cur_task);
if (p == NULL) {
printf("FATAL: xTaskNotifyWait 当前任务句柄未知\n");
printf("FATAL: xTaskNotifyWait current task handle unknown\n");
exit(2);
}
if (pulNotificationValue != NULL) {
@@ -249,7 +249,7 @@ BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry,
/* 阻塞分支:这就是"睡到 netTask 回执"的调度点 → 驱动一轮 netTask 再拾取 */
g_ns_block_waits++;
if (g_ns_pump == NULL) {
printf("FATAL: 走到阻塞等待但测试没装 pump 钩子\n");
printf("FATAL: reached the blocking wait but the test installed no pump hook\n");
exit(2);
}
{
@@ -267,7 +267,7 @@ BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry,
}
}
if (p->pending == 0) {
printf("FATAL: 阻塞等待 %d 轮仍无回执(该通知的没通知 = 真机必挂死)\n", rounds);
printf("FATAL: blocking wait still got no receipt after %d rounds (a missing notify would hang real hardware)\n", rounds);
exit(2);
}
}
@@ -326,7 +326,7 @@ GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
g_ns_on_poll(); /* 并发事件注入点(在时间推进之后,超时判定才量得到) */
}
if (g_ns_poll_calls > 400000U) {
printf("FATAL: net_poll 轮询 %lu 次仍未收敛(等待条件永不满足)\n",
printf("FATAL: net_poll still not converged after %lu rounds (wait condition never met)\n",
(unsigned long)g_ns_poll_calls);
exit(2);
}