Testing a compiler
In the previous section, you have learned how to run the core LLVM unit tests, but this is only the beginning of the story. There are two big missing pieces:
- How do you understand and reproduce a failing unit test?
- How do you go beyond unit testing?
Let us answer these questions in the following sections. However, first, we need a primer on some of the tools/infrastructure used for testing in LLVM.
Crash course on the Google test infrastructure
LLVM uses the Google test infrastructure (gtest) for some of its unit tests.
The tests based on gtest are regular C++ codes and produce regular executables. If you open one of the source files of the tests using this framework, you will find gtest-specific directives (e.g., EXPECT_EQ
, TEST
, etc.) but nothing complicated beyond that.
Running the related executable will directly reproduce whatever issue you may want to investigate and all the techniques you know for debugging C++ code...