Files
STM32F4-Base/test/board
wandering1 10323c4c22 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%).
2026-11-16 19:35:15 +08:00
..

test/board/ — 板端测试套件

⚠️ 编入固件的测试代码(由 testTask 执行)。这些 .c 已注册到 Keil 工程 MDK-ARM/STM32F4-Demo.uvprojx,占用 MCU 的 RAM/Flash。

文件一览

文件 测试对象 / 作用
test_config.c/h 测试任务配置:TEST_SUITE_* 套件选择开关(互斥)+ ENABLE_DESTRUCTIVE_TESTS
test_common.h 公共断言内核:test_stats_t + TEST_CHECK_IMPL/TEST_REPORT_IMPL;各套件用一行宏绑定自身统计变量
ch395f_test_task.c/h + ch395f_test.h CH395F 以太网(硬件层 Phase 15 / NET 层 Phase 611)
gd5f_test_task.c/h + gd5f_test.h GD5F2GQ5UE SPI NAND 存储
sd2506_test_task.c/h + sd2506_test.h SD2506 RTC
storage_test_task.c/h + storage_test.h 存储性能
net_test_task.c/h 网络层测试
net_latency_test.c/h 链路时延探针(DWT CYCCNT 时基,MCU 专属)

⚠️ 构建约束(AGENTS.md 详述)

  • 套件互斥:test_config.h 的 TEST_SUITE_CH395F/STORAGE/GD5F/RTC 一次只能启用一个 (违反则 #error);全部注释 = 产品构建
  • ⚠️ 测试固件不得静默提交:TEST_SUITE_* 开关受 pre-commit 钩子 test-suite-switch 门禁——默认要求全部注释。跑完套件回归务必改回产品构建再提交(2026-10-01 实测已提交 HEAD 里 TEST_SUITE_CH395F 就是开启状态,纯靠人记得改;故补此门禁)。确需提交测试构建时用 ALLOW_TEST_BUILD=1 git commit ... 或 python scripts/check_test_suite.py --allow-test-build 显式放行
  • 破坏性用例默认关闭:ENABLE_DESTRUCTIVE_TESTS(默认注释)控制写/擦 NAND、格式化、 坏块注入。关闭时为只读模式(横幅 mode: READ-ONLY),可随时在在用设备上跑
  • ⚠️ 实测一轮破坏性 GD5F 运行即让 dhara 多记一个坏块(容量下降且需全片擦除恢复)—— 只在产线首启或明确需要时打开
  • CH395F 套件:硬件层与 NET 层模式互斥
  • 总线独占:CH395F 硬件层模式下 netTask 自挂起,testTask 独占 CH395F

添加新测试套件

  1. 在 test_config.h 加开关(并入互斥 #error 检查)
  2. 新建 <模块>_test_task.c/h
  3. 注册进 Keil 工程(<FilePath>..\test\board\xxx.c</FilePath>)
  4. 跑回归:/serial-boot-test(.dsh/skills/serial-boot-test/scripts/run_boot_test.py)

相关文档

  • 测试指南:docs/测试说明/板级测试/CH395F_Test_Guide.md、GD5F2GQ5UE_Test_Guide.md、SD2506_Test_Guide.md、FTP_Test_Guide.md
  • 套件配置:AGENTS.md「测试与验证」章
  • 容量恢复:docs/测试说明/专项验证/存储维护与容量恢复.md