Files
wandering1 2055de0303 测试:落地测试架构改进 T-1~T-5(套件开关门禁/汇总行校验/通用 harness/公共断言宏/多套件编排)
背景:L0.5 主机侧单测落地后复审测试架构,给出 6 条改进意见(P0~P3),
登记进 docs/待处理内容.md「测试与验证基础设施」后逐条实施。

- T-1(P0) 测试套件开关门禁:新增 scripts/check_test_suite.py + pre-commit 钩子
  test-suite-switch,默认要求产品构建(全部 TEST_SUITE_* 注释),跑套件回归用
  --allow-test-build / ALLOW_TEST_BUILD=1 显式放行。顺带把 test_config.h 中长期
  开启的 TEST_SUITE_CH395F 改回注释(仓库此前躺着的是测试固件)。
- T-2(P1) verify_log.py 增加 --require-suite-summary:要求
  "=== <名称>: N/M PASSED (failed=0) ===" 且 N>0,堵住"套件没跑到汇总行/
  断言数为 0 仍判 PASS"的盲区;run_boot_test.py 同名参数透传。不传参向后兼容。
- T-3(P1) 抽取通用 harness test/host/common/unit_test_harness.py(工具链探测/
  INCLUDE-LIB 拼接/wd4819/GBK 解码/退出码契约);watchdog 运行器 170→55 行,只声明 TestBuild。
- T-4(P2) 新增 test/board/test_common.h 集中断言内核(TEST_CHECK_IMPL/TEST_REPORT_IMPL),
  4 套件各用一行宏绑定自身统计变量(保持 g_xxx_stats 独立、防跨套件串数)。
  刻意不 include dbg_log.h——否则冻结 DBG_TAG 默认值触发 #47-D 重定义警告。
- T-5(P2) 新增 test/run_all_suites.py 多套件回归编排,try/finally 无条件还原套件开关。

验证:@build 产品构建 0 错 0 警;4 套件逐一构建均 0/0;看门狗单测 39/39 PASS;
pre-commit 14 钩子全通过;编排脚本 dry-run/开关切换/异常还原均实测通过。
2026-10-01 07:28:57 +08:00

53 lines
2.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 模块名称:Storage Test Suite
* 模块功能:FTL + FatFS 存储测试的声明与断言宏。实现见 storage_test_task.c,
* 统一由 testTask 调度;正常产品构建下由 defaultTask 调用,
* 行为与原 defaultTask 内联逻辑一致。
* 适用平台:STM32F4 系列
* 作者:王建锋
* 创建日期:2026-08-26
*/
#ifndef STORAGE_TEST_H
#define STORAGE_TEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "test_common.h"
typedef test_stats_t storage_test_stats_t;
extern storage_test_stats_t g_storage_stats;
#define STORAGE_TEST_CHECK(cond, fmt, ...) \
TEST_CHECK_IMPL(g_storage_stats, cond, fmt, ##__VA_ARGS__)
#define STORAGE_TEST_REPORT(name) TEST_REPORT_IMPL(g_storage_stats, name)
/* 存储测试入口:FTL + FatFS 文件系统与性能测试 */
void storage_test_run(void);
/* 存储套件恢复测试(默认关闭):取消注释并编译 STORAGE 套件运行一次,
* 即可重建 BBT(清除 TC-STO-03 等注入的坏块)并重新格式化,恢复设备干净态。
* 恢复完成后建议重新注释并编译正常构建。 */
//#define ENABLE_STORAGE_RECOVERY_TESTS /* 台架已跑过一次恢复(2026-09-20 BBT 回出厂态),保持注释 */
/* 恢复模式的扩展(默认关闭,需与上面 ENABLE_STORAGE_RECOVERY_TESTS 同时打开):
* 把 dhara 可见区**整片擦净**(连 journal checkpoint 一起),用于**把被扣掉的容量恢复回来**。
* 原理(2026-09-21 读码 + 台架实证):dhara 把坏块计数持久化在 checkpoint 头里
* (journal.c `hdr_set_bb_current/bb_last`),而 `dhara_journal_clear()` 只是
* `bb_last = bb_current`(**不归零**)——所以 `nand_ftl_format()` 恢复不了容量(95200 卡住);
* 只有让下次启动 `dhara_map_resume` 失败、走 `dhara_map_clear` 的**全新初始化**分支
* (此时 bb_last = bb_current = 0)才能回满。2026-09-21 台架实测:95200 → **96064**(健康满值 ✓)。
* 代价:卷内容全失(启动时 FatFs 自动重建)、约 2044 次块擦除(数十秒)。 */
//#define STORAGE_RECOVERY_FULL_WIPE
#ifdef __cplusplus
}
#endif
#endif /* STORAGE_TEST_H */