Testing your code is important! Before you can even get your code committed into the source tree, you have to test it, and larger patches have to have automated tests. These articles will help you master (and continue to excel at) testing Mozilla code.
- Clang static analysis
- Clang has a built-in static analyzer. The gist is you add a wrapper around the compiler which directs all static analysis results to a common location. At the end of a build, these reports are aggregated into a report document showing all the potential issues.
- Debugging Mozilla with Valgrind
- This page describes how to use Valgrind (specifically, its Memcheck tool) to find memory errors.
- Firefox and Address Sanitizer
- Address Sanitizer (ASan) is a fast memory error detector that detects use-after-free and out-of-bound bugs in C/C++ programs. It uses a compile-time instrumentation to check all reads and writes during the execution. In addition, the runtime part replaces the
freefunctions to check dynamically allocated memory. More information on how ASan works can be found on the Address Sanitizer wiki.
- Measuring Code Coverage on Firefox
- Code coverage essentially is about measuring how often certain lines are hit, branches taken or conditions met in a program, given some test that you run on it. There are different types of coverage metrics (see also the Wikipedia entry), but when we speak of code coverage here, we usually mean line and branch coverage. This type of coverage is only concerned with hit counts for lines and branches.