Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Display code coverage for CppUTests

Options
seanhead
seanhead Posts: 1

My Goal:

My project consists of three C++ libraries and a set of existing CppUTest tests that unit test the classes in those libraries. My goal is to see the code coverage, in the libraries that is caused by running the CppUTest tests.

The libraries and test are built by CMake. This is in a CentOS-7.2 Linux environment. I’ve been attempting to use Parasoft C/C++test Professional 10.4 with the Eclipse GUI to perform the required instrumentation.

What I’ve tried so far:

I created a new “C/C++” “Makefile Project with Existing Code” in the root directory of my project after CMake had been run. This drew all C++ files (including many undesired templates) without providing proper includes and linking. Even with many modifications, I was unable to successfully build the project using either Build Settings Options sources: “Use options from a build system” or “Specify all options manually”.

I’ve used cpptestscan and cpptesttrace to create build data file and import that file into cpptest. The BDF from cpptestscan loaded the entire project into one folder under “Navigator”. With some finagling, it was able to “build” the project (right clicking and selecting build), but “Build Application with Coverage Monitoring” had errors about duplicated test functions (hundreds of errors) and I was not patient enough to fix.
cmake -D CMAKE_C_COMPILER=/opt/programs/parasoft/cpptest/10.4/cpptestscan -D CMAKE_CXX_COMPILER=/opt/programs/parasoft/cpptest/10.4/cpptestscan .

The cpptesttrace BDF created four folders in Navigator, one for each library and one for the CppUTest (this reflects the layout of the project, each of the four, is in its own directory, with its own CMakeLists.txt file). None of these projects could be “built” through eclipse. My libraries returned many errors from “Build application with coverage monitoring”, first complaining that there was no “main()” function and then, strangely complaining that there were no references to the CppUTest functions. “Build and run application with coverage monitoring” on the CppUTest folder succeeded! However, despite printouts affirming all the tests were run, and many library functions exercised, only main() function, which runs the tests, was recorded as having any coverage.

Someone else linked in the cpptest coverage library (so I’m not 100% on the details), I used the “Load Application Coverage” to read these files. It returns successfully, but does not seem to show increased coverage. With some guidance, is there a proper way to do this that might allow the coverage to show up?

Help?

I’m looking to see if there is any way to fix my attempts so far to achieve my goal, or learn of any alternative methods that might prove more fruitful.

One remaining route I wasn’t sure how to pursue, is that I was told that cpptest could recognize and import the CppUTests; this might be more in line with the intent of cpptest application, (having access to a library, and separate tests). I was told this should happen automatically, but I did not see that happen in any of the ways I imported the project; is there a way to do that manually?