10323c4c22
Bench verification of the IO board needs an observation window: production build has no consumer of ioboard_di_snap_read(), so the DI values were invisible. Add TEST_SUITE_IOBOARD as a semi-automatic bench sequence and fix two real bugs found while wiring it in. New files: - test/board/ioboard_test.h, test/board/ioboard_test_task.c Test suite: - Owns its own thread (iobTest, 4096 words) instead of running in testTask: testTask is osPriorityBelowNormal, below defaultTask whose 1ms console drain loop can starve a blocking wait in a lower priority context. - Phases: bit-order self-check, DI eight-point bijection, DO point-by-point toggle with operator confirmation, release-all on every exit path. - Only exit is ioboard_release_all(); it is called from the entry guard, every phase failure, the write-failure branch and the thread tail. - Sample window is 20 reads x 2ms = 40ms and does overlap the 50ms production poll. That is stated as harmless in the header: the driver wraps the whole read in taskENTER_CRITICAL (26us, not the whole 40ms), both sides only read, and a torn cross-reader sample is caught by the debounce layer rather than acted upon. default_task.c fix: - DEFAULT_TASK_DI_PUBLISH_EN was defined twice: once at file scope and once inside default_task_func(). #define has no scope, so the second was a redefinition of the first. Collapsed to a single authoritative site. - Add TEST_SUITE_STORAGE to the disable list: the STORAGE suite owns the file system via testTask, and default_task_di_poll() referenced four statics that live inside an !TEST_SUITE_STORAGE block, which broke the STORAGE build with 11 errors. - Shrink the !TEST_SUITE_STORAGE block to cover only default_task_net_cfg_save_notify() and move the three declarations out; move edges/fails into the #else branch so the empty branch references none of the four statics. Registration and gates: - MDK-ARM/STM32F407-Demo.uvprojx and simulator/CMakeLists.txt entries. - scripts/check_test_suite.py: whitelist TEST_SUITE_IOBOARD. - scripts/stack_report.py: let a self-started thread that is not declared in Src/freertos.c osThreadAttr_t still be budget checked. - test/run_all_suites.py: bring the suite into the orchestrator view. Verified: six-build matrix all 0 errors 0 warnings. CH395F/STORAGE/GD5F/RTC and the product build are bit-identical at Code=257936; the IOBOARD build is Code=264640 (+6704), which is the evidence that the suite really enters the image. Host unit tests 100/100, stack report 1760/4096 words (57%).
134 lines
6.3 KiB
C
134 lines
6.3 KiB
C
/*
|
||
* 模块名称:统一测试套件选择
|
||
* 模块功能:集中选择当前构建要运行的测试套件。所有测试统一由
|
||
* testTask(start_test_task)调度,defaultTask 在测试
|
||
* 构建下空闲,正常产品构建下仅运行存储挂载/测试。
|
||
* 适用平台:STM32F4 系列
|
||
* 作者:王建锋
|
||
* 创建日期:2026-08-26
|
||
*
|
||
* 一次构建仅启用一个 TEST_SUITE_*(或都不启用 = 正常产品构建):
|
||
* TEST_SUITE_CH395F : CH395F 测试(沿用 ch395f_test.h 阶段宏,HW 1~5 / NET 6~11)
|
||
* TEST_SUITE_STORAGE : FTL + FatFS 存储测试(从 defaultTask 迁入)
|
||
* TEST_SUITE_GD5F : GD5F2GQ5UE NAND 驱动测试
|
||
* TEST_SUITE_RTC : SD2506 RTC 测试
|
||
* TEST_SUITE_IOBOARD : 开入开出板测试(8 路 DI 位序 + 4 路 DO 点动,半自动)
|
||
*/
|
||
|
||
#ifndef TEST_CONFIG_H
|
||
#define TEST_CONFIG_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
#include <stdint.h>
|
||
|
||
/* === 选择当前构建的测试套件(五选一,或都注释 = 正常产品构建)===
|
||
* ⚠️ 默认必须是**产品构建**(全部注释)——pre-commit 钩子 `test-suite-switch` 会拦截
|
||
* 未显式放行的测试构建(`--allow-test-build` / `ALLOW_TEST_BUILD=1`)。
|
||
* 跑套件回归时取消注释所需套件;跑完务必改回、或直接用 `test/run_all_suites.py`
|
||
* (自动改宏 + 结束后无条件还原)。详见 docs/测试说明/流程与规范/测试开发标准流程.md §3.1/§3.6。 */
|
||
//#define TEST_SUITE_CH395F
|
||
//#define TEST_SUITE_STORAGE
|
||
//#define TEST_SUITE_GD5F
|
||
//#define TEST_SUITE_RTC
|
||
//#define TEST_SUITE_IOBOARD
|
||
|
||
/* === 破坏性测试总开关(默认关闭)===
|
||
* 破坏性用例会改变设备的**持久状态**,跑一次即有代价(2026-09-21 实测:GD5F 整轮
|
||
* 破坏性用例跑一次即消耗一个 NAND 块,容量 95248 → 95200,且 TC-STORAGE-04 恢复不回来):
|
||
* - 向 BBT 持久化坏块标记 / 注入坏块(永久减少可用容量)
|
||
* - 写、擦 NAND 块(覆盖卷数据);格式化卷(nand_ftl_format / f_mkfs)
|
||
* - FatFS 建文件、写文件、性能压测
|
||
* 默认关闭:套件只跑**只读与参数校验**类用例,可随时在在用设备上执行。
|
||
* 仅在**产品首次上电/产线首启**或明确需要时打开;打开跑完建议做一次恢复。 */
|
||
//#define ENABLE_DESTRUCTIVE_TESTS
|
||
|
||
#if defined(TEST_SUITE_CH395F) + defined(TEST_SUITE_STORAGE) + defined(TEST_SUITE_GD5F) + defined(TEST_SUITE_RTC) + defined(TEST_SUITE_IOBOARD) > 1
|
||
#error "测试套件互斥:一次构建只能启用一个 TEST_SUITE_*"
|
||
#endif
|
||
|
||
/* 派生标记:任一套件被选中时置位。**2026-10-04 起有唯一消费点**——`Src/freertos.c`
|
||
* 的 MX_FREERTOS_Init() 用它门控 testTask 的回收:产品构建下 CubeMX 生成区
|
||
* 无条件创建 testTask,随后本标记未定义 → 立即 vTaskDelete 回收其 8KB CCM 栈 + TCB,
|
||
* 避免空转占堆。testTask 的调度见 test/board/test_config.c 的 start_test_task(),
|
||
* 后者**直接按 TEST_SUITE_RTC 等宏分支**,与本标记无关——故"RTC 构建下 testTask 不被
|
||
* 创建"的旧疑点不成立(实测 RTC 套件正常执行;RTC 已计入下方析取,故 RTC 构建下本
|
||
* 标记亦置位、testTask 正常保留)。
|
||
* 4 个套件(含 RTC)在此补齐:若将来再引入"测试构建下 defaultTask 空闲"等分支而复用
|
||
* 本标记,可避免重演"漏 RTC"的隐患。IOBOARD 同批补入(本标记的另一消费点 =
|
||
* `Src/freertos.c` 对 testTask 的回收,漏一个套件就等于该套件的 testTask 被回收、
|
||
* 套件永不执行,且不报错)。详见 docs/测试说明/板级测试/实机测试实施指南.md §8.3。 */
|
||
#if defined(TEST_SUITE_CH395F) || defined(TEST_SUITE_STORAGE) || defined(TEST_SUITE_GD5F) || defined(TEST_SUITE_RTC) || defined(TEST_SUITE_IOBOARD)
|
||
#define TEST_SUITE_SELECTED
|
||
#endif
|
||
|
||
#ifdef TEST_SUITE_CH395F
|
||
#include "ch395f_test.h"
|
||
#define TEST_SUITE_NAME "CH395F"
|
||
#endif
|
||
|
||
#ifdef TEST_SUITE_STORAGE
|
||
#include "storage_test.h"
|
||
#define TEST_SUITE_NAME "STORAGE"
|
||
#endif
|
||
|
||
#ifdef TEST_SUITE_GD5F
|
||
/* 选中 GD5F 套件时,自动开启 gd5f 测试总开关;
|
||
* 只读阶段无条件启用,破坏性阶段(写/擦/格式化/BBT 落盘)受 ENABLE_DESTRUCTIVE_TESTS 门控 */
|
||
#define ENABLE_GD5F_TESTS
|
||
|
||
/* --- 只读阶段:随时可跑,不改设备状态 --- */
|
||
#define ENABLE_GD5F_PHASE1_TESTS /* init / read_id / reset */
|
||
#define ENABLE_GD5F_PHASE2_TESTS /* BBT 读取与 RAM 内标记(206/207 落盘另受门控) */
|
||
#define ENABLE_GD5F_PHASE7_TESTS /* DMA 边界与守卫(701~703/705 写擦受门控;704 只读,日常回归亦跑) */
|
||
#define ENABLE_GD5F_PHASE10_TESTS /* 越界与 size=0 参数校验(1003/1004 写入另受门控) */
|
||
//#define ENABLE_GD5F_PHASE11_TESTS /* 13h 锁存复现实验(2026-09-21 已完成:16 轮×48 读零复现;仅擦写最高一块,可随时重开) */
|
||
|
||
#ifdef ENABLE_DESTRUCTIVE_TESTS
|
||
/* --- 破坏性阶段:写/擦页与块、格式化、FatFS 写入 --- */
|
||
#define ENABLE_GD5F_PHASE3_TESTS /* 页/跨页/多页读写 */
|
||
#define ENABLE_GD5F_PHASE4_TESTS /* 块擦除 */
|
||
#define ENABLE_GD5F_PHASE5_TESTS /* ECC 写读 */
|
||
#define ENABLE_GD5F_PHASE6_TESTS /* SPI 原语(块擦除 + 编程) */
|
||
#define ENABLE_GD5F_PHASE8_TESTS /* FTL init + nand_ftl_format(格式化清卷) */
|
||
#define ENABLE_GD5F_PHASE9_TESTS /* FatFS 挂载 + 写文件 */
|
||
#endif
|
||
|
||
#include "gd5f_test.h"
|
||
#define TEST_SUITE_NAME "GD5F"
|
||
#endif
|
||
|
||
#ifdef TEST_SUITE_RTC
|
||
#include "sd2506_test.h"
|
||
#define TEST_SUITE_NAME "RTC"
|
||
#endif
|
||
|
||
#ifdef TEST_SUITE_IOBOARD
|
||
/* 开入开出板套件:行序/点动序列全在 ioboard_test_task.c;
|
||
* 本块只做"选它 + 给它一个名字"。 */
|
||
#include "ioboard_test.h"
|
||
#define TEST_SUITE_NAME "IOBOARD"
|
||
#endif
|
||
|
||
#ifndef TEST_SUITE_NAME
|
||
#define TEST_SUITE_NAME "NONE"
|
||
#endif
|
||
|
||
/*
|
||
* 链路时延探针(M2/M3):在 net_socket.c 发送分块循环内定义 CHUNK_WAIT
|
||
* 测量钩子(netTask 上下文);产品构建未定义 → 钩子代码编译消失(零开销)。
|
||
* 依赖 ch395f_test.h 的 Phase 宏(上方 TEST_SUITE_CH395F 块内已包含)。
|
||
*/
|
||
#if defined(TEST_SUITE_CH395F) && \
|
||
(defined(ENABLE_PHASE13_TESTS) || defined(ENABLE_PHASE14_TESTS))
|
||
#define TEST_LATENCY_PROBE 1
|
||
#endif
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* TEST_CONFIG_H */
|