Achieving High Coverage for Floating-Point Code via Unconstrained Programming Zhoulai Fu Zhendong Su University of California, Davis, USA
[email protected] [email protected] Abstract have driven the research community to develop a spectrum Achieving high code coverage is essential in testing, which of automated testing techniques for achieving high code gives us confidence in code quality. Testing floating-point coverage. code usually requires painstaking efforts in handling floating- A significant challenge in coverage-based testing lies in point constraints, e.g., in symbolic execution. This paper turns the testing of numerical code, e.g., programs with floating- the challenge of testing floating-point code into the oppor- point arithmetic, non-linear variable relations, or external tunity of applying unconstrained programming — the math- function calls, such as logarithmic and trigonometric func- ematical solution for calculating function minimum points tions. Existing solutions include random testing [14, 23], over the entire search space. Our core insight is to derive a symbolic execution [17, 24], and various search-based strate- representing function from the floating-point program, any of gies [12, 25, 28, 31], which have found their way into many whose minimum points is a test input guaranteed to exercise mature implementations [16, 39]. Random testing is easy to a new branch of the tested program. This guarantee allows employ and fast, but ineffective in finding deep semantic is- us to achieve high coverage of the floating-point program by sues and handling large input spaces; symbolic execution and repeatedly minimizing the representing function. its variants can perform systematic path exploration, but suf- We have realized this approach in a tool called CoverMe fer from path explosion and are weak in dealing with complex and conducted an extensive evaluation of it on Sun’s C math program logic involving numerical constraints.