Opened 6 years ago
Last modified 5 years ago
#3819 new enhancement
Add test coverage of C files
Reported by: | pmav99 | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.8.3 |
Component: | Compiling | Version: | svn-trunk |
Keywords: | Cc: | ||
CPU: | Unspecified | Platform: | Unspecified |
Description
Disclaimer: I've only tested with gcc.
Using the info from these links I managed to get test coverage for the C codebase:
- https://stackoverflow.com/questions/16682606/how-to-resovle-gcov-init-undefined-reference-issue-when-link
- https://stackoverflow.com/questions/39086957/test-coverage-from-swig-compiled-c-python-code
- install gcov
- Compile with these options:
export CFLAGS='-O0 -fPIC -march=native -std=gnu99 -fprofile-arcs -ftest-coverage -g' export LDFLAGS='-s -lgcov --coverage'
- Run tests
- Generate test coverage reports (there may be warning/errors):
mkdir -p coverage gcovr -r . --filter="" --html --html-details -o coverage/coverage.html
- Inspect coverage:
firefox coverage/coverage.html
If possible, this should be added to fatra and once #3771 is resolved, on travis too.
I guess that it would also make sense to add a configure option like e.g. libspatialite:
#----------------------------------------------------------------------- # --enable-gcov # # Check whether --enable-gcov was given. if test "${enable_gcov+set}" = set; then : enableval=$enable_gcov; fi if test "x$enable_gcov" = "xyes"; then CFLAGS=$CFLAGS" -fprofile-arcs -ftest-coverage -g" GCOV_FLAGS="-lgcov" fi #-----------------------------------------------------------------------
Change History (3)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
GDAL is already using gcov/lcov, too, so it might make sense to see how they have integrated them
This is quite messy to be honest. Partly because I didn't try to make this better :-) So basically, I've a job that forks the GDAL master branch and re-applies the following changes on top of it : https://github.com/rouault/gdal_coverage/commit/3b63c70890a0897dcbe1cbd49f36b76e0a5e704a But the gist is build with lcov, run the tests, run lcov, filter some stuff in its output to have a clean report, run genhtml and then push this to a github repo. The interesting part that could be more or less reused by GRASS is in https://github.com/rouault/gdal_coverage/commit/3b63c70890a0897dcbe1cbd49f36b76e0a5e704a#diff-46c965c7db8bedae7518f42e783c44dd
comment:3 by , 5 years ago
Milestone: | → 7.8.3 |
---|
For the record, GDAL is already using gcov/lcov, too, so it might make sense to see how they have integrated them: https://gdalautotest-coverage-results.github.io/coverage_html/index.html