Resurgence of Regression Test Selection for C++

Resurgence of Regression Test Selection for C++

Resurgence of Regression Test Selection for C++ Ben Fu1, Sasa Misailovic2, and Milos Gligoric1 1The University of Texas at Austin, 2University of Illinois at Urbana-Champaign Email: ben [email protected], [email protected], [email protected] Abstract—Regression testing – running available tests after the test) or dynamically (during test execution on the old each project change – is widely practiced in industry. Despite its project revision). The code elements on which dependencies widespread use and importance, regression testing is a costly are kept determines the granularity of an RTS technique, e.g., activity. Regression test selection (RTS) optimizes regression testing by selecting only tests affected by project changes. RTS statement-level, function-level. has been extensively studied and several tools have been deployed RTS techniques have been studied for over four decades, in large projects. However, work on RTS over the last decade has and several surveys summarize RTS status and progress [5], mostly focused on languages with abstract computing machines [14], [50]. Researchers and practitioners have studied RTS (e.g., JVM). Meanwhile development practices (e.g., frequency of commits, testing frameworks, compilers) in C++ projects techniques for various programming languages, including have dramatically changed and the way we should design and C/C++, C#, and Java (e.g., [10], [16], [27], [34], [35], [47], implement RTS tools and the benefits of those tools is unknown. [52]). These techniques kept dependencies on various code We present a design and implementation of an RTS technique, elements, such as basic blocks, functions/methods, and classes dubbed RTS++, that targets projects written in C++, which (e.g., [10], [16], [42]), and used both static and dynamic compile to LLVM IR and use the Google Test testing framework. RTS++ uses static analysis of a function call graph to select tests. analysis (e.g., [16], [27], [52]). RTS++ integrates with many existing build systems, including Motivation. Most of the initial work on RTS techniques was AutoMake, CMake, and Make. We evaluated RTS++ on 11 large open-source projects, totaling 3,811,916 lines of code. To focused on languages that compile to an executable file, e.g., the best of our knowledge, this is the largest evaluation of an C/C++, but work in the last decade has mostly focused on RTS RTS technique for C++. We measured the benefits of RTS++ for languages with abstract computing machines, such as Java compared to running all available tests (i.e., retest-all). Our and C#. Although C++ is still a widely used programming results show that RTS++ reduces the number of executed tests language and projects written in C++ come with many tests, and end-to-end testing time by 88% and 61% on average. researchers arguably focused on Java and C# as they were Index Terms—Regression test selection, static analysis, call graph, LLVM, Google Test easier to analyze and come with an abundance of libraries. Despite the revolution of C++ compilers (e.g., the popularity I. INTRODUCTION of LLVM), testing frameworks (e.g., the widespread use of Regression testing – running available tests at each project Google Test), and development processes (the popularity of revision to check the correctness of recent project changes – GitHub and continuous integration services), the impact of is widely practiced in industry. The widespread availability of these factors on RTS design, implementation, and provided continuous integration systems simplified build configurations benefits is unknown. Additionally, recent practices to evaluate to enable regression testing, and continuous integration ser- RTS implementations based on end-to-end time (i.e., time to vices, e.g., TravisCI [45], provide necessary resources even to run the RTS tool and selected tests) were not used for RTS open-source projects. Although regression testing is important, tools that target C++ projects for decades. it is a rather costly activity, and this cost tends to increase Technique. We designed, implemented, and evaluated the with the increase in the number of tests and the frequency of first RTS technique, named RTS++, which supports projects project changes [43], [44]. Many large software organizations, that compile to LLVM IR (intermediate representation) [28], including Apache, Facebook, Google, Microsoft, Salesforce, use Google Test, and follow modern development practices. and Uber have reported high cost of regression testing and RTS++ is the first RTS technique for C++ based on static have been adopting various techniques to reduce this cost [7], function-level call graph analysis. At a new project revision, [13], [15], [21], [23], [42]. RTS++ analyzes code changes and runs those tests that de- Regression test selection (RTS) optimizes the regression pend on one of the modified/deleted/added functions. RTS++ testing activity by selecting tests that are affected by recent ensures to select an appropriate set of tests even in the presence project changes and skipping to run the remaining subset of of dynamic dispatch; this is achieved by a separate analysis of tests [5], [14], [39], [50]. Traditionally, RTS techniques keep a call graphs obtained for both the old and new project revisions. mapping from each test to all code elements (e.g., statements, RTS++ also supports changes in macros and templates by basic blocks, functions, classes) that the test might use and design, because it analyzes LLVM IR. RTS++ is influenced select those tests (at a new project revision) that depend on any by prior RTS techniques that analyze class-firewall, control- modified code element. The mapping from each test to code flow graphs, and dangerous-edges [24], [34], [35], [39]. The elements can be obtained either statically (without running key differences include the level on which RTS++ keeps dependencies, the way analysis is performed, and support for 1 // unittest.cc 1 // unittest.cc LLVM IR and Google Test. 2 class A f 2 class A f 3 public: 3 public: We implemented RTS++ as an LLVM compiler pass [29]. 4 virtual int foo() f 4 virtual int foo() f The benefit of this approach is that RTS++ can be ex- 5 return 5; g 5 return 5; g 6 g; 6 g; tended to support other languages that compile to LLVM 7 class B : public A f 7 class B : public A f 8 public: 8 public: bitcode. RTS++ blends nicely with Google Test and supports 9 virtual int foo() f 9 virtual int foo() f all test types. However, most of RTS++ is independent of 10 return 20; g 10 return 30; g 11 g; 11 g; Google Test and could be integrated with other testing frame- 12 class C: public A f 12 class C: public A f works, such as the Boost Test Library [6]. RTS++ currently 13 13 public: 14 14 virtual int foo() f supports AutoMake, CMake, and Make build systems. 15 15 return 30; g 16 g; 16 g; Evaluation. We performed an extensive evaluation of RTS++ 17 17 18 TEST(UnitTest, TestA) f 18 TEST(UnitTest, TestA) f on 11 open-source projects available on GitHub, totaling 19 A a; 19 A a; 3,811,916 lines of code and 1,709 test cases. To the best of our 20 EXPECT EQ(5, a.foo()); 20 EXPECT EQ(5, a.foo()); 21 g 21 g knowledge, this is the largest evaluation of an RTS technique 22 TEST(UnitTest, TestB) f 22 TEST(UnitTest, TestB) f 23 B b; 23 B b; for C++. This is also the first evaluation of an RTS for C++ 24 EXPECT EQ(20, b.foo()); 24 EXPECT EQ(20, b.foo()); that uses each revision rather than project releases. We use (up 25 g 25 g 26 TEST(UnitTest, TestC) f 26 TEST(UnitTest, TestC) f to) 50 latest revisions of each project. 27 C c; 27 C c; To assess the benefits of RTS++, we measured savings 28 EXPECT EQ(5, c.foo()); 28 EXPECT EQ(5, c.foo()); 29 g 29 g compared to retest-all strategy – running all test at each project (a) R revision (b) R0 revision revision (i.e., a strategy oblivious of the program changes). We compared the number of executed tests and end-to-end testing Fig. 1: An illustrative example that shows the old (left) and time. Our results show that RTS++ can provide substantial new (right) revisions of a simple project with three classes and savings. RTS++ reduced the number of tests of up to 97.20% three test cases. (88% on average) compared to retest-all. RTS++ reduced the end-to-end testing time up to 88.09% (61% on average) compared to retest-all (considering only those projects when B:foo() T estB() B() B:foo() T estB() B() testing time is substantial). These were surprising findings as recent work for Java showed that using static method A:foo() T estA() A() A:foo() T estA() A() call graph, which is analogous to function members in C++, provides no benefits [16], [27], [51]. T estC() C() C:foo() T estC() C() The main contributions of this paper include: (a) R revision (b) R0 revision ? RTS++, an RTS technique, based on a static function-level Fig. 2: Annotated dependency graphs for the illustrative ex- call graph analysis. ample. Each node is a function and there is an edge if one ? Implementation of RTS++ for projects that compile to function might invoke another function; the shape of the node LLVM IR and use the Google Test testing framework. is squared if the checksum for that node changed between two ? Extensive evaluation of RTS++ on 11 open-source projects, revisions; newly added nodes are always considered modified. totaling 3,811,916 lines of code and 1,709 test cases. II. BACKGROUND AND EXAMPLE tests (TestA, TestB, and TestC).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us