feat(vd960DBN): offlog TIME_ANCHOR 严格用平台下发 unix_ts

offlog_time_anchor 原丢弃传参内部重取 dev_time_now() (毫秒级误差),
改为 offlog_evt_ts() 直接写入平台下发值, 锚点事件与平台 ts 严格一致。
新增单测 test_time_anchor_exact, 7 例 ALL PASS
This commit is contained in:
wangfq
2026-08-04 18:10:18 +08:00
parent 2b1e888a73
commit 90755bf465
3 changed files with 30 additions and 4 deletions
+17
View File
@@ -216,6 +216,22 @@ static void test_power_loss_mid_sector(void)
printf("PASS test_power_loss_mid_sector\n");
}
/* 测试7: TIME_ANCHOR 严格使用平台下发 unix_ts (不走 dev_time_now) */
static void test_time_anchor_exact(void)
{
OfflogEvt e;
reset_flash();
offlog_init();
offlog_time_anchor(1800000000UL); /* 平台下发值, 与 mock dev_time_now() 不同 */
CHECK(offlog_count() == 1);
CHECK(offlog_read_idx(0, &e) == 0);
CHECK(e.type == OFFLOG_EVT_TIME_ANCHOR);
CHECK(e.unix_ts == 1800000000UL); /* 严格等于传参 */
CHECK(e.flags & OFFLOG_UNIX_VALID_FLAG);
printf("PASS test_time_anchor_exact\n");
}
int main(void)
{
test_fresh_init();
@@ -224,6 +240,7 @@ int main(void)
test_sector_switch();
test_clear();
test_power_loss_mid_sector();
test_time_anchor_exact();
if (failures) {
printf("\n%d FAILURE(S)\n", failures);