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:
@@ -418,31 +418,31 @@ static int delays_all(uint32_t v, int n) {
|
||||
static void tc_delay_fed(void) {
|
||||
fakes_reset();
|
||||
time_sync_delay_fed(0U);
|
||||
CHECK((s_beat_calls == 0) && (s_delay_calls == 0), "TC-TIMESYNC-001 delay_fed(0) 不睡眠不喂狗");
|
||||
CHECK((s_beat_calls == 0) && (s_delay_calls == 0), "TC-TIMESYNC-001 delay_fed(0) neither sleeps nor beats");
|
||||
|
||||
fakes_reset();
|
||||
time_sync_delay_fed(50U);
|
||||
CHECK((s_beat_calls == 1) && (s_delay_calls == 1) && (s_delays[0] == 50U),
|
||||
"TC-TIMESYNC-002 delay_fed(50) = 1 片 50ms + 1 次心跳");
|
||||
"TC-TIMESYNC-002 delay_fed(50) = one 50 ms slice + 1 beat");
|
||||
|
||||
fakes_reset();
|
||||
time_sync_delay_fed(120U);
|
||||
CHECK((s_beat_calls == 3) && (s_delay_calls == 3), "TC-TIMESYNC-003 delay_fed(120) 切成 3 片");
|
||||
CHECK((s_beat_calls == 3) && (s_delay_calls == 3), "TC-TIMESYNC-003 delay_fed(120) splits into 3 slices");
|
||||
CHECK((s_delays[0] == 50U) && (s_delays[1] == 50U) && (s_delays[2] == 20U),
|
||||
"TC-TIMESYNC-003b 片长 50/50/20(末片为余数)");
|
||||
"TC-TIMESYNC-003b slice lengths 50/50/20 (last slice is the remainder)");
|
||||
|
||||
fakes_reset();
|
||||
time_sync_delay_fed(2000U);
|
||||
CHECK((s_delay_calls == 40) && (s_beat_calls == 40) && delays_all(50U, 40),
|
||||
"TC-TIMESYNC-004 delay_fed(2000) = 40 片 × 50ms,每片喂一次心跳");
|
||||
"TC-TIMESYNC-004 delay_fed(2000) = 40 slices x 50 ms, one beat per slice");
|
||||
|
||||
fakes_reset();
|
||||
time_sync_delay_fed(49U);
|
||||
CHECK((s_beat_calls == 1) && (s_delays[0] == 49U), "TC-TIMESYNC-005 不足一片(49ms)单片处理");
|
||||
CHECK((s_beat_calls == 1) && (s_delays[0] == 49U), "TC-TIMESYNC-005 less than one slice (49 ms) handled as a single slice");
|
||||
|
||||
fakes_reset();
|
||||
time_sync_delay_fed(30000U);
|
||||
CHECK(s_delay_calls == 600, "TC-TIMESYNC-006 总预算 30s = 600 片(片长上限恒 50ms)");
|
||||
CHECK(s_delay_calls == 600, "TC-TIMESYNC-006 total budget 30 s = 600 slices (slice cap is always 50 ms)");
|
||||
}
|
||||
|
||||
/* ===================== TC-TIMESYNC-010..015:open_listener ===================== */
|
||||
@@ -451,13 +451,13 @@ static void tc_open_listener(void) {
|
||||
fakes_reset();
|
||||
{
|
||||
int s = time_sync_open_listener();
|
||||
CHECK(s == 5, "TC-TIMESYNC-010 open_listener 成功返回 socket 描述符");
|
||||
CHECK(s == 5, "TC-TIMESYNC-010 open_listener success returns the socket descriptor");
|
||||
CHECK((s_socket_calls == 1) && (s_bind_calls == 1) && (s_listen_calls == 1),
|
||||
"TC-TIMESYNC-010b socket / bind / listen 各一次");
|
||||
CHECK(s_htons_last == (uint16_t)TIME_SYNC_PORT, "TC-TIMESYNC-010c 端口经 net_htons(8888)");
|
||||
CHECK(s_bind_port == net_htons((uint16_t)TIME_SYNC_PORT), "TC-TIMESYNC-010d sin_port 为网络序");
|
||||
"TC-TIMESYNC-010b socket / bind / listen called once each");
|
||||
CHECK(s_htons_last == (uint16_t)TIME_SYNC_PORT, "TC-TIMESYNC-010c port goes through net_htons(8888)");
|
||||
CHECK(s_bind_port == net_htons((uint16_t)TIME_SYNC_PORT), "TC-TIMESYNC-010d sin_port is in network byte order");
|
||||
CHECK(s_bind_family == (uint16_t)NET_AF_INET, "TC-TIMESYNC-010e sin_family = NET_AF_INET");
|
||||
CHECK(s_delay_calls == 0, "TC-TIMESYNC-010f 成功路径无退避延时");
|
||||
CHECK(s_delay_calls == 0, "TC-TIMESYNC-010f no backoff delay on the success path");
|
||||
}
|
||||
|
||||
fakes_reset();
|
||||
@@ -465,10 +465,10 @@ static void tc_open_listener(void) {
|
||||
s_bind_seq_n = 1;
|
||||
{
|
||||
int s = time_sync_open_listener();
|
||||
CHECK(s == 5, "TC-TIMESYNC-011 bind 失败一次后重试成功");
|
||||
CHECK((s_close_calls == 1) && (s_close_socks[0] == 5), "TC-TIMESYNC-011b bind 失败关闭该 socket");
|
||||
CHECK(s_delay_calls == 40, "TC-TIMESYNC-011c bind 失败退避 2000ms(40 片)");
|
||||
CHECK(g_tstest_err_count == 1, "TC-TIMESYNC-011d bind 失败留痕 DBG_ERROR");
|
||||
CHECK(s == 5, "TC-TIMESYNC-011 bind succeeds on retry after one failure");
|
||||
CHECK((s_close_calls == 1) && (s_close_socks[0] == 5), "TC-TIMESYNC-011b bind failure closes that socket");
|
||||
CHECK(s_delay_calls == 40, "TC-TIMESYNC-011c bind failure backs off 2000 ms (40 slices)");
|
||||
CHECK(g_tstest_err_count == 1, "TC-TIMESYNC-011d bind failure leaves a DBG_ERROR trace");
|
||||
}
|
||||
|
||||
fakes_reset();
|
||||
@@ -476,19 +476,19 @@ static void tc_open_listener(void) {
|
||||
s_listen_seq_n = 1;
|
||||
{
|
||||
int s = time_sync_open_listener();
|
||||
CHECK(s == 5, "TC-TIMESYNC-012 listen 失败一次后重试成功");
|
||||
CHECK((s_close_calls == 1) && (s_close_socks[0] == 5), "TC-TIMESYNC-012b listen 失败关闭该 socket");
|
||||
CHECK(s_delay_calls == 40, "TC-TIMESYNC-012c listen 失败退避 2000ms");
|
||||
CHECK(s == 5, "TC-TIMESYNC-012 listen succeeds on retry after one failure");
|
||||
CHECK((s_close_calls == 1) && (s_close_socks[0] == 5), "TC-TIMESYNC-012b listen failure closes that socket");
|
||||
CHECK(s_delay_calls == 40, "TC-TIMESYNC-012c listen failure backs off 2000 ms");
|
||||
}
|
||||
|
||||
fakes_reset();
|
||||
s_socket_default = -1;
|
||||
{
|
||||
int s = time_sync_open_listener();
|
||||
CHECK(s == -1, "TC-TIMESYNC-013 socket 连续失败 -> 返回 -1");
|
||||
CHECK(s_socket_calls == 5, "TC-TIMESYNC-013b 重试上限 5 次");
|
||||
CHECK(g_tstest_err_count == 5, "TC-TIMESYNC-013c 每次失败各留痕一条(5 条 DBG_ERROR)");
|
||||
CHECK(s_delay_calls == 50, "TC-TIMESYNC-013d 每次失败退避 500ms(5 × 10 片)");
|
||||
CHECK(s == -1, "TC-TIMESYNC-013 socket keeps failing -> returns -1");
|
||||
CHECK(s_socket_calls == 5, "TC-TIMESYNC-013b retry cap is 5 attempts");
|
||||
CHECK(g_tstest_err_count == 5, "TC-TIMESYNC-013c every failure leaves its own trace (5 DBG_ERROR lines)");
|
||||
CHECK(s_delay_calls == 50, "TC-TIMESYNC-013d every failure backs off 500 ms (5 x 10 slices)");
|
||||
}
|
||||
|
||||
fakes_reset();
|
||||
@@ -498,16 +498,16 @@ static void tc_open_listener(void) {
|
||||
s_socket_seq_n = 3;
|
||||
{
|
||||
int s = time_sync_open_listener();
|
||||
CHECK(s == 9, "TC-TIMESYNC-014 第 3 次重试成功并返回新描述符");
|
||||
CHECK(s_socket_calls == 3, "TC-TIMESYNC-014b 恰好尝试 3 次");
|
||||
CHECK(s_delay_calls == 20, "TC-TIMESYNC-014c 两次失败退避 500ms × 2");
|
||||
CHECK(s == 9, "TC-TIMESYNC-014 3rd retry succeeds and returns the new descriptor");
|
||||
CHECK(s_socket_calls == 3, "TC-TIMESYNC-014b exactly 3 attempts");
|
||||
CHECK(s_delay_calls == 20, "TC-TIMESYNC-014c two failures back off 500 ms x 2");
|
||||
}
|
||||
|
||||
fakes_reset();
|
||||
s_socket_default = -1;
|
||||
(void)time_sync_open_listener();
|
||||
CHECK(s_beat_calls == 55, "TC-TIMESYNC-015 每轮重试(5) + 每片延时(50) 各喂一次心跳");
|
||||
CHECK(s_beat_id_bad == 0, "TC-TIMESYNC-015b 心跳位恒为 TASK_WD_TIMESYNC");
|
||||
CHECK(s_beat_calls == 55, "TC-TIMESYNC-015 every retry round (5) + every delay slice (50) beats once");
|
||||
CHECK(s_beat_id_bad == 0, "TC-TIMESYNC-015b the beat bit is always TASK_WD_TIMESYNC");
|
||||
}
|
||||
|
||||
/* ===================== TC-TIMESYNC-020..029:handle_conn =====================
|
||||
@@ -526,13 +526,13 @@ static void tc_handle_conn(void) {
|
||||
s_recv_seq_n = 1;
|
||||
s_tick = 100U;
|
||||
time_sync_handle_conn(7);
|
||||
CHECK(s_set_unix_calls == 1, "TC-TIMESYNC-020 TIME 包一次收齐 -> 更新墙钟一次");
|
||||
CHECK(s_set_unix_last == 0x12345678u, "TC-TIMESYNC-020b epoch 按大端解析");
|
||||
CHECK((s_recv_calls == 1) && (s_recv_len_log[0] == 16), "TC-TIMESYNC-020c 首次请求 16 字节");
|
||||
CHECK(s_recv_to_log[0] == 50U, "TC-TIMESYNC-020d 单次等待片长 = 50ms");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-020e 处理完**不**关闭连接(close 交外层 conn!=ls 分支)");
|
||||
CHECK(s_drop_calls == 0, "TC-TIMESYNC-020g 成功会话不拆(drop 只用于放弃路径)");
|
||||
CHECK(g_tstest_info_count == 1, "TC-TIMESYNC-020f 留痕 wall clock updated");
|
||||
CHECK(s_set_unix_calls == 1, "TC-TIMESYNC-020 TIME packet in one shot -> wall clock updated once");
|
||||
CHECK(s_set_unix_last == 0x12345678u, "TC-TIMESYNC-020b epoch parsed big-endian");
|
||||
CHECK((s_recv_calls == 1) && (s_recv_len_log[0] == 16), "TC-TIMESYNC-020c the first request asks for 16 bytes");
|
||||
CHECK(s_recv_to_log[0] == 50U, "TC-TIMESYNC-020d single wait slice length = 50 ms");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-020e after handling, the connection is **not** closed (close is the outer conn!=ls branch job)");
|
||||
CHECK(s_drop_calls == 0, "TC-TIMESYNC-020g a successful session is not torn down (drop is only for give-up paths)");
|
||||
CHECK(g_tstest_info_count == 1, "TC-TIMESYNC-020f leaves the wall clock updated trace");
|
||||
|
||||
/* 2) 分段送达:4 + 4 */
|
||||
fakes_reset();
|
||||
@@ -541,11 +541,11 @@ static void tc_handle_conn(void) {
|
||||
recv_set(1, 4, pkt + 4, 4, 10U);
|
||||
s_recv_seq_n = 2;
|
||||
time_sync_handle_conn(3);
|
||||
CHECK((s_set_unix_calls == 1) && (s_set_unix_last == 10u), "TC-TIMESYNC-021 分段送达累积后解析正确");
|
||||
CHECK(s_recv_calls == 2, "TC-TIMESYNC-021b 读了两次");
|
||||
CHECK((s_set_unix_calls == 1) && (s_set_unix_last == 10u), "TC-TIMESYNC-021 pieces accumulate and then parse correctly");
|
||||
CHECK(s_recv_calls == 2, "TC-TIMESYNC-021b read twice");
|
||||
CHECK((s_recv_len_log[0] == 16) && (s_recv_len_log[1] == 12),
|
||||
"TC-TIMESYNC-021c 第二次只请求剩余 12 字节");
|
||||
CHECK((s_recv_to_log[0] == 50U) && (s_recv_to_log[1] == 50U), "TC-TIMESYNC-021d 每片 50ms(预算充裕)");
|
||||
"TC-TIMESYNC-021c the second request asks only for the remaining 12 bytes");
|
||||
CHECK((s_recv_to_log[0] == 50U) && (s_recv_to_log[1] == 50U), "TC-TIMESYNC-021d 50 ms per slice (budget is ample)");
|
||||
|
||||
/* 3) 16 字节一次到达(只取前 8) */
|
||||
fakes_reset();
|
||||
@@ -553,8 +553,8 @@ static void tc_handle_conn(void) {
|
||||
recv_set(0, 16, pkt, 16, 0U);
|
||||
s_recv_seq_n = 1;
|
||||
time_sync_handle_conn(4);
|
||||
CHECK((s_set_unix_calls == 1) && (s_set_unix_last == 5u), "TC-TIMESYNC-022 超长包只取前 8 字节");
|
||||
CHECK(s_recv_calls == 1, "TC-TIMESYNC-022b 一次读够即停");
|
||||
CHECK((s_set_unix_calls == 1) && (s_set_unix_last == 5u), "TC-TIMESYNC-022 an over-long packet only takes the first 8 bytes");
|
||||
CHECK(s_recv_calls == 1, "TC-TIMESYNC-022b stops as soon as one read is enough");
|
||||
|
||||
/* 4) 前缀不是 TIME */
|
||||
fakes_reset();
|
||||
@@ -569,23 +569,23 @@ static void tc_handle_conn(void) {
|
||||
recv_set(0, 8, pkt, 8, 0U);
|
||||
s_recv_seq_n = 1;
|
||||
time_sync_handle_conn(4);
|
||||
CHECK(s_set_unix_calls == 0, "TC-TIMESYNC-023 非 TIME 前缀不更新墙钟");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-023b 非 TIME 前缀也不关闭连接");
|
||||
CHECK(s_set_unix_calls == 0, "TC-TIMESYNC-023 a non-TIME prefix does not update the wall clock");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-023b a non-TIME prefix also does not close the connection");
|
||||
|
||||
/* 5) 对端关闭(EOF) */
|
||||
fakes_reset();
|
||||
recv_set(0, 0, NULL, 0, 0U);
|
||||
s_recv_seq_n = 1;
|
||||
time_sync_handle_conn(6);
|
||||
CHECK((s_set_unix_calls == 0) && (s_recv_calls == 1), "TC-TIMESYNC-024 对端关闭(EOF)立即退出不解析");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-024b EOF 也不关闭连接(net 层 auto_relisten 收口监听)");
|
||||
CHECK((s_set_unix_calls == 0) && (s_recv_calls == 1), "TC-TIMESYNC-024 peer close (EOF) exits immediately without parsing");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-024b EOF also does not close the connection (net-layer auto_relisten re-arms the listener)");
|
||||
|
||||
/* 6) 真错误 */
|
||||
fakes_reset();
|
||||
recv_set(0, -1, NULL, 0, 0U);
|
||||
s_recv_seq_n = 1;
|
||||
time_sync_handle_conn(6);
|
||||
CHECK((s_recv_calls == 1) && (s_set_unix_calls == 0), "TC-TIMESYNC-025 真错误立即退出不解析");
|
||||
CHECK((s_recv_calls == 1) && (s_set_unix_calls == 0), "TC-TIMESYNC-025 a real error exits immediately without parsing");
|
||||
|
||||
/* 7) 4 字节后 EOF */
|
||||
fakes_reset();
|
||||
@@ -594,27 +594,27 @@ static void tc_handle_conn(void) {
|
||||
recv_set(1, 0, NULL, 0, 0U);
|
||||
s_recv_seq_n = 2;
|
||||
time_sync_handle_conn(6);
|
||||
CHECK(s_set_unix_calls == 0, "TC-TIMESYNC-026 不足 8 字节不解析");
|
||||
CHECK(s_recv_calls == 2, "TC-TIMESYNC-026b 继续等待后续字节");
|
||||
CHECK(s_set_unix_calls == 0, "TC-TIMESYNC-026 fewer than 8 bytes are not parsed");
|
||||
CHECK(s_recv_calls == 2, "TC-TIMESYNC-026b keeps waiting for the remaining bytes");
|
||||
|
||||
/* 8) 30s 预算耗尽 */
|
||||
fakes_reset();
|
||||
recv_set(0, -2, NULL, 0, 30000U);
|
||||
s_recv_seq_n = 1;
|
||||
time_sync_handle_conn(6);
|
||||
CHECK(s_recv_calls == 1, "TC-TIMESYNC-027 预算耗尽后不再读(只读 1 次)");
|
||||
CHECK(g_tstest_info_count == 1, "TC-TIMESYNC-027b 留痕 no TIME packet in 30s, drop conn");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-027c 预算耗尽也不关闭连接");
|
||||
CHECK(s_drop_calls == 1, "TC-TIMESYNC-027d 预算耗尽主动拆会话(E-02 收口:net_drop_conn 拆连接保监听)");
|
||||
CHECK(s_recv_calls == 1, "TC-TIMESYNC-027 no more reads once the budget is exhausted (only 1 read)");
|
||||
CHECK(g_tstest_info_count == 1, "TC-TIMESYNC-027b leaves the no TIME packet in 30s, drop conn trace");
|
||||
CHECK(s_close_calls == 0, "TC-TIMESYNC-027c budget exhausted still does not close the connection");
|
||||
CHECK(s_drop_calls == 1, "TC-TIMESYNC-027d budget exhausted drops the session on purpose (E-02 wrap-up: net_drop_conn kills the connection, keeps the listener)");
|
||||
|
||||
/* 9) 剩余预算不足一片 */
|
||||
fakes_reset();
|
||||
recv_set(0, -2, NULL, 0, 29980U);
|
||||
s_recv_seq_n = 1;
|
||||
time_sync_handle_conn(6);
|
||||
CHECK(s_recv_calls == 2, "TC-TIMESYNC-028 两次等待后结束");
|
||||
CHECK(s_recv_calls == 2, "TC-TIMESYNC-028 ends after two waits");
|
||||
CHECK((s_recv_to_log[0] == 50U) && (s_recv_to_log[1] == 20U),
|
||||
"TC-TIMESYNC-028b 第二次片长 = 剩余 20ms");
|
||||
"TC-TIMESYNC-028b second slice length = the remaining 20 ms");
|
||||
|
||||
/* 10) 32 位 tick 回绕 */
|
||||
fakes_reset();
|
||||
@@ -623,7 +623,7 @@ static void tc_handle_conn(void) {
|
||||
s_recv_seq_n = 1;
|
||||
time_sync_handle_conn(6);
|
||||
CHECK((s_recv_calls == 2) && (s_recv_to_log[0] == 50U) && (s_recv_to_log[1] == 50U),
|
||||
"TC-TIMESYNC-029 32 位 tick 回绕后预算计算仍正确");
|
||||
"TC-TIMESYNC-029 after a 32-bit tick wraparound the budget math is still correct");
|
||||
}
|
||||
|
||||
/* ===================== TC-TIMESYNC-040..044:time_sync_task ===================== */
|
||||
@@ -646,15 +646,15 @@ static void tc_task(void) {
|
||||
time_sync_task(NULL);
|
||||
}
|
||||
CHECK((s_wd_bind_calls == 1) && (s_wd_bind_id_bad == 0),
|
||||
"TC-TIMESYNC-040 任务入口登记心跳位(task_wd_bind 一次)");
|
||||
CHECK(s_evt_calls == 0, "TC-TIMESYNC-040b sys_evtHandle==NULL 时跳过就绪屏障");
|
||||
CHECK(s_accept_calls == 3, "TC-TIMESYNC-040c accept 轮询 3 次(2 次无连接 + 1 次成功)");
|
||||
CHECK((s_set_unix_calls == 1) && (s_set_unix_last == 9u), "TC-TIMESYNC-040d 收到时间包并更新墙钟");
|
||||
CHECK(s_close_calls == 1, "TC-TIMESYNC-040e 连接被关闭一次");
|
||||
CHECK(s_delay_calls == 9, "TC-TIMESYNC-040f 延时片数 = 4+4+1(200+200+50ms)");
|
||||
CHECK(delays_all(50U, 9), "TC-TIMESYNC-040g 所有延时均按 50ms 分片");
|
||||
CHECK(s_beat_calls == 13, "TC-TIMESYNC-040h 心跳次数 = 主循环1 + 退避8 + 收连接1 + 收尾1 + 次轮1");
|
||||
CHECK(s_beat_id_bad == 0, "TC-TIMESYNC-040i 所有心跳均打 TIMESYNC 位");
|
||||
"TC-TIMESYNC-040 task entry registers the watchdog beat bit (task_wd_bind once)");
|
||||
CHECK(s_evt_calls == 0, "TC-TIMESYNC-040b skips the readiness barrier when sys_evtHandle==NULL");
|
||||
CHECK(s_accept_calls == 3, "TC-TIMESYNC-040c accept polled 3 times (2 with no connection + 1 success)");
|
||||
CHECK((s_set_unix_calls == 1) && (s_set_unix_last == 9u), "TC-TIMESYNC-040d the time packet arrived and the wall clock was updated");
|
||||
CHECK(s_close_calls == 1, "TC-TIMESYNC-040e the connection is closed once");
|
||||
CHECK(s_delay_calls == 9, "TC-TIMESYNC-040f delay slice count = 4+4+1 (200+200+50 ms)");
|
||||
CHECK(delays_all(50U, 9), "TC-TIMESYNC-040g every delay is sliced at 50 ms");
|
||||
CHECK(s_beat_calls == 13, "TC-TIMESYNC-040h beat count = main loop 1 + backoff 8 + accepted connection 1 + wrap-up 1 + next round 1");
|
||||
CHECK(s_beat_id_bad == 0, "TC-TIMESYNC-040i every beat sets the TIMESYNC bit");
|
||||
|
||||
/* B) 就绪屏障:2 次未就绪 + 1 次就绪 */
|
||||
fakes_reset();
|
||||
@@ -667,12 +667,12 @@ static void tc_task(void) {
|
||||
if (setjmp(s_jmp) == 0) {
|
||||
time_sync_task(NULL);
|
||||
}
|
||||
CHECK(s_evt_calls == 3, "TC-TIMESYNC-041 就绪屏障轮询 3 次(2 次未就绪 + 1 次就绪)");
|
||||
CHECK(s_evt_last_timeout == 100U, "TC-TIMESYNC-041b 屏障等待按 100ms 分片");
|
||||
CHECK(s_evt_last_flags == SYS_EVT_NET_READY, "TC-TIMESYNC-041c 等待 NET_READY 位");
|
||||
CHECK(s_evt_last_options == (osFlagsWaitAny | osFlagsNoClear), "TC-TIMESYNC-041d 就绪位不被消费");
|
||||
CHECK(s_beat_calls == 3, "TC-TIMESYNC-041e 未就绪的两次各喂一次心跳(+主循环 1 次)");
|
||||
CHECK(s_wd_bind_calls == 1, "TC-TIMESYNC-041f 仍先登记心跳路由");
|
||||
CHECK(s_evt_calls == 3, "TC-TIMESYNC-041 readiness barrier polled 3 times (2 not ready + 1 ready)");
|
||||
CHECK(s_evt_last_timeout == 100U, "TC-TIMESYNC-041b barrier waits are sliced at 100 ms");
|
||||
CHECK(s_evt_last_flags == SYS_EVT_NET_READY, "TC-TIMESYNC-041c waits for the NET_READY bit");
|
||||
CHECK(s_evt_last_options == (osFlagsWaitAny | osFlagsNoClear), "TC-TIMESYNC-041d the ready bit is not consumed");
|
||||
CHECK(s_beat_calls == 3, "TC-TIMESYNC-041e the two not-ready rounds each beat once (+ 1 in the main loop)");
|
||||
CHECK(s_wd_bind_calls == 1, "TC-TIMESYNC-041f still registers the beat routing first");
|
||||
|
||||
/* C) 屏障期间持续喂心跳(就绪位长期不置位) */
|
||||
fakes_reset();
|
||||
@@ -682,8 +682,8 @@ static void tc_task(void) {
|
||||
if (setjmp(s_jmp) == 0) {
|
||||
time_sync_task(NULL);
|
||||
}
|
||||
CHECK(s_evt_calls == 4, "TC-TIMESYNC-042 屏障等待 4 次均未就绪(循环未挂死)");
|
||||
CHECK(s_beat_calls == 3, "TC-TIMESYNC-042b 每次未就绪后各喂一次心跳(第 4 次跳出前)");
|
||||
CHECK(s_evt_calls == 4, "TC-TIMESYNC-042 barrier waited 4 times, none ready (loop did not hang)");
|
||||
CHECK(s_beat_calls == 3, "TC-TIMESYNC-042b beats once after each not-ready round (before the 4th breaks out)");
|
||||
|
||||
/* D) 网络代次变化 -> 关闭旧监听并重监听 */
|
||||
fakes_reset();
|
||||
@@ -695,12 +695,12 @@ static void tc_task(void) {
|
||||
if (setjmp(s_jmp) == 0) {
|
||||
time_sync_task(NULL);
|
||||
}
|
||||
CHECK((s_close_calls == 1) && (s_close_socks[0] == 5), "TC-TIMESYNC-043 代次变化时关闭旧监听");
|
||||
CHECK((s_close_calls == 1) && (s_close_socks[0] == 5), "TC-TIMESYNC-043 closes the old listener when the network generation changes");
|
||||
/* INFO 三条:两次 open_listener 成功各一条 "TCP listen on" + 一条 "network re-init, relisten" */
|
||||
CHECK(g_tstest_info_count == 3, "TC-TIMESYNC-043b 留痕 network re-init, relisten(另含 2 条 listen 成功)");
|
||||
CHECK(s_accept_calls == 2, "TC-TIMESYNC-043c 每次循环只轮询一次 accept 即放弃");
|
||||
CHECK(g_tstest_info_count == 3, "TC-TIMESYNC-043b leaves the network re-init, relisten trace (plus 2 listen-success lines)");
|
||||
CHECK(s_accept_calls == 2, "TC-TIMESYNC-043c polls accept only once per loop then gives up");
|
||||
CHECK((s_socket_calls == 2) && (s_bind_calls == 2) && (s_listen_calls == 2),
|
||||
"TC-TIMESYNC-043d 第二次循环重建了监听");
|
||||
"TC-TIMESYNC-043d the second loop rebuilt the listener");
|
||||
|
||||
/* E) 监听建立失败 -> 5 次重试后放弃并退避 2000ms */
|
||||
fakes_reset();
|
||||
@@ -709,11 +709,11 @@ static void tc_task(void) {
|
||||
if (setjmp(s_jmp) == 0) {
|
||||
time_sync_task(NULL);
|
||||
}
|
||||
CHECK(s_socket_calls == 5, "TC-TIMESYNC-044 open_listener 内部重试 5 次后放弃");
|
||||
CHECK(g_tstest_err_count == 6, "TC-TIMESYNC-044b 5 条 net_socket FAIL + 1 条 retry later");
|
||||
CHECK(s_delay_calls == 90, "TC-TIMESYNC-044c 退避 5×500ms + 2000ms = 90 片");
|
||||
CHECK(s_beat_calls == 97, "TC-TIMESYNC-044d 心跳次数 = 2 + 5 + 50 + 40");
|
||||
CHECK(s_beat_id_bad == 0, "TC-TIMESYNC-044e 所有心跳均打 TIMESYNC 位");
|
||||
CHECK(s_socket_calls == 5, "TC-TIMESYNC-044 open_listener gives up after 5 internal retries");
|
||||
CHECK(g_tstest_err_count == 6, "TC-TIMESYNC-044b 5 net_socket FAIL lines + 1 retry later line");
|
||||
CHECK(s_delay_calls == 90, "TC-TIMESYNC-044c backoff 5x500 ms + 2000 ms = 90 slices");
|
||||
CHECK(s_beat_calls == 97, "TC-TIMESYNC-044d beat count = 2 + 5 + 50 + 40");
|
||||
CHECK(s_beat_id_bad == 0, "TC-TIMESYNC-044e every beat sets the TIMESYNC bit");
|
||||
}
|
||||
|
||||
/* ===================== main ===================== */
|
||||
|
||||
Reference in New Issue
Block a user