arXiv:2606.19725cs.SEcs.AI2026-06

用AI自动生成可编译的固件单元测试,减少人工调试负担。

Library-Aware Doubles and Iterative Repair for Large Language Model-Generated Unit Tests in OpenSIL Firmware

论文配图:Library-Aware Doubles and Iterative Repair for Large Language Model-Generated Unit Tests in OpenSIL Firmware
图 1 · 摘自论文原文
  • LLM驱动多智能体流水线,自动构建测试框架并复用桩代码
  • 76个函数中73个生成可编译测试,覆盖率最高达98.8%
  • 适合需要高效生成固件测试的嵌入式开发人员

低层C语言固件验证成本高昂,因单元测试在严格编译条件下易因缺少头文件、未解析符号和依赖冲突而无法编译链接。本文针对AMD维护的开源硅初始化库(openSIL)提出自动化单元测试生成流程,基于大语言模型(LLM)的多智能体架构,结合测试骨架自动生成、库感知的桩/模拟/假实现创建与复用,以及由编译日志和行覆盖反馈驱动的迭代修复循环。评估指标包括编译成功率、修复迭代次数、分发成功性和行覆盖率,辅以时间、成本和令牌消耗。在76个待测函数中,该流程成功生成73个可编译测试。在无行覆盖引导或检索增强配置下,平均行覆盖率达73.9%;在48个函数子集上,仅使用行覆盖引导时平均覆盖率提升至98.8%,结合向量数据库检索后达94.7%。结果表明,自动化生成-修复流水线可显著提升受限固件环境下的测试生成效率与覆盖率,同时降低人工调试开销。

原文摘要 · Abstract (English)

Validating changes in low-level C firmware is expensive because unit tests (UTs) are fragile under strict build constraints, where missing headers, unresolved symbols, and dependency mismatches frequently prevent compilation and linking. This study introduces an automated UT authoring workflow for the Open-Source Silicon Initialization Library (openSIL) firmware codebase maintained by Advanced Micro Devices (AMD) that reduces manual effort through a large language model (LLM) guided multi-agent pipeline. The workflow combines automated generation of test scaffolds, library-aware creation or reuse of stubs, mocks, and fakes, and an iterative compile-dispatch repair loop driven by build logs and line-coverage feedback. We evaluate the approach using compilation success, repair iterations, dispatch success, and line coverage, with time, cost, and token usage as secondary measures. Across 76 functions under test, the workflow generated compilable UTs for 73 functions. In a configuration without line coverage guidance or retrieval augmentation, mean line coverage reached 73.9%. On a 48-function subset evaluated under both configurations, mean line coverage reached 98.8% with line-coverage guidance alone and reached 94.7% when combined with vector-database retrieval. Results show that automated generation-and-repair pipelines can substantially improve UT creation efficiency and coverage for constrained firmware environments while reducing manual debugging effort.

单元测试固件验证LLM应用自动化修复

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。