K
dsh-plugin
kedeshuai/dsh-plugin
White-box testing workflow skill for embedded C: host-side stub harness, wb.py test driver with gcov coverage gating, and a control-logic study handbook template.
Install
dsh plugin --profile web add github:kedeshuai/dsh-pluginREADME
dsh-plugin-whitebox-testing
DSH 技能插件:嵌入式 C 白盒测试标准化工作流。技能被 DSH 自动发现后,说"对 XX 模块做白盒测试"即可按 P0~P7 流程执行。
提供什么
| 内容 | 说明 |
|---|---|
skills/whitebox-testing/SKILL.md | 方法论与判断规则:范围界定→结构分析→三类打桩→用例设计→执行→覆盖率闭环口径→缺陷分级→文档交付(含控制逻辑学习手册),附环境坑清单与增量回归 5 步 |
skills/whitebox-testing/scripts/wb.py | 测试驱动:new(生成 test/stub 骨架并注册)/ run / gate(覆盖率门禁,CI 非零退出)/ cases / vg(环复杂度) |
skills/whitebox-testing/scripts/build_run.py | 构建+执行+gcov(宿主机 GCC) |
skills/whitebox-testing/scripts/coverage_report.py | gcov 聚合报告(markdown) |
skills/whitebox-testing/scripts/cyclomatic.py | 扩展 McCabe 环复杂度表 |
skills/whitebox-testing/templates/harness/ | harness 模板:test_framework.h、hwlog.h(硬件调用记录器)、hc32_ll.h.example / stubs_hw.c.example(MCU 桩示例,按芯片适配) |
安装
dsh plugin add <本仓库> # 或 DSH 内 plugin_manager 安装
要求 Node.js >= 22.19。安装后 DSH 自动发现 skills/whitebox-testing;web 端提供两个 UI 入口:左栏底部(Settings 旁)"白盒测试配置"按钮打开配置面板,Plugins 页本插件卡片内嵌同一表单。
使用
- 在被测工程根目录放
whitebox.config.json(可直接用上述配置面板填写生成;键说明见scripts/wbconfig.py头注释):
{
"test_root": "whitebox-test",
"source_root": "path/to/source",
"include_dirs": ["path/to/bsp"],
"gcc": "C:/msys64/ucrt64/bin/gcc.exe",
"min_line": 85,
"min_branch": 80
}
- 对 DSH 说"对 xx 模块做白盒测试"——技能按 SKILL.md 流程产出 7 件文档 + 可执行测试 + 覆盖率门禁。
实证
方法论与脚本已在实际嵌入式 C 固件工程上完整走通:多模块、数百个测试用例全绿,行/分支覆盖率达验收线,发现并分级数十处缺陷。wb.py gate 端到端通过。
提交插件市场(awesome-dsh-plugin)
投稿是一个文件的 PR:data/plugins/<owner>__<repo>.yml,草稿见 docs/marketplace-entry.yml。CI 检查清单(详见 contributing.md):
-
package.json声明dsh.bundle(含patch: ./cordis.patch.yml)——已具备 - 仓库根有
cordis.patch.yml(- insert: id/name)——已具备 - 建独立 GitHub 仓库(https://github.com/kedeshuai/dsh-plugin)、添加
dsh-plugintopic - 填写
package.json的repository字段指向该仓库 - 提 PR:awesome-dsh-plugin#12253(
data/plugins/kedeshuai__dsh-plugin.yml) - 等待仓库满 1 天后 CI 通过、评审合并;held: author 时推同一分支更新
- 可选:
screenshots.json截图、发布 npm(免构建授权)
License
MIT