Debian Codegraph @

bin/gcov_info.pl

raw
1 #!/usr/bin/perl
2 #/*
3 # * This file is part of buteo-sync-plugins package
4 # *
5 # * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 # *
7 # * Contact: Sateesh Kavuri <[email protected]>
8 # *
9 # * This library is free software; you can redistribute it and/or
10 # * modify it under the terms of the GNU Lesser General Public License
11 # * version 2.1 as published by the Free Software Foundation.
12 # *
13 # * This library is distributed in the hope that it will be useful, but
14 # * WITHOUT ANY WARRANTY; without even the implied warranty of
15 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # * Lesser General Public License for more details.
17 # *
18 # * You should have received a copy of the GNU Lesser General Public
19 # * License along with this library; if not, write to the Free Software
20 # * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 # * 02110-1301 USA
22 # *
23 # */
24 # Author : Srikanth Kavoori
25 # Not Tested fully yet. There could be some issues.
26 # If you see any issues Let me know and i shall fix it :)
27 open(INPUTFILE, "<$ARGV[0]");
28 open(EXTRACTED_INFO,">$ARGV[2]");
29 open(EXTRACTED_FILES,">$ARGV[3]");
30
31 $exclude_string = "/usr/include/";
32 $exclude_string2 = ".h";
33 $coverage_count_string ="Lines executed:";
34 $include_string = ".cpp";
35 $count = 0;
36 $filecount = 0;
37 $coverage_percent = 0;
38
39 while(<INPUTFILE>) {
40 my($line) = $_;
41 if ($count == 3) {
42 $count = 0;
43 }
44 if(/$exclude_string/ || /$exclude_string2/) {
45 #print "Found usr_include or header file on line $. \n" ;
46 $count ++;
47 }
48
49 if( /$include_string/ ) {
50 $count = 0;
51 }
52
53 if ($count == 0) {
54 # Print the line to the extracted_info and add a newline
55 print EXTRACTED_INFO "$line\n";
56 if(/$coverage_count_string/) {
57 $filecount ++;
58 $index = rindex($line,':') + 1;
59 $percent = substr($line,$index);
60 $perc_index = rindex($percent,'%');
61 $percent = substr($percent,0,$perc_index);
62 $coverage_percent += $percent;
63 }
64 } else {
65 #count should be 1 or 2 omit the line
66 $count ++;
67 }
68 }
69 if($filecount != 0 ) {
70 $coverage_percent=sprintf("%.2f",$coverage_percent/$filecount);
71 }
72 print "Total No. of files : $filecount Coverage Percent : $coverage_percent ";
73 print EXTRACTED_INFO "Total No. of files : $filecount Coverage Percent : $coverage_percent ";
74 open(PERCENTFILE,">$ARGV[1]");
75 print PERCENTFILE "$coverage_percent\n" ;
76 close(PERCENTFILE);
77 close(INPUTFILE);
78 close(EXTRACTED_INFO);
79 close(EXTRACTED_FILES);