Learning useful FileCheck tricks
FileCheck is an advanced pattern checker that originates from LLVM. It has a similar role as the grep
command-line tool available in Unix/Linux systems, but provides a more powerful yet straightforward syntax for line-based contexts. Furthermore, the fact that you can put FileCheck
directives beside the testing targets makes the test cases self-contained and easy to understand.
Though basic FileCheck
syntax is easy to get hands-on with, there are many other FileCheck
functionalities that truly unleash the power of FileCheck
and greatly improve your testing experiences – creating more concise testing scripts and parsing more complex program output, to name a few. This section will show you some of those skills.
Preparing for our example project
The FileCheck
command-line tool needs to be built first. Similar to the previous section, building one of the check-XXX
(phony) targets in the LLVM tree is the easiest way to do so. The following...