Last active
April 11, 2025 02:28
-
-
Save flounderK/aa8181351777c8056bb056f8285287a5 to your computer and use it in GitHub Desktop.
gather code coverage information with gcov in gcc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # build targets with code coverage, CFLAGS bit only works if `+=` is used in the make file | |
| CFLAGS="-fprofile-arcs -ftest-coverage" make CC=gcc | |
| # <run test case> | |
| # create files for all coverage reached by test case (don't use if using lcov) | |
| find . -type f -iname '*.gcda' |xargs gcov | |
| # generate coverage file for gcda files under this directory | |
| lcov -c -d . -o coverage.info | |
| # generate html report of all coverage | |
| genhtml coverage.info -o coverage_report | |
| # view coverage info in browser | |
| firefox coverage_report/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment