gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] Test coverage


From: Christian Gagneraud
Subject: Re: [gpsd-dev] Test coverage
Date: Tue, 05 Jun 2012 21:09:20 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120421 Thunderbird/12.0

On 03/06/12 10:48, Eric S. Raymond wrote:
Christian Gagneraud<address@hidden>:
Any comments on this?

You may have missed my previous reply.  I like the idea of having
a coverage check, but I haven't figured out how to read those reports.
Can you point me at documentation?

Well, I couldn't find proper documentation. But there's an option to add a legend which tells quickly how to read the report. I have generated a coverage of my aishub campaign. See [1] for an example with the legend added at the top.

Basically:
Blue line: executed
Red line: not executed
Blue "+": branch taken
Red "-": branch not taken
Red "#": branch not executed.

For a switch case, you will have as many +/-/# as cases.
For a if test, you will have as many +/-/# as combinations. For example if(foo) gives 2, if (bar || baz) gives 4, ...

A real example:
86 [ +  + ]: 71181766 :     if (strstr(buf, "\"type\":1,") != NULL
87 [ +  + ]: 30675126 :         || strstr(buf, "\"type\":2,") != NULL
88 [ +  + ]: 29305376 :         || strstr(buf, "\"type\":3,") != NULL) {

The if at line 86 has been evaluated 71M times, type 1, 2 and 3 tests have all been evaluated to true and to false. => This test has 8 execution branches, they have all been taken at least once.

For this one:
221 [ + + ][ - + ]:655462 : else if (strstr(buf, "\"dac\":235,") != NULL || strstr(buf, "\"dac\":250,") != NULL) {

The if has been evaluated 655462 times, dac 235 test has been evaluated to true and to false, dac 250 test has never been evaluated to true but has been evaluated to false at least once.
=> This test has 4 execution branches, only 3 have been taken at least once.

And finally
253 [ -  + ]:56780 :  else if (strstr(buf, "\"fid\":13,") != NULL) {
254 : 0 : status = json_read_object(buf, json_ais8_fid13, endptr);
255 [ #  # ]:    0 :                 if (status == 0) {

The if has been evaluated 56780 times, never to true, as a consequence, line 254 has never been executed, and the following if test has never been evaluated.


Chris.

[1] http://www.techworks.ie/pub/chris/gpsd/coverage/AIVDM-aishub/gpsd/gpsd.git/ais_json.c.gcov.html


--
Christian Gagneraud,
Embedded systems engineer.
Techworks Marine
1 Harbour road
Dun Laoghaire
Co. Dublin
Ireland
Tel: + 353 (0) 1 236 5990
Web: http://www.techworks.ie/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]