7 #use Date::Manip qw(ParseDate UnixDate); #sudo apt-get install libdate-manip-perl
8 #use Date::Calc qw(Delta_Days); #sudo apt-get install libdate-calc-perl
10 #------------------------------------------------------------------------------
12 #------------------------------------------------------------------------------
16 sub pr2
{ print STDERR
"@_\n"; }
17 sub pr
{ print "@_\n"; }
18 sub mylog
{ print STDERR
"@_\n" if $debug; }
25 #------------------------------------------------------------------------------
27 #------------------------------------------------------------------------------
30 my $so = 0; #spatch ok
44 my $sumlineP = 0; #whole git
46 my $sumlinePchange = 0;
55 my $duration = 0; # in days
59 #------------------------------------------------------------------------------
61 #------------------------------------------------------------------------------
62 $spfile = `make sp_file`;
65 if($spfile =~ /(rule|mega|bt)(\d+)\.cocci/) { $ruleno = "$2"; }
67 #------------------------------------------------------------------------------
69 #------------------------------------------------------------------------------
71 #$cedescr = `make ce_descr`;
73 #print STDERR (Dumper($cedescr));
74 open TMP
, "Makefile" or die "no Makefile file ?";
76 if(/^(CE)?DESCRIPTION=["'](.*)["']/) { $cedescr = $2; }
81 #$cedescr =~ s/\\/\\\\/g;
82 #$cedescr =~ s/\f/\\f/g;
83 #$cedescr =~ s/\t/\\t/g;
85 #------------------------------------------------------------------------------
87 #------------------------------------------------------------------------------
88 my $files = `make source_files`;
90 @cfiles = split /\s+/, $files;
92 $nbfiles = scalar(@cfiles);
94 #------------------------------------------------------------------------------
96 #------------------------------------------------------------------------------
98 my ($linefile) = `wc -l $_`;
100 die "wierd wc output" unless $linefile =~ /^(\d+) /;
102 mylog
"filesize $_ $1";
106 #------------------------------------------------------------------------------
108 #------------------------------------------------------------------------------
110 `cat $spfile | perl -p -e "s/\\/\\/.*//g;" | grep -v '^[ \t]*\$' | wc -l`;
114 #------------------------------------------------------------------------------
116 #------------------------------------------------------------------------------
117 if(!(-e
"README")) { pr2
"no README file ?"; }
119 open TMP
, "README" or die "no README file ?";
121 if (/\[bug\]/ || /status\]\s*bug/ || /status\]\s*BUG/ ) {
123 # can also look for [semibug] but it's often related to [corrected_c] kind of pbs
124 #|| /status\]\s*semi-bug/
126 #pr2 "OLD BUG FORMAT: $_";
134 #------------------------------------------------------------------------------
136 #------------------------------------------------------------------------------
139 ($sumlineP) = `cat gitinfo |wc -l`;
145 #------------------------------------------------------------------------------
146 # Number of authors and duration
147 #------------------------------------------------------------------------------
152 open TMP
, "gitinfo" or die "no gitinfo file ?";
163 #can also do: egrep "^Author" gitinfo | sort | uniq | wc -l
164 if (/^Author: (.*)/) {
168 # if(/^Date: (.*) ([-+]\d+)?/) {
169 # my $date = ParseDate($1);
170 # if (!$date) { die "bad date" }
172 # my ($year, $month, $day) = UnixDate($date, "%Y", "%m", "%d");
173 # my @current = ($year, $month, $day);
175 # @mindate = @current;
176 # @maxdate = @current;
179 # my $diff1 = Delta_Days(@mindate, @current);
180 # if($diff1 < 0) { @mindate = @current; }
181 # my $diff2 = Delta_Days(@current, @maxdate);
182 # if($diff2 < 0) { @maxdate = @current; }
184 # #pr2 "$diff1, $diff2";
193 # my $diff = Delta_Days(@mindate, @maxdate);
194 # if($diff == 1 || $diff == 0) {
195 # $duration = "1 day";
197 # elsif($diff < 31) {
198 # $duration = "$diff days";
200 # elsif($diff > 365) {
201 # my $years = int($diff / 365);
202 # my $s = plural($years);
203 # $duration = "$years year$s";
205 # elsif($diff > 31) {
206 # my $months = int($diff / 31);
207 # my $s = plural($months);
208 # $duration = "$months month$s";
210 # else { die "impossible"; }
212 $duration = "xxx months";
214 $numauthors = scalar(keys %{$h});
220 #------------------------------------------------------------------------------
221 # Size P (only change for .c in drivers/ or sounds/ (the test files))
222 #------------------------------------------------------------------------------
225 foreach my $c (@cfiles) {
226 die "wierd: $c, with $spfile" unless ($c =~ /(.*)\.c$/);
229 my $aft = "$base.res";
230 if(-e
"corrected_$base.res") {
231 $aft = "corrected_$base.res";
232 mylog
"found corrected";
235 open TMP
, "diff -u -b -B $bef $aft |";
241 if (/^\+[^+]/) { $onlychange++; }
242 if (/^\-[^-]/) { $onlychange++; }
244 $sumlinePchange += $onlychange;
245 $sumlineP2 += $count;
248 #------------------------------------------------------------------------------
250 #------------------------------------------------------------------------------
251 foreach my $c (@cfiles) {
252 die "" unless ($c =~ /(.*)\.c$/);
255 my $diagnosefile = "";
258 if(-e
"$base.c.ok") { $ok++; $diagnosefile = "$base.c.ok"; }
259 if(-e
"$base.c.failed") { $fa++; $diagnosefile = "$base.c.failed"; }
260 if(-e
"$base.c.spatch_ok") { $so++; $diagnosefile = "$base.c.spatch_ok"; }
261 if(-e
"$base.c.gave_up") { $gu++; $diagnosefile = "$base.c.gave_up"; }
263 open TMP
, $diagnosefile or die "no diagnose $base: $diagnosefile";
267 # before -test_okfailed
268 # if (/real[ \t]+([0-9])+m([0-9]+)[.]([0-9]+)/) {
271 # $time = $1 * 60.0; # minutes
272 # $time += $2; # seconds
273 # $time += $3 / 1000.0; # 1/1000th sec.
275 # pr2 (sprintf "%4.1fs\n", $time);
276 # printf "I: %15s & %4.1fs\n", $c, $time;
284 mylog
(sprintf "%4.1fs\n", $time);
285 printf "I: %15s & %4.1fs\n", $c, $time;
291 die "not found time information in $diagnosefile" unless $found == 1;
294 $maxtime = $time if $time > $maxtime;
298 #------------------------------------------------------------------------------
300 #------------------------------------------------------------------------------
302 my $correct = $ok + $so;
304 my $pourcentcorrect = ($correct * 100.0) / $nbfiles;
305 my $avglines = $sumlinefiles / $nbfiles;
306 my $avgtime = $sumtime / $nbfiles;
309 my $ratioPvsSP = $sumlineP / $sizeSP;
310 my $ratioPvsSP2 = $sumlineP2 / $sizeSP;
313 #------------------------------------------------------------------------------
315 #------------------------------------------------------------------------------
320 map { mylog
"\t$_"; } @cfiles;
321 pr
"----------------------------------------";
324 pr
"!!Total files = $nbfiles";
325 printf "!!AvgLine = %.1fl\n", $avglines;
327 #pr " Correct number = $correct";
328 printf "!!Correct = %.1f%s\n", $pourcentcorrect, "%";
330 pr
"!!Human errors = $errors";
332 pr
"!!Size SP = $sizeSP";
333 pr
"!!Size P = $sumlineP";
334 pr
"!!Size P (change only) = $sumlinePchange";
336 printf "!!Ratio P/SP = %3.1f\n", $ratioPvsSP;
339 printf "!!RunTime = %.1fs\n", $sumtime;
340 printf "!!MaxTime = %.1fs\n", $maxtime;
341 printf "!!AvgTime = %.1fs\n", $avgtime;
343 my $totalstatus = $ok + $fa + $so + $gu;
344 mylog
"----------------------------------------------------------------";
345 mylog
"Sanity checks: nb files vs total status: $nbfiles =? $totalstatus";
349 printf "L: %20s (r%3s) & %5.1f%% & %5dfi & %2de & %6.1fx & %6.1fs \n",
350 $cedescr, $ruleno, $pourcentcorrect, $nbfiles, $errors, $ratioPvsSP, $sumtime;
353 # Mega, Complex, Bluetooth
355 printf "M: %60s & %5d & %6d (%d) & %2d & %s & %2d & %3d & %6.0fx & %6.1fs (%.1fs) & %5.0f\\%% \\\\\\hline%% SP: %s \n",
356 $cedescr, $nbfiles, $sumlineP, $sumlinePchange, $numauthors, $duration, $errors, $sizeSP, $ratioPvsSP,
357 $avgtime, $maxtime, $pourcentcorrect, $spfile;
359 printf "C: %60s & %5d & %6d (%d) & %2d & %3d & %6.0fx & %6.1fs (%.1fs) & %5.0f\\%% \\\\\\hline%% SP: %s \n",
360 $cedescr, $nbfiles, $sumlineP, $sumlinePchange, $errors, $sizeSP, $ratioPvsSP,
361 $avgtime, $maxtime, $pourcentcorrect, $spfile;
363 printf "B: %60s & %5d & %5d (%d) & %3d & %6.0fx & %6.1fs (%.1fs) & %5.0f\\%% \\\\\\hline%% SP: %s \n",
364 $cedescr, $nbfiles, $sumlineP, $sumlinePchange, $sizeSP, $ratioPvsSP,
365 $avgtime, $maxtime, $pourcentcorrect, $spfile;