C++ is popular in many application domains for its extensibility, flexibility, and high performance. At the same time, however, C++ is infamous for its complex syntax and semantics. Thus, it is challenging to write correct C++ programs and the need to automatically test C++ programs has been high. Unfortunately, due to the high complexity of C++ (e.g., template instantiation, complex STL types, etc.), there are almost no automated unit testing tool publicly available for real-world C++ programs.
I have developed a new automated unit testing tool CITRUS that resolves the aforementioned complexity of C++ programs. After analyzing the source code of a target C++ program P, CITRUS automatically generates test driver files for P, each of which consists of various method calls of P. Then, to improve the test coverage of P, it generates more diverse test drivers by mutating the test driver code. Also, CITRUS increases the test coverage of P further by applying libfuzzer to alternate P's state by mutating arguments of the methods. I have demonstrated the testing effectiveness and the efficiency of CITRUS through the experiments on the real-world C++ programs, on which CITRUS achieves up to 95% statement and 79% branch coverage.
C++는 그 확장성, 유연성 및 고성능을 가진 프로그래밍 언어로써 많은 응용 프로그램에 널리 사용되고 있다. 하지만, C++는 복잡한 문법 체계를 가지고 있어, 정확한 코드를 적기 위해서는 매우 어려우며, 따라서 C++ 프로그램을 자동으로 테스트하여 코드의 질을 높일 수 있는 기술이 필요하다. 하지만 템플릿 인스턴스화, 복잡한 STL 타입 등의 높은 복잡성을 가지는 C++ 코드의 분석이 어려워, 실제 C++ 프로그램을 유닛 테스팅 할 수 있는 도구는 거의 없는 실정이다.
본 논문에서는 위에서 언급된 C++의 복잡성을 해결하여 자동으로 C++ 프로그램을 유닛 테스팅 할 수 있는 도구인 CITRUS를 개발하여 제안한다. CITRUS는 주어진 C++ 프로그램 P를 분석하여, P의 다양한 함수 호출을 포함하는 테스트 드라이버를 자동으로 생성한다. 더 나아가서, 테스트 드라이버를 변이하여 더 다양한 함수 호출 시퀀스를 생성하고, libfuzzer를 이용하여 각 함수 호출의 인수 (argument)를 변이하여 다양한 값으로 함수를 호출 할 수 있도록 한다. CITRUS를 평가하기 위해 실제 C++ 프로그램에 적용한 결과, 95%의 명령문(statement) 커버리지 향상과, 79%의 분기 커버리지 향상을 보였다.