[ros-users] Test Coverage?

Yamokoski, JD (JSC-ER)[FLORIDA INSTITUTE FOR HUMAN MACHINE COGNITION] john.d.yamokoski at nasa.gov
Tue Jul 8 14:06:29 UTC 2014


I got this working with rosbuild. My solution might not have been the most elegant, but I discovered that nearly any CXX compile and link flag (or maybe just one.. its been a long while since I looked at this) was getting clobbered or ignored if I set them after a call to rosbuild_init(). To make things pretty I pushed a lot of the settings to environmental variables. Then I created a cmake script (BuildOptions.cmake) to examine those environmental variables and set the appropriate flags. So for instance:

In BuildOptions.cmake, to turn on code coverage:

# Code Coverage Determination and add compiler flags
if (DEFINED ENV{CAPTURE_CODE_COVERAGE})
    set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage ${CMAKE_CXX_FLAGS}")
    set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage ${CMAKE_C_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "-lgcov ${CMAKE_EXE_LINKER_FLAGS}")
endif (DEFINED ENV{CAPTURE_CODE_COVERAGE})

Then in my ROS package CMakeLists.txt I just made sure to put a "include(BuildOptions)" before rosbuild_init().

Again, not the prettiest solution, but it worked for me.

JD

ps.. maybe I did this because I wanted to avoid having to a "target_link_library(gcov)" after the declaration of my target?? I dunno. Again, its been nearly a year and half since I hacked this together.

On 07/07/2014 10:18 AM, Fazzari, Kyle R CIV NSWCDD, G82 wrote:

I've been making good use of Google Test in my ROS projects (Fuerte, currently). I'm interested in looking at my code coverage, so I've been playing with using gcov etc. I'm not having any luck getting it to work, and I'm curious if others have.

I added set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -fprofile-arcs -ftest-coverage") to my CMakeLists.txt file, but when I run "make test" no gcov data is generated anywhere that I can see.

Does anyone have any experience using these three tools together (ROS, gtest, gcov)?

--------------------
Kyle Fazzari
Computer Engineer






_______________________________________________
ros-users mailing list
ros-users at lists.ros.org<mailto:ros-users at lists.ros.org>
http://lists.ros.org/mailman/listinfo/ros-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20140708/14be01aa/attachment.html>


More information about the ros-users mailing list