Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverate report using lcov and gcov #105

Closed
wants to merge 6 commits into from

Conversation

velichkov
Copy link
Contributor

To generate the code coverage report you need first to install gcov and lcov (the configure script checks for them) and then execute

./configure --enable-code-coverage
make check-code-coverage

an URL pointing to the generated report will be displayed

file:///home/user/asn1c/build_gcc/asn1c-0.9.28-coverage/index.html

After every successful travis-ci build the code coverage report will be send to the coveralls.io. I've also added a badge in the Readme

If you don't like coveralls.io I will remove this commit but if you decide to merge it you need to create a new account in coveralls.io (it's free for opensource), configure the asn1c project from your github repo, get the coveralls repo token and add it to your travis-ci build enviroment (COVERALLS_REPO_TOKEN).

You also need to change the in the coveralls.io URL in the Readme.md
https://coveralls.io/repos/github/velichkov/asn1c/badge.svg?branch=master

Some other changes:

  • Link asn1c/tests with libasn1cskeletons.a in order to improve
    skeletons code coverage. When the skeleton files are copied the lcov will
    report coverage for each copy separatly.
  • When -Wpedantic is not supported try adding the -pedantic instead.
    GCC prior to 4.8 does not supprot -Wpedantic.
    See https://gcc.gnu.org/gcc-4.8/changes.html
    The travis-ci currently builds with gcc-4.6.3
  • Fix few duplicate 'const' warnings

To generate the code coverage report you need gcov and lcov installed
and then execute

 ./configure --enable-code-coverage
 make check-code-coverage

 Writing directory view page.
 Overall coverage rate:
   lines......: 76.5% (10519 of 13759 lines)
   functions..: 85.5% (491 of 574 functions)
   branches...: 57.5% (7040 of 12250 branches)
 file:///home/user/asn1c/asn1c-0.9.28-coverage/index.html

Open the index.html with a web browser
Link asn1c/tests with libasn1cskeletons.a in order to improve
skeletons coverage. When the skeleton files are copied the lcov will
report coverage for each copy separatly.
GCC prior to 4.8 does not supprot -Wpedantic.
See https://gcc.gnu.org/gcc-4.8/changes.html

The travis-ci currently builds with gcc-4.6.3

  $ gcc --version
  gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
error: duplicate 'const' [-Werror=edantic]
@velichkov
Copy link
Contributor Author

To generate the coverage report when compiling with clang add GCOV="llvm-cov-" to configure

CC="clang-3.5" GCOV="llvm-cov-3.5" ./configure --enable-Werror --enable-code-coverage

../../skeletons/GeneralizedTime.c:7:0: warning: "_BSD_SOURCE" redefined [enabled by default]
 #define _BSD_SOURCE     /* for timegm(3) */
mouse07410 referenced this pull request in mouse07410/asn1c Jan 31, 2017
@vlm
Copy link
Owner

vlm commented Mar 26, 2017

Merged manually with slight changes, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants