[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1416689800-27146-1-git-send-email-fabf@skynet.be>
Date: Sat, 22 Nov 2014 21:56:40 +0100
From: Fabian Frederick <fabf@...net.be>
To: linux-kernel@...r.kernel.org
Cc: Fabian Frederick <fabf@...net.be>, Joe Perches <joe@...ches.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 1/1] scripts: add a graph generator based on checkpatch reports
This script generates a graph based on errors/warnings/checks detected
by checkpatch -f recursively on each files of a directory.
Results are grouped by subfolders and pushed in gnuplot datasets.
By default checkstat.png is generated with an histogram.
This script should always be called from kernel source root.
eg scripts/checkstat.pl fs
Cc: Joe Perches <joe@...ches.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Fabian Frederick <fabf@...net.be>
---
scripts/checkstat.pl | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 120 insertions(+)
create mode 100755 scripts/checkstat.pl
diff --git a/scripts/checkstat.pl b/scripts/checkstat.pl
new file mode 100755
index 0000000..8b7d451
--- /dev/null
+++ b/scripts/checkstat.pl
@@ -0,0 +1,120 @@
+#!/usr/bin/perl
+# (c) 2014, Fabian Frederick (fabf@...net.be)
+#
+# Based on scripts/checkpatch.pl
+#
+# This script generates a graph based on errors/warnings/checks detected
+# by checkpatch -f recursively on each files of a directory.
+# Results are grouped by subfolders.
+#
+
+use strict;
+use Getopt::Long;
+use File::Basename;
+use Chart::Gnuplot;
+
+my $P = $0;
+my $statdir = '.';
+my $files;
+my @cfiles = ();
+my %stat;
+my %stats;
+my $report;
+my $currentdir = '';
+
+my $checkpatch = "scripts/checkpatch.pl";
+my $output = "checkstat.png";
+my @dontcheck = qw/fs\/nls/;
+
+sub help {
+ my $text = << "EOM";
+Usage: $P [OPTION] [DIRECTORY]
+
+This script should always be called from kernel source root.
+
+Options:
+ --output name of generated png graph.
+EOM
+ my $std=shift;
+ if ($std == 1) {
+ print STDERR $text;
+ } else {
+ print $text;
+ }
+ exit;
+}
+
+GetOptions(
+ 'h|help' => \&help,
+ 'output=s' => \$output
+);
+
+if ($#ARGV >= 0) {
+ $statdir = @ARGV[0];
+}
+
+my $graphreport = Chart::Gnuplot->new(
+ output => $output,
+ yrange => [0, '*'],
+ imagesize => '3, 2',
+ xtics => {
+ rotate => '90 right',
+ },
+ bmargin => 15,
+ title => 'Linux Kernel: checkstat - Date: `date`'
+);
+
+$files = `find $statdir -name "*.c"`;
+@...les = split('\n', $files);
+
+#Execute checkpatch on each file and store results
+foreach my $file (@cfiles) {
+ print "checkpatch: $file: ";
+ $currentdir = dirname($file);
+
+ if (not grep(/^$currentdir$/, @dontcheck)){
+ $report = `$checkpatch -f --terse $file | tail -n 1`;
+
+ if ($currentdir ne $statdir) {
+ $currentdir =~ s/$statdir\///;
+ $currentdir =~ s/\/(.*)//;
+ $currentdir = $statdir."/".$currentdir;
+ }
+ print "adding to ".$currentdir." stats\n";
+ my $i = 0;
+
+ foreach my $stat_type ("errors", "warnings", "checks") {
+ $report =~ m/(\d+)\s$stat_type/;
+ $stat{$currentdir}[$i++] += $1;
+ $stats{$stat_type}{$currentdir} += $1;
+ }
+ } else {
+ print "File in dontcheck list ...\n";
+ }
+}
+
+my @columns=();
+my %colors=(
+ errors => 'red',
+ warnings => 'orange',
+ checks => 'green'
+);
+
+#Reorder and push data in datasets.
+foreach my $stat_type (keys %stats) {
+ my @xdir=();
+
+ foreach my $dir (sort keys %{$stats{$stat_type}}){
+ push @xdir, [$dir, $stats{$stat_type}{$dir}];
+ }
+ push @columns, Chart::Gnuplot::DataSet->new(
+ points => \@xdir,
+ title => $stat_type,
+ color => $colors{$stat_type},
+ fill => {density => 1},
+ style => "histograms",
+ );
+}
+
+$graphreport->plot2d(@columns);
+print("graph generated: $output\n");
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists