[GRASS-dev] [GRASS GIS] #3819: Add test coverage of C files

GRASS GIS trac at osgeo.org
Thu Apr 18 07:35:51 PDT 2019


#3819: Add test coverage of C files
-------------------------+-------------------------
 Reporter:  pmav99       |      Owner:  grass-dev@…
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:
Component:  Compiling    |    Version:  svn-trunk
 Keywords:               |        CPU:  Unspecified
 Platform:  Unspecified  |
-------------------------+-------------------------
 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

 1. install [https://gcc.gnu.org/onlinedocs/gcc/Gcov.html gcov]
 2. Compile with these options:
 {{{
 export CFLAGS='-O0 -fPIC -march=native -std=gnu99 -fprofile-arcs -ftest-
 coverage -g'
 export LDFLAGS='-s -lgcov --coverage'
 }}}
 3. Run tests
 4. Generate test coverage reports (there may be warning/errors):
 {{{
 mkdir -p coverage
 gcovr -r . --filter="" --html --html-details -o coverage/coverage.html
 }}}
 5. 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.
 [https://www.gaia-gis.it/fossil/libspatialite/artifact/f5c88dedc9888f65
 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
 #-----------------------------------------------------------------------
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/3819>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list