Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Code coverage: (14 Items)
   
Code coverage  
I'm able to compile some source with code coverage enabled and can activate the tool to show the session information. 
However it does not show the source code since it is looking in the wrong directory (project root) . I'm using make 
files that I created myself, with multiple source subdirectories underneath the project root.  

Is there a way to set the source code search diectory for thecode coverage part? And is it also possible to extend the 
coverage session period? Right now the executable stops after a few seconds of work
Re: Code coverage  
You can set the source look up path in your launch configuration "Source" tab. Add your extra source path to it.

If I understand your second question - you want your executable to run for a longer period so that you can gather more 
coverage data? If so you need to change your executable so that it does not exit after a few secodes (e.g. add some 
sleep() calls). Code Coverage does not stop the executable from finishing processing.
Re: Code coverage  
Setting the source path under the launch configuration does not help. In fact all the source directories are already 
there. 

I've attached a simple program that run without exiting when running without code coverage. When using code coverage it 
terminates after a couple of seconds 
Attachment: Text coverage.cpp 712 bytes
Re: Code coverage  
For your first question, can you attach your project? And which version of IDE are you running?

For your second question, you use "pause()" in the main thread to suspect it. But with Code Coverage, the thread is 
polled every (by default) 5 seconds for coverage data. It does not terminate the thread but it delivers a signal thus 
unlocks the pause(). You can put the infinite loop to the main thread.
Re: Code coverage  
Hi Andy,

Thanks for explaining why the example terminates. 

About the project file, I assume you mean the .cproject file which is attached. The coverage example resides in a src/
test directory where also  a .gcno file is created. 

I'm using IDE version 4.6.0 on a windows 7 host machine.

Thanks,
Wim
Attachment: Text .cproject 17.4 KB
Re: Code coverage  
Hi, Wim,

By saying "attach your project" I meant to export your project to a zip file. Looking at the .cproject file is not 
enough to see where the problem is. Because this is a standard make project, the make file and the project layout will 
contribute to the problem.

If attaching the whole project source is an issue for you, you can always remove your source code and only attach sample
 source to your project, but please keep your make file and project directory layout unchanged.

Thanks,
Andy
Re: Code coverage  
Hi Andy,

Attached you will find a zip file containing a  project that reassembles the way I build all of my projects . The 
attached project  covers testing  code coverage. It has the problem of not showing the source file

Thanks Wim
Attachment: Compressed file Coverage.zip 55.79 KB
Re: Code coverage  
Thanks for the attachment, however it is missing the "common.mk" file. It can't be built now.

Re: Code coverage  
Sorry about that. Here the new attachment  with the common.mk file. Building requires a windows enviromnent variable to 
be set. When you take a look at the common.mk file you will see the line ROOT_DIR = ${test} The 'test' environment 
variable points the the project root where the common.mk file resides.  building from the root directory requires you to
 execute ' make CMD=all', cleaning 
'make CMD=clean' within the source directory you can run make without the extra argument.

Thanks Wim 
Attachment: Compressed file Coverage.zip 25.12 KB
Re: Code coverage  
Hi, Wim,

There are at least three issues with the project setup:

1) The output .gcno file needs to be at the same directory of the executable "coverage".

2) The .gcno file needs to have the path to the "coverage.cpp". Compiler takes whatever you set in the compile line the 
path of the source file and writes to the .gcno file

3) In the main function, you can't sleep(1) in an infinite loop. This causes the thread not responding to the coverage 
signal so thus no data can be gathered.

I attached my test project to this reply to just demonstrate one of the setup which works. Please change it to your 
needs.

HTH,
Andy
Re: Code coverage  
Hi Andy,

I really appreciate your help !!!!! Thanks

One small problem though, did you forget to attach the example -:)

Regards Wim
Re: Code coverage  
Sorry. The file is attached this time.
Attachment: Compressed file Coverage_ajin.zip 19.3 KB
Re: Code coverage  
Hi Andy,

I have the example working but i don't like the idea that source, object, and executable code all end up in the same 
directory. Is there no other way to set the source path? 

Thanks Wim
RE: Code coverage  
Hi, Wim,

That's just my quick test to show the idea. You can set the binary output path to your real location and change to that 
path to do the compile. Since you are now using full path to the source in  your make file the gcno file will have the 
correct path to it - just make sure it resides together with the binary.

HTH,
Andy
Attachment: Text winmail.dat 2.28 KB