I want to test a complex shared library (cxsc) with the help of cmake. After a lot of trial and error i managed to create a html coverage report but the lines I test, with the boost testing framework, are still red.
This is the script I use to create the coverage report:
rm -fr build_coverage
mkdir build_coverage
cd build_coverage
cmake \
-DCMAKE_BUILD_TYPE=Coverage \
..
make
cd ../tests
make clean
make
cd ../build_coverage
make cxsc_coverage
The cmake part where the coverage report gets created:
# Cleanup lcov
COMMAND ${LCOV_PATH} --zerocounters --directory ${CMAKE_CURRENT_SOURCE_DIR}/build_coverage/CMakeFiles/cxsc.dir/src
COMMAND ${LCOV_PATH} --capture --initial --no-external --directory ${CMAKE_CURRENT_SOURCE_DIR}/build_coverage/CMakeFiles/cxsc.dir/src --output-file ${_outputname}.before
# Run tests
COMMAND LD_LIBRARY_PATH=${CMAKE_CURRENT_SOURCE_DIR}/build_coverage ${_testrunner} ${ARGV3}
# Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --capture --no-checksum --no-external --directory ${CMAKE_CURRENT_SOURCE_DIR}/build_coverage/CMakeFiles/cxsc.dir/src --output-file ${_outputname}.after
COMMAND ${LCOV_PATH} --add-tracefile ${_outputname}.before --add-tracefile ${_outputname}.after --output-file ${_outputname}.info
COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info
Makefile of the test binary (I think this is where the error is):
g++ \
-o test_runner \
main.cpp \
test_interval.cpp \
-I./../src \
-I./../src/rts \
-I./../src/asm \
-I./../src/fi_lib \
-I./../build_coverage \
-L./../build_coverage \
-lcxsc \
-Wall -Winline \
-lboost_unit_test_framework
This is what happens:
cmake -DCMAKE_BUILD_TYPE=Coverage ..
build_coverage directory is created with atarget.dir
directory and *.gcno files in itcd tests && make
Test executable is created and linked against the shared library in thebuild_coverage
directory (Maybe here is my mistake)make coverage
Coverage data is collected and tests are executed
Aucun commentaire:
Enregistrer un commentaire