[Mono-devel-list] Re: coverage tool

Paolo Molaro lupus at ximian.com
Mon Jun 16 12:38:54 EDT 2003


On 06/12/03 Paolo Molaro wrote:
> This should be mostly useful for checking whether a test suite covers
> all the methods in an assembly. I'll add basic-block level coverage to
> the profiling API to make the tool more accurate in the future.

As promised, basic block coverage handling is now included in the tool
(in cvs it's mono/mono/profiler/mono-cov.c). It's not yet built by
default, I'll probably wait after the release for that, unless someone
is willing to test the build on win32/*bsd/osx/etc.

As an example, to check which methods are not fully covered in the
Stream classes when running tests/console.exe, you can do:

	mini --debug --profile=cov:corlib/Stream tests/console.exe

Note: --debug is needed to get filename and line number information
for basic blocks that are not executed, otherwise you'll get just the IL
code offset.
Example output is:

[...]
Not covered: System.IO.StreamWriter:.ctor (string,bool,System.Text.Encoding,int)
Partial coverage: System.IO.StreamWriter:Flush ()
	offset 0x0022 (/home/opt/ximian/mcs/class/corlib/System.IO/StreamWriter.cs: line: 148, col: 1)
	offset 0x000b (/home/opt/ximian/mcs/class/corlib/System.IO/StreamWriter.cs: line: 145, col: 1)
[...]

The column is always 1 because the debug code doesn't support column
information, but when it will be added the profiler can display it.
The offset is the offset of the IL instruction that starts the basic block
that was not reached during execution (this can help also when there are
more basic blocks on the same line and the column info is not accurate).

Hope this helps, happy hacking.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list