🤖 AI Summary
This work addresses the limitations of existing large language models in generating concurrent, stateful Rust API tests—namely, frequent violations of preconditions, insufficient depth, and degeneration into sequential execution—as well as the heavy manual modeling burden of traditional model-driven testing. The authors propose a Petri net–guided test generation framework that employs colored Petri nets to formally model API resources, lifecycles, and causal dependencies. This formalism yields valid, near-valid, and partially ordered concurrent scenarios as constrained intermediate representations. Guided by local fidelity contracts, structural repair loops, and schedule shaping mechanisms, large language models synthesize executable tests exhibiting high conflict and coverage. The approach enables low-cost translation from formal scenarios to test code, significantly improving the legality, depth, and concurrency coverage of generated tests.
📝 Abstract
Concurrent stateful library APIs expose behavior through evolving resource ownership, lifecycle states, and competing interleavings. Large language models can synthesize executable Rust tests, but their outputs often violate API preconditions, remain shallow, or reduce concurrency to accidental sequential traces. Conversely, model-based and systematic testing techniques provide semantic control but commonly require substantial handwritten code to turn abstract scenarios into executable tests. This paper addresses the gap between formal scenario design and low-cost test concretization. We present a Petri-net-guided methodology for test generation over concurrent stateful Rust APIs. The method represents API resources, lifecycle conditions, and causal dependencies as colored tokens and transitions; derives legal deep-state, near-legal, and partial-order concurrent scenarios; and uses these scenarios as a constrained intermediate representation for LLM-based code synthesis. A local-faithfulness contract and structural repair loop preserve the modeled intent during concretization, while Petri-guided schedule shaping prioritizes high-conflict concurrency skeletons for systematic exploration. A layered semantic oracle then distinguishes synthesis failures from violations of the target API's expected behavior.