A Method for Detecting and Generating Test Data for Runtime Errors in C/C++ Project Units
Linh Ngoc Truc Tran, Nguyen Duc Nguyen, Hieu Vu Duc, Hoang Nguyen Viet, Lam Nguyen Tung, Hoang-Viet Tran, Phạm Ngọc Hùng · 2023
Runtime errors are a common challenge in software development as creating an error-free program is a difficult task. This paper presents a method named RED (Runtime Error Detection) to automatically generate test data for units of C/C++ projects. The method is based on static code analysis and utilizes two types of constraints to generate test data: test path constraints that lead the execution flow of the program to the error position, and error-causing constraints that trigger the error. These constraints are then converted into the SMT format and solved by an SMT solver such as Z3 to find the corresponding solution. If a solution can be found, the associated runtime error exists. Although the method is presented using projects written in C/C++, it can be applied to other programming languages. The effectiveness of this method has been evaluated using a tool named RedTool, and some initial experimental results on several open-source projects are presented and discussed in the paper.