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:
@@ -57,6 +57,7 @@ SUITE_MACROS = [
|
||||
("TEST_SUITE_STORAGE", "STORAGE 存储套件(FTL + FatFS)"),
|
||||
("TEST_SUITE_GD5F", "GD5F NAND 驱动套件(10 阶段)"),
|
||||
("TEST_SUITE_RTC", "RTC 套件(SD2506)"),
|
||||
("TEST_SUITE_IOBOARD", "开入开出板套件(8 路 DI 位序 + 4 路 DO 点动,半自动)"),
|
||||
]
|
||||
|
||||
# 只关注"套件选择开关"本身。同文件里还有派生的 TEST_SUITE_SELECTED /
|
||||
|
||||
@@ -48,6 +48,16 @@ ROOTS = {
|
||||
"adc_task_func": "adcTask",
|
||||
"iec104_serv_task": "iec104Task",
|
||||
"protect_task": "protectTask",
|
||||
# 套件自起线程(xTaskCreateStatic,TCB 与栈都在 .bss,不在 freertos.c 的
|
||||
# osThreadAttr_t 表里)。配置值由下面 STATIC_TASK_STACKS 直接读源码常量。
|
||||
"ioboard_thread_entry": "iobTest",
|
||||
}
|
||||
|
||||
# 自起线程的栈**不由 freertos.c 声明**,配置值只能从定义处读:任务名 -> (文件, 常量名)。
|
||||
# 常量本身是**字节数**(`(1024U * 4U)` 这种写法也认);读不到即视为 0 → 报告里显示
|
||||
# N/A,而不是拿一个猜的数去算余量。
|
||||
STATIC_TASK_STACKS = {
|
||||
"iobTest": ("test/board/ioboard_test_task.c", "IOBOARD_TEST_THREAD_STACK"),
|
||||
}
|
||||
|
||||
# Runtime lines use the short labels emitted by stack_probe_poll() in freertos.c.
|
||||
@@ -130,6 +140,37 @@ def parse_task_stacks(path):
|
||||
return stacks
|
||||
|
||||
|
||||
def parse_static_task_stacks():
|
||||
"""Configured stack size (bytes) of self-spawned tasks.
|
||||
|
||||
These tasks never appear as osThreadAttr_t in freertos.c, so without this the
|
||||
table would show them as "N/A (not in image)" and the very thread that was added
|
||||
to hold a big buffer would escape the budget check entirely.
|
||||
|
||||
Accepted forms at the definition site (C integer literals, 0-2 multiplications):
|
||||
#define X (1024U * 4U) -> 4096
|
||||
#define X 2048U -> 2048
|
||||
"""
|
||||
sizes = {}
|
||||
for task, (rel, macro) in STATIC_TASK_STACKS.items():
|
||||
p = REPO_ROOT / rel
|
||||
try:
|
||||
text = p.read_text(encoding='utf-8', errors='replace')
|
||||
except OSError:
|
||||
continue
|
||||
m = re.search(r'^\s*#define\s+' + re.escape(macro) + r'\s+([^\r\n/]+)', text, re.M)
|
||||
if not m:
|
||||
continue
|
||||
expr = m.group(1)
|
||||
factors = re.findall(r'(\d+)\s*[uU]?', expr)
|
||||
if factors and not re.search(r'(?i)[a-wyz]', expr.replace('u', '').replace('U', '')):
|
||||
total = 1
|
||||
for f in factors:
|
||||
total *= int(f)
|
||||
sizes[task] = total
|
||||
return sizes
|
||||
|
||||
|
||||
def parse_runtime(path):
|
||||
"""Extract the last [STACK] block from a serial log: task -> peak/free."""
|
||||
text = pathlib.Path(path).read_text(encoding='utf-8', errors='replace')
|
||||
@@ -168,6 +209,7 @@ def main():
|
||||
|
||||
meta, functions = parse_callgraph(html_path)
|
||||
stacks = parse_task_stacks(FREERTOS_C)
|
||||
stacks.update(parse_static_task_stacks()) # 自起线程(不在 freertos.c 里)
|
||||
runtime, heap = ({}, None)
|
||||
if args.serial:
|
||||
runtime, heap = parse_runtime(args.serial)
|
||||
|
||||
Reference in New Issue
Block a user