How to create and run a test coverage, then generate html report?

2,644 views
Skip to first unread message

Geni Suarez

unread,
Feb 14, 2017, 4:48:21 AM2/14/17
to cpputest
Helo, I'm new in embedded systems so unit testing too, let me apologyze if I say something wrong, first of all.

I'm trying to generate a coverage report with some test group that has passed the test and this console message has the only output I have. I would like to have the html view explained at cpputest oficial page. Concretely at "how to create a coverage report" page step. Since I have cpputest installed with apt-get install I can not follow the step:
 
$ cd cpputest_build
$ autoreconf .. -i
$ ../configure
$ make
$ make check_coverage

(Even this I have not much clear what kind of coverage can do this instruction if no test project directory has refered here). Here, They also say:
"This will generate a file called gcov_report.txt with the coverage report in plain text format." But I don't know of what test you will get your test coverage doing this by this way.

Anyways, a part of this, I try to enable test coverage in my make file but the only thing I get is a hmtl report with 0,0% coverage.
I would like to know some suggestions of the ways that other experienced people gets its test coverage runing correctly.

I will show you the main lines of my make file refered to coverage (I'm testing C code for embedded sw):

# gcc complier parameters (code coverage enabled)
CFLAGS= -g -Wall -fprofile-arcs -ftest-coverage
...
# g++ compiler parameters (code coverage enabled)
CPPFLAGS= -g -Wall -Wno-c++14-compat -fprofile-arcs -ftest-coverage
...
LDFLAGS= -L$(CPPUTEST_HOME)/cpputest_build/lib -lCppUTest -lgcov --coverage -lCppUTestExt

... (Here more lines about creating the o. and .c objects for my test.c and the last lines before output report):

##############################################################################
# Execute test and code coverage module
##############################################################################
test_exe:
@echo -e "\e[1;34m"
@echo -e "\r"
@echo -e "********************************************************\r"
@echo -e "* Executing tests... \r"
@echo -e "********************************************************\r"
./test_RFID_Drv.exe -c
@echo -e "\e[1;36m"
@echo -e "\r"
@echo -e "********************************************************\r"
@echo -e "* Code coverage results... \r"
@echo -e "********************************************************\r"
gcov -n ./test_RFID_Drv.c
@echo -e "\r"
gcov -n ./RFID_Drv.c
@echo -e "\r"


Any suggestion will be usefull.
Thanks in advance.

Matthew Piatt

unread,
Feb 27, 2017, 5:05:37 PM2/27/17
to cpputest
Hi Geni,

I use gcov with CppUTest. I use the raw text output of gcov normally, but I think a tool exists to generate HTML reports. Check out gcovr (http://gcovr.com/guide.html).

As for your empty coverage results, it looks like your compile flags to enable coverage are correct, but are you seeing any *.gcno and *.gcda files being emitted after you run your app? Also, what does the raw text output of gcov look like for your files? I suggest making gcov show proper coverage data in the simplest way before trying to make fancy HTML reports.

Are you are using CppUTest's MakefileWorker.mk? If so, you can use the GCOV_ARGS in the makefile to pass arguments to gcov.

Hope that helps!
Matthew

Geni Suarez

unread,
Mar 3, 2017, 6:10:07 PM3/3/17
to cppu...@googlegroups.com
Thanks for your help, Matthew. I will think about your suggestions and try. I'm sure they could be useful
best Regards :)





 



--
You received this message because you are subscribed to a topic in the Google Groups "cpputest" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cpputest/mAiWZX5gsP0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cpputest+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

subhasankari sargururaj

unread,
May 27, 2024, 3:02:28 AM5/27/24
to cpputest
hi i have used your suggestion it works for me like that anything in lcov


To unsubscribe from this group and all its topics, send an email to cpputest+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages