From: Peter O. <obe...@us...> - 2010-08-23 16:14:45
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv12581/bin Modified Files: lcov Log Message: lcov: add option to display summary coverage information Provide an option for users to determine the summary coverage information of one or more tracefiles. Example output: Summary coverage rate: lines......: 26.0% (78132 of 300355 lines) functions..: 34.9% (8413 of 24081 functions) branches...: 16.9% (32610 of 193495 branches) Index: lcov =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/lcov,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** lcov 23 Aug 2010 14:47:40 -0000 1.77 --- lcov 23 Aug 2010 16:14:37 -0000 1.78 *************** *** 140,143 **** --- 140,144 ---- sub get_func_found_and_hit($); sub br_ivec_get($$); + sub summary(); # Global variables & initialization *************** *** 189,192 **** --- 190,194 ---- our $opt_external; our $opt_no_external; + our @opt_summary; our $ln_overall_found; our $ln_overall_hit; *************** *** 274,277 **** --- 276,280 ---- "external" => \$opt_external, "no-external" => \$opt_no_external, + "summary=s" => \@opt_summary, )) { *************** *** 351,355 **** # Only --extract, --remove and --diff allow unnamed parameters ! if (@ARGV && !($extract || $remove || $diff)) { die("Extra parameter found: '".join(" ", @ARGV)."'\n". --- 354,358 ---- # Only --extract, --remove and --diff allow unnamed parameters ! if (@ARGV && !($extract || $remove || $diff || @opt_summary)) { die("Extra parameter found: '".join(" ", @ARGV)."'\n". *************** *** 439,442 **** --- 442,451 ---- $br_overall_found, $br_overall_hit) = diff(); } + elsif (@opt_summary) + { + ($ln_overall_found, $ln_overall_hit, + $fn_overall_found, $fn_overall_hit, + $br_overall_found, $br_overall_hit) = summary(); + } temp_cleanup(); *************** *** 481,484 **** --- 490,494 ---- -l, --list FILE List contents of tracefile FILE --diff FILE DIFF Transform tracefile FILE according to DIFF + --summary FILE Show summary coverage data for tracefiles Options: *************** *** 529,543 **** $list && $i++; $diff && $i++; if ($i == 0) { ! die("Need one of the options -z, -c, -a, -e, -r, -l or ". ! "--diff\n". "Use $tool_name --help to get usage information\n"); } elsif ($i > 1) { ! die("ERROR: only one of -z, -c, -a, -e, -r, -l or ". ! "--diff allowed!\n". "Use $tool_name --help to get usage information\n"); } --- 539,554 ---- $list && $i++; $diff && $i++; + @opt_summary && $i++; if ($i == 0) { ! die("Need one of options -z, -c, -a, -e, -r, -l, ". ! "--diff or --summary\n". "Use $tool_name --help to get usage information\n"); } elsif ($i > 1) { ! die("ERROR: only one of -z, -c, -a, -e, -r, -l, ". ! "--diff or --summary allowed!\n". "Use $tool_name --help to get usage information\n"); } *************** *** 3920,3923 **** --- 3931,3987 ---- } + # + # summary() + # + + sub summary() + { + my $filename; + my $current; + my $total; + my $ln_total_found; + my $ln_total_hit; + my $fn_total_found; + my $fn_total_hit; + my $br_total_found; + my $br_total_hit; + + # Read and combine trace files + foreach $filename (@opt_summary) { + $current = read_info_file($filename); + if (!defined($total)) { + $total = $current; + } else { + $total = combine_info_files($total, $current); + } + } + # Calculate coverage data + foreach $filename (keys(%{$total})) + { + my $entry = $total->{$filename}; + my $ln_found; + my $ln_hit; + my $fn_found; + my $fn_hit; + my $br_found; + my $br_hit; + + (undef, undef, undef, undef, undef, undef, undef, undef, + $ln_found, $ln_hit, $fn_found, $fn_hit, $br_found, + $br_hit) = get_info_entry($entry); + + # Add to totals + $ln_total_found += $ln_found; + $ln_total_hit += $ln_hit; + $fn_total_found += $fn_found; + $fn_total_hit += $fn_hit; + $br_total_found += $br_found; + $br_total_hit += $br_hit; + } + + + return ($ln_total_found, $ln_total_hit, $fn_total_found, $fn_total_hit, + $br_total_found, $br_total_hit); + } # *************** *** 4183,4187 **** $br_do, $br_found, $br_hit) = @_; ! info("Overall coverage rate:\n"); info(" lines......: %s\n", get_overall_line($ln_found, $ln_hit, "line", "lines")) --- 4247,4251 ---- $br_do, $br_found, $br_hit) = @_; ! info("Summary coverage rate:\n"); info(" lines......: %s\n", get_overall_line($ln_found, $ln_hit, "line", "lines")) |