Abstract
FuzzAug is a novel data augmentation technique that leverages coverage-guided fuzzing to generate high-quality training data for neural test generation. By converting dynamic fuzzing inputs into semantically valid unit tests, FuzzAug addresses the data scarcity bottleneck in training Large Language Models (LLMs) for software testing. Fine-tuning models like StarCoder2 and CodeQwen1.5 with FuzzAug-augmented data leads to significant improvements in assertion accuracy and code coverage.
The Challenge of Data Scarcity in Test Generation
Automated test generation has increasingly shifted toward Large Language Models (LLMs) due to their ability to produce human-readable tests that are easier to maintain than traditional tool outputs. However, these models face a significant bottleneck: data scarcity. In most software repositories, unit tests comprise less than 20% of the code. This imbalance makes it difficult for LLMs to learn the complex relationships between a function's logic and the specific inputs required for thorough testing.
While traditional "fuzzing" (randomly providing inputs to find program crashes) is effective at exploring execution paths, its outputs are typically raw data strings rather than the structured unit tests developers use. FuzzAug bridges this gap by transforming the "brute force" power of fuzzing into high-quality training data for neural models.
Methodology: The FuzzAug Pipeline
The authors introduce a pipeline that converts dynamic software analysis into static training data through four primary stages:
- Instrumentation: Existing "fuzz targets" in Rust repositories are identified and augmented with a "reporter" to record inputs that trigger new program behaviors.
- Coverage-guided Fuzzing: A fuzzer (libFuzzer) generates a diverse set of valid inputs to explore as many code branches as possible.
- Syntax Transformation: Using Abstract Syntax Trees (ASTs), fuzz targets are rewritten into standard unit test templates, ensuring the generated data adheres to the formal grammar and semantics of the language.
- Instantiation: These templates are populated with the diverse inputs gathered during fuzzing, effectively doubling the training dataset with unique, executable test cases.
Unlike standard data augmentation techniques like variable name swapping, FuzzAug introduces prior knowledge from dynamic analysis, allowing the model to learn from inputs known to exercise specific code paths.
Dataset Augmentation and Evaluation
The study focuses on the Rust programming language, chosen for its strict syntax and robust built-in support for fuzzing. The researchers developed a Rust version of the UniTSyn dataset and applied FuzzAug to significantly expand it.
As shown in the table above, FuzzAug added over 6,800 additional code-test pairs, nearly doubling the original dataset's size and providing millions of additional tokens for training.
Key Results and Performance Gains
The authors fine-tuned three 7B-parameter models—StarCoder2, CodeLlama, and CodeQwen1.5—using the FuzzAug-augmented data. The results demonstrated consistent improvements across the board:
- Higher Accuracy: The FuzzQwen model achieved an increase in assertion accuracy of up to 10.49% over the baseline.
- Better Coverage: Unit tests generated by FuzzAug-trained models achieved significantly higher branch coverage. For instance, FuzzQwen reached 24.63% coverage, compared to 20.76% for the standard fine-tuned version.
- Consistency: FuzzAug-augmented models consistently outperformed both pre-trained and standard fine-tuned baselines in generating executable, valid code.
Key Insights
- Dynamic Analysis as a Teacher: Fuzzers are experts at finding edge cases. By capturing these and formatting them as unit tests, LLMs can learn program boundaries that are not obvious from source code alone.
- Readability vs. Robustness: FuzzAug combines the robustness of fuzzing (diverse inputs) with the readability of LLMs (structured code).
- The Scaling Ceiling: Simply adding more fuzzed inputs has diminishing returns. The quality and diversity of execution paths explored are more critical than raw data volume.
Limitations and Future Work
Currently, FuzzAug is tailored to Rust. While the concept is language-agnostic, the AST-based syntax transformation tools must be adapted for other languages like C++ or Go. Additionally, FuzzAug requires compilable source code to run the fuzzer, limiting its use on incomplete code snippets. Future research may explore using FuzzAug to identify actual bugs in real-world projects where ground truth is unknown.
Summary updated