feat(ioboard): board test suite for DI/DO, fix default_task conditional compile
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%).
This commit is contained in:
+23
-18
@@ -121,10 +121,19 @@ static const stack_probe_task_t s_stack_probe[] = {
|
||||
static void stack_probe_poll(void);
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
static void default_task_net_cfg_save_notify(void);
|
||||
static FRESULT storage_bring_up(FATFS *fs);
|
||||
static void wave_store_drain(void);
|
||||
static uint8_t default_task_di_poll(void);
|
||||
|
||||
/* 周期性发布者的编译期开关:两个测试套件构建都禁用本任务的发布(见 poll 函数的说明四) */
|
||||
#if defined(TEST_SUITE_CH395F) || defined(TEST_SUITE_GDRAM)
|
||||
/*
|
||||
* 周期性发布者的编译期开关:测试套件构建下禁用本任务的发布(见 poll 函数的说明四)。
|
||||
* 为什么把 STORAGE 也算进来:STORAGE 套件由 testTask 独占文件系统,而本任务的发布路径
|
||||
* 会经 syslog_post() 写 run.log;同时那四个开入静态变量声明在 !TEST_SUITE_STORAGE 区里,
|
||||
* 若本开关对它仍判 1,poll 函数体就会引用到被条件编译挖掉的变量而编不过。
|
||||
* **本段是 DEFAULT_TASK_DI_PUBLISH_EN 的唯一权威定义点**——函数体内不得再定义一次
|
||||
* (#define 没有作用域,重复定义是宏重定义警告,且让"当前生效的值"变成靠行号推断)。
|
||||
*/
|
||||
#if defined(TEST_SUITE_CH395F) || defined(TEST_SUITE_GDRAM) || defined(TEST_SUITE_STORAGE)
|
||||
#define DEFAULT_TASK_DI_PUBLISH_EN 0
|
||||
#else
|
||||
#define DEFAULT_TASK_DI_PUBLISH_EN 1
|
||||
@@ -144,8 +153,6 @@ static ioboard_di_ch_t s_di_ch[IOBOARD_DI_CH_NUM];
|
||||
static ioboard_di_snapshot_t s_di_snap;
|
||||
static uint8_t s_di_pub_mask;
|
||||
static uint32_t s_di_fail_edges_seen;
|
||||
static FRESULT storage_bring_up(FATFS *fs);
|
||||
static void wave_store_drain(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -214,14 +221,9 @@ void default_task_func(void *argument) {
|
||||
uint32_t cfg_poll_cnt = 0u;
|
||||
uint32_t led_tick = HAL_GetTick();
|
||||
|
||||
/* 周期性发布者的编译期开关:两个套件都禁用本任务的发布(见下方 poll 函数的说明) */
|
||||
#if defined(TEST_SUITE_CH395F) || defined(TEST_SUITE_GDRAM)
|
||||
#define DEFAULT_TASK_DI_PUBLISH_EN 0
|
||||
#else
|
||||
#define DEFAULT_TASK_DI_PUBLISH_EN 1
|
||||
#endif
|
||||
/* 开入第一次读取放在 bring-up 之后:此刻 MX_GPIO_Init 早已配好引脚(模块初始化期),
|
||||
* 且看门狗尚未启动,几十微秒的移位读不会影响任何节拍。 */
|
||||
* 且看门狗尚未启动,几十微秒的移位读不会影响任何节拍。
|
||||
* 发布开关 DEFAULT_TASK_DI_PUBLISH_EN 在文件作用域统一定义,此处**不得重复定义**。 */
|
||||
(void)default_task_di_poll();
|
||||
|
||||
/* 注册控制台写者:本任务此后是串口唯一发送者(其余任务只写环形缓冲)。
|
||||
@@ -967,22 +969,25 @@ static void default_task_net_cfg_save_notify(void) {
|
||||
* 有效性下降沿(有效 → 失效)各落一条 run.log。判据用 fail_edges 的**边沿**
|
||||
* 而不是失败计数,保证一个故障 episode 只记一条(与 task_wd_poll 的位图边沿同款)。
|
||||
* 写日志点放在本函数内而非 ioboard_di.c:纯逻辑层不碰文件系统。
|
||||
* 且只在 !TEST_SUITE_CH395F && !TEST_SUITE_GDRAM 时发布 —— 那两个套件构建下
|
||||
* 卷由 testTask 独占(与 TEST_SUITE_STORAGE 同款理由),defaultTask 侧只读不算不写盘。
|
||||
* 且只在 !TEST_SUITE_CH395F && !TEST_SUITE_GDRAM && !TEST_SUITE_STORAGE 时发布 ——
|
||||
* 那三个套件构建下卷由 testTask 独占,defaultTask 侧只读不算不写盘。
|
||||
*/
|
||||
static uint8_t default_task_di_poll(void) {
|
||||
uint8_t mask = 0u;
|
||||
uint8_t rc = 0u;
|
||||
uint8_t i;
|
||||
uint32_t now = HAL_GetTick();
|
||||
|
||||
#if (DEFAULT_TASK_DI_PUBLISH_EN == 0)
|
||||
/* 测试套件构建:卷上写者不是本任务,本函数不发布也不写日志(见函数说明四)。
|
||||
* 这一分支下不触碰 s_di_ch / s_di_snap / s_di_pub_mask / s_di_fail_edges_seen:
|
||||
* TEST_SUITE_STORAGE 构建把它们的声明整段条件编译掉了,引用就是编译错误。 */
|
||||
(void)mask; (void)rc; (void)i; (void)now;
|
||||
return 0u;
|
||||
#else
|
||||
uint32_t edges = 0u;
|
||||
int32_t fails = 0;
|
||||
|
||||
#if (DEFAULT_TASK_DI_PUBLISH_EN == 0)
|
||||
/* 测试套件构建:卷上写者不是本任务,本函数不发布也不写日志(见函数说明四) */
|
||||
(void)mask; (void)rc; (void)i; (void)now; (void)edges; (void)fails;
|
||||
return 0u;
|
||||
#else
|
||||
if (ioboard_di_read(&mask) == BSP_OK) {
|
||||
/* 成功:第一拍(或刚从故障恢复)先整组重新确立基准,再喂本拍 */
|
||||
if (s_di_snap.valid == 0u) {
|
||||
|
||||
Reference in New Issue
Block a user