Gcov - a Test Coverage Program
gcov is a tool you can use in conjunction with GCC to test code coverage in your programs. It’s no need to install independently. gcov works only on code compiled with GCC. It is not compatible with any other profiling or test coverage mechanism.
Lcov - the LTP GCOV extension
LCOV is a graphical front-end for GCC's coverage testing tool gcov. It collects gcov data for multiple source files and creates HTML pages containing the source code annotated with coverage information. It also adds overview pages for easy navigation within the file structure. LCOV supports statement, function and branch coverage measurement.
Installing LCOV
The LCOV package is available as either RPM or tarball from: http://ltp.sourceforge.net/coverage/lcov.php
I got lcov-1.9.tar.gz. To install the tarball, unpack it to a directory and run:
[root@Server lcov-1.9]# make install
Build -- Execute Shell in Hudson
Command 1
#generate .info file for test case codes
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib64:/lib:/lib64:/usr/local/lib
cd ./client/testunit/lcov
make clean
make
./driver
gcov *.cpp *.h
lcov -d . -t 'driver' -o 'test.info' -b . -c
Command 2
#generate .info file for client codes
cd ./client/src/client
gcov *.cpp
lcov -d . -t '../../testunit/lcov/driver' -o 'client.info' -b . -c
Command 3
#merge the .info files and generate html report
cd ./client
lcov -add-tracefile ./src/client/client.info -a ./testunit/lcov/test.info -o ./result.info
genhtml -o result result.info
#copy the html pages to apache web server, can be ignored the two lines
rm -rf /usr/local/apache2/htdocs/MPI/
cp -rf ./result /usr/local/apache2/htdocs/MPI/
Post-build Actions
Publish HTML reports 加入index.html的路径,如图所示