arXiv:2607.28271cs.SEcs.AI2026-07

用智能代理自动生成测试用例,验证老代码迁移后的功能正确性。

Agentic Method for Deterministic Validation of Legacy Code Migration

论文配图:Agentic Method for Deterministic Validation of Legacy Code Migration
图 1 · 摘自论文原文
  • 构建双环境模拟器,通过智能代理搜索输入路径覆盖代码分支。
  • 在三个案例中实现接近全量覆盖,最高达91.90%分支覆盖率。
  • 适合需要高可靠性迁移的老系统改造团队使用。

将遗留的COBOL程序迁移到Java需大量测试以保证功能正确。但常因缺乏测试数据和难以覆盖所有边界情况而困难重重。本文提出一种新型智能体测试生成方法——“Locksmith Loop”,通过在通用硬件上离线运行被测的COBOL源码与生成的Java目标代码,并各自注入模拟组件。迭代式智能体循环执行输入模拟的见证搜索,以穿透程序分支,随后进行保持等价性的变异。当到达路由边界时,分析器识别出“锁定段”:阻碍进一步探索的条件。在三个案例中(涵盖两个开源项目和一个类生产级内部程序,源代码规模430至4,114行),Locksmith持续突破初始输入搜索的覆盖率瓶颈,在两个开源项目中达到近乎完整的覆盖,在内部项目中达到91.90%分支覆盖率。所有通过验证的测试用例中,生成的Java代码均通过确定性等价检查,与原始COBOL行为一致。本研究首次展示了一种基于确定性断言验证智能体生成代码输出的新范式。

原文摘要 · Abstract (English)

Migration of legacy COBOL programs to Java requires extensive testing to ensure correct functionality. This effort is often complicated by the lack of test data and the difficulty of validating all corner cases. In this paper we propose a novel agentic test-synthesis method, the "Locksmith Loop," which is initiated by preparing two runtime environments: the COBOL source and the generated Java target are each instrumented with mocks and executed off-mainframe on commodity hardware, then an iterative agentic loop performs Witness Search over input mocks to penetrate program branches, followed by parity-preserving mutations. When routing boundaries are reached, an analyzer identifies a Locked Paragraph: a condition preventing deeper exploration. Across three COBOL-Java case studies, spanning two open-source programs and one internal production-like COBOL program and ranging from 430 to 4,114 source lines, Locksmith consistently improved coverage beyond input-search plateaus, reaching nearly complete coverage on the two open-source programs and 91.90% branch coverage on the internal production-like COBOL program. The generated Java matched the COBOL reference under deterministic parity checks in all accepted test cases. Through these findings we demonstrate, to the best of our knowledge, a novel approach for validating agentic coding output using a deterministic oracle.

代码迁移智能体测试生成验证

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