I am trying to perform a coverage test of a shared library. I have chosen for gcov/lcov due to the fact, that it is free and open source, which means, I can try it immediately (commercial software would need to be approved/purchased, a lot of decision would have to be made - it costs time).
The situation is as follows - the library - our product, written in Fortran is then us开发者_StackOverflowed for simulation software (ADAMS from MSC.Software, to be specific). I can compile the library with -fprofile-arcs -ftest-coverage and it works properly if used by ADAMS. However, no .gcda files are created.
There is a small test executable to test basic behaviour of the library (small subset of the methods). If I compile this executable with coverage tests switches, I get .gcda files for both the executable itself and the library.
The question is: is it possible to invoke gcov measurements for the library if the executable using the library was not compiled with coverage test switches? And if yes, how?
It is possible to write extensive test, but it will be almost like replicating ADAMS (or any other simulation package). Or have I chosen wrong coverage test tool and I should move to commercial products?
Thank you in advance.
Mike
It seems, there isn't any problem with code coverage test of the library that is invoked by proprietary software. One should only pay attention to compile all components with the same version of the compiler and use corresponding gcov version. In my case the library (in Fortran) was compiled with f77 (gcc-3.4.6), the component of it was compiled with newest gcc (gcc-4.4). The wrapper for the library used by ADAMS was compiled again with gcc-3.4.6 and gcov used was 4.1.
Using gcc-3.4.6 for all components delivered very appealing code coverage test results.
Consider the topic closed, but should anyone have questions, please ask. I'll gladly share my experience.
The way I compile my programs is usually to supply exactly the same switches to the compiler for ALL modules, so, no, I don't know if its possible to get gcov working when the executable was not compiled with the coverage switches.
However, what I then do is to post-process the output files from gcov, ignoring files relating to test code only, but keeping all files relating to code directly called by test code as well as library code called by itself.
精彩评论