Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Linux Tools Project » Regex based file filter for Gcov coverage outputs(feature request for Gcov integration plugin)
Regex based file filter for Gcov coverage outputs [message #987923] Wed, 28 November 2012 11:39 Go to next message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
Hello,

I'm using the latest release version of the Gcov plugin together with the google test framework to unit test embedded C software components coming from the hardware abstraction layer.
To fake or mock up given aspects of these low level C modules without polluting the production code itself with conditional compilation switches for testing purposes, I have to include the C module itself into the unit test module instead of the C module's interface header. This way it is possible to make all necessary changes to the C module under test using the C preprocessor without the need to alter the production code.

Example:
#include "gtest/gtest.h" /* include gtest */

/* override INLINE compiler abstraction macro for unit testing with GCC */
#include "compiler.h"
#undef INLINE
#define INLINE inline
#include "module.c" /* include module under test */

/* unit testing code */
...


The approach works perfectly, without altering the production code or polluting it with test code, it was possible to overcome even on the most wicked issues I've seen so far. My only problem is that as my module under test is actually parsed into the unit testing module itself as an include, when I try to use the Gcov plugin to output the coverage info of my compiled module or binary it also outputs all the google test related header files.

Would it be possible to implement an ignore list for files to filter out the unwanted header or other files from the coverage output?

E.g. in the summary view for the whole binary it would be great if I could apply a generic filter to discard a list of files based on a regular expression. A regex could include patters, lists and everything so it would be very generic and would only need to test for the name of the element on the list of the files in the summary. The regex pattern could be input on the open coverage results... dialog window.

Currently if I want to show coverage details for a given C file only, eclipse opens google test's 20+ header files too which would be possible to filter using the same regex based filter approach.
Re: Regex based file filter for Gcov coverage outputs [message #988267 is a reply to message #987923] Thu, 29 November 2012 03:35 Go to previous messageGo to next message
Xavier Raynaud is currently offline Xavier Raynaud
Messages: 15
Registered: February 2012
Junior Member
Hi,

Thanks for the suggestion, it's a good idea.

I suggest to implement it like the "filter" text in the "Error Log" view:
http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.user/images/error_log.png

Is this proposal suitable for your needs ?
Re: Regex based file filter for Gcov coverage outputs [message #988330 is a reply to message #988267] Thu, 29 November 2012 07:48 Go to previous messageGo to next message
Tamas Kleiber is currently offline Tamas Kleiber
Messages: 20
Registered: December 2010
Junior Member
Most unfortunately I do not have this Error Log view and whatever I tried I could not manage to install it. But I think it is the same as the filter on the Help/Install New Software... menu. If it is so, than according to my understanding, with that approach the filtering is applied after processing all possible inputs. This is useful when we are searching for some given elements from a big list of files for example. But my use case or need is a bit different. So this "on the fly" filter is useful and I would implement it if possible for the gcov tab with the coverage summary, but also I would need something different.

My goals would be these:

  • If I select the option to Show coverage for the whole selected binary file, I would like to see only files and elements which are not found on an ignore list.
  • If I select the option to Show coverage details for "module X" only, eclipse should only open the source files with coverage overlay which are not found on an ignore list.
  • The ignore list input field should be provided on the Gcov - Open coverage results... popup window or at least the ignore list should be ready before the Open coverage popup window is closed so that files from the ignore list are not opened or not placed into the Summary list.
  • The ignore list should be kept or saved so that the user does not need to reenter it all the time. Best would be if the ignore list would be saved on a per project basis.


So basically I need to filter out the unit testing environment related source and header files. The unit testing environment does not change often so the related file names are usually known and can be specified easily with a regular expression.

For example, the following regular expression matches and therefore bans all google test framework related files: "gtest.*?.[hc]"

The next bans google test and the fake function framework: "gtest.*?.[hc]|fff.h"

The next bans all previous stuff plus some C/C++ headers used by the unit testing framework only: "gtest.*?.[hc]|fff.h|basic_|stl_"


So if the proposed filter really works the same way as the one on the Install New Software window, than it does not solve my issue completely as if I would want to use the Show coverage details for "module X" only option than still 20+ files would be opened due to the unit testing framework's own files. Best would be to skip loading and opening all those files which we do not want to see.

Do you know lcov? In the latest version there is a new option: Added options --external and --no-external to include/exclude external source files such as standard libary headers. Now lcov also excludes and skips processing of given files based on their location. This approach would also solve my problem as the unit testing framework's source files are never mixed with the test or production code itself. So even an ignore list for directories would be sufficient for me.
Re: Regex based file filter for Gcov coverage outputs [message #989107 is a reply to message #988330] Tue, 04 December 2012 11:06 Go to previous message
Xavier Raynaud is currently offline Xavier Raynaud
Messages: 15
Registered: February 2012
Junior Member
A bug has bee filled out for this proposal:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=395733
Previous Topic:Using Valgrind with gdb in Eclipse
Next Topic:GCov integration plug-in only accepts executable files from loaded project folders
Goto Forum:
  


Current Time: Mon Jul 28 08:33:56 EDT 2014

Powered by FUDForum. Page generated in 0.01773 seconds