Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / scripts / extractor_README.pl
1 # Copyright 2012, INRIA
2 # Julia Lawall, Gilles Muller
3 # Copyright 2010-2011, INRIA, University of Copenhagen
4 # Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
5 # Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
6 # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
7 # This file is part of Coccinelle.
8 #
9 # Coccinelle is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, according to version 2 of the License.
12 #
13 # Coccinelle is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
20 #
21 # The authors reserve the right to distribute this or future versions of
22 # Coccinelle under other licenses.
23
24
25 #!/usr/bin/perl
26
27 use strict;
28
29 my $ok = 0; #ok+spatch-ok
30 my $wrong = 0; #Error, file level
31 my $fail = 0;
32 my $unknown = 0;
33 my $nbfiles = 0;
34
35 my $bugfix = 0; # site level ?
36 my $wrongsites = 0; # Error, site level
37
38 my $SP = "";
39
40 while(<>) {
41
42 if(/\[status\]/) { $nbfiles++; }
43
44 if(/\[status\]\s*(spatch-ok|ok)\b/) { $ok++; }
45 if(/\[status\]\s*(wrong)\b/) { $wrong++; }
46 if(/\[status\]\s*(fail)\b/) { $fail++; }
47
48 if(/\[status\]\s*(UNKNOWN)\b/) { $unknown++; }
49
50 if(/Cocci\s+file\s*:\s*(\w+.cocci)/) { $SP = $1; }
51
52 }
53
54 my $pourcentcorrect = ($ok * 100.0) / $nbfiles;
55
56 print "----------------------------------------\n";
57 print "!!Total files = $nbfiles\n";
58 print " Correct number = $ok\n";
59 printf "!!Correct = %3.1f\%\n", $pourcentcorrect;
60 print "!!Error = $wrong\n";
61 print "!!Bugfix (sites) = $bugfix\n";
62
63
64 my $sizeSP = `cat $SP | perl -p -e "s/\\/\\/.*//g;" | grep -v '^[ \t]*\$' | wc -l`;
65 chomp $sizeSP;
66 print "!!Size SP = $sizeSP\n";
67
68 my $gitinfo = `ls *.gitinfo`;
69 chomp $gitinfo;
70 print " gitinfo files = $gitinfo\n";
71
72 my $sizeP = `cat *.gitinfo | wc -l`;
73 chomp $sizeP;
74 print " Size P = $sizeP\n";
75
76 my $ratioSPvsP = ($sizeSP * 100.0) / $sizeP;
77 printf "!!Ratio SP vs P = %3.1f\%\n", $ratioSPvsP;
78
79 my $ratioPvsSP = $sizeP / $sizeSP;
80 printf "!!Ratio SP vs P = %3.1f\n", $ratioPvsSP;
81
82
83 my $totalstatus = $ok + $fail + $wrong + $unknown;
84 print "----------------------------------------------------------------\n";
85 print "Sanity checks: nb files = $nbfiles, total status = $totalstatus\n";
86 print "NB UNKNOWNS = $unknown\n" if $unknown > 0;