TLDR: UnitTenX is an open-source AI multi-agent system that combines AI agents, Large Language Models (LLMs), and formal verification to automatically generate unit tests for legacy C codebases. It aims to increase test coverage, identify crash conditions, and improve software reliability and maintainability. The system features a five-step process including automated mockups, symbolic analysis for crash conditions, LLM-driven test generation, coverage analysis, and an LLM-based reflection loop for iterative improvement. In experiments on a legacy DNS server, UnitTenX achieved 100% line coverage and demonstrated robustness in handling common errors, making it a viable tool for modernizing and maintaining complex legacy software.
In the ever-evolving landscape of software development, legacy codebases present a significant challenge. These are systems built on older technologies, often lacking proper documentation and, crucially, comprehensive tests. This absence of testing can lead to a myriad of issues, from undetected bugs and security vulnerabilities to increased development time for new features. Addressing this critical problem, a new open-source AI multi-agent system called UnitTenX has been introduced, designed to automatically generate unit tests for these complex, older software packages.
UnitTenX leverages a powerful combination of Artificial Intelligence (AI) agents, Large Language Models (LLMs), and formal verification methods to automate the creation of unit tests. While LLMs have shown remarkable capabilities in code generation, they often struggle with the intricate task of bug detection, which involves solving complex reachability problems within a program. UnitTenX overcomes this limitation by integrating formal verification tools, specifically the Efficient SMT-based Bounded Model Checker (ESBMC), to identify potential crash conditions and ensure thorough test coverage.
The system operates through a five-step methodology. First, an ‘AutoMockUps’ component generates isolated mockups for each target function, consolidating all necessary dependencies into a single file. This simplifies the testing process and provides a complete context for the LLM. Next, the ‘Symbolic Analyzer’ uses ESBMC to scan these mockups, extracting sensitization conditions that highlight coverage gaps and identify unsafe execution states, such as integer overflows or buffer overflows. These conditions are then fed into the ‘Unit Test Generator’, where an LLM crafts candidate unit tests. Any tests that cause crashes are noted, providing valuable documentation for developers.
Following test generation, the ‘Coverage Analysis’ step compiles the generated tests and reports code coverage using tools like gcov. Finally, the ‘Reflection’ step employs the LLM to evaluate the test outcomes and coverage results, recommending improvements and iteratively refining the test suites. This feedback loop allows UnitTenX to continuously enhance the quality and coverage of the generated tests, even recovering from common errors like compilation failures and segmentation faults.
The effectiveness of UnitTenX was demonstrated through an experimental evaluation on djbdns, a legacy DNS server implementation written in C, comprising over 200 functions. The results were impressive: the system successfully measured coverage for 93.5% of the executed functions, and 33.2% of functions saw an improvement in their test quality ratings. Notably, UnitTenX managed to bring the codebase from 0% line coverage to 100%, proving its capability for use in production environments. Despite encountering over a thousand errors during the process, including compilation errors, segmentation faults, and timeouts, UnitTenX robustly produced compiling tests for all executed functions.
This innovative approach significantly reduces the manual effort typically required for testing legacy code. By automating the generation of high-coverage test suites and effectively handling errors, UnitTenX addresses key challenges in maintaining and modernizing older software systems. The ability to generate tests that expose crash conditions also enhances the documentation and understanding of legacy interfaces, which is crucial for long-term maintenance. While the initial evaluation was conducted on a single codebase and relied on subjective test quality ratings from the LLM, the findings highlight UnitTenX’s substantial potential to improve software reliability and maintainability. Future research aims to validate its effectiveness across a broader range of legacy systems and integrate more objective metrics into its reflection process.
Also Read:
- Automating C to Rust Translation with Collaborative AI Agents
- ECHO Algorithm Enhances Error Attribution in Multi-Agent AI Systems
For more details, you can read the full research paper here.


