Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

CppUnit Code coverage Tool

Help
Dinesh
2011-07-07
2013-08-22
  • Dinesh
    Dinesh
    2011-07-07

    Hi
    I am using CppUnit framework in my C++ project for unit testing.  I want to use code covarage tool to chek the code covarage of my project.
    Is CppUnit provide any code coverage tool ? If not then please suggest any other tool whch can provide 100% code covarage.

       

     
  • Magnus Björk
    Magnus Björk
    2011-08-10

    CppUnit does not provide any code coverage analysis, but you can run it in combination with gcov.

     
    • Mike Finch
      Mike Finch
      2013-07-11

      Any hints on how to get gcov to work. I have it compiling and linking, but not creating any output files. CppUTest is running fine. Running in OSX. Added following lines to my make file:

      CPP_PLATFORM = Gcc

      CPPUTEST_CPPFLAGS += -DSUPPRESS_PRINTING
      CPPUTEST_CPPFLAGS += -fprofile-arcs
      CPPUTEST_CPPFLAGS += -ftest-coverage

      CPPUTEST_LDFLAGS += -lssl
      CPPUTEST_LDFLAGS += -lcrypto
      CPPUTEST_LDFLAGS += -fprofile-arcs

       
  • Mike Finch
    Mike Finch
    2013-07-12

    I found this in one of the sample files, but still no luck.

    GCOVFLAGS = -fprofile-arcs -ftest-coverage

    Thanks, Mike

     
    • John Dubchak
      John Dubchak
      2013-07-12

      Hi Mike,

      I know you said it was compiling and linking, but the only suggestion I
      have is that the concatenation of the flags, using +=, is not valid in
      a makefile on any *nix type of system.

      I suspect you've already tried changing those to the more traditional:

      CPPUTEST_CPPFLAGS = -DSUPPRESS_PRINTING
      CPPUTEST_CPPFLAGS = -fprofile-arcs:$(CPPUTEST_CPPFLAGS)
      CPPUTEST_CPPFLAGS = -ftest-coverage:$(CPPUTEST_CPPFLAGS)

      CPPUTEST_LDFLAGS = -lssl
      CPPUTEST_LDFLAGS = -lcrypto:$(CPPUTEST_LDFLAGS)
      CPPUTEST_LDFLAGS = -fprofile-arcs:$(CPPUTEST_LDFLAGS)

      That's the one thing that stands out to me.

      Hope that helps,
      John

      On Fri 12 Jul 2013 04:39:55 AM PDT, Mike Finch wrote:

      I found this in one of the sample files, but still no luck.

      GCOVFLAGS = -fprofile-arcs -ftest-coverage

      Thanks, Mike


      CppUnit Code coverage Tool
      https://sourceforge.net/p/cppunit/discussion/37108/thread/3d2343a6/?limit=25#4e6c


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cppunit/discussion/37108/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Mike Finch
    Mike Finch
    2013-07-15

    Thanks John. That also compiled and ran my test, but did not generate any .gcda, .gcno or *.gcov files.

     
  • Mike Finch
    Mike Finch
    2013-07-17

    After some help and a lot of Googling
    Either set of compile flags and the one linker flag do the trick. If I can determine a difference I'll post something.
    CPPUTEST_CPPFLAGS += -g -O0 --coverage

    CPPUTEST_CPPFLAGS += -fprofile-arcs

    CPPUTEST_CPPFLAGS += -ftest-coverage

    CPPUTEST_LDFLAGS += -lprofile_rt

     
  • nishant
    nishant
    2013-08-22

    can anyone explain me the proper steps to run gcov with CppUTest in unix project