[PATCH 2/3] aiaiai-test-patchset: make checkpatch optional like other checkers

Jacob Keller jacob.e.keller at intel.com
Tue May 27 10:56:35 PDT 2014


This modifies behavior of aiaiai such that checkpatch will be an option
much like sparse and coccinelle. In addition, only work if checkpatch.pl
is found in the project at the requested location. Will disable
checkpatch if it cannot be found.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
 aiaiai-test-patchset             | 32 ++++++++++++++++++++++----------
 doc/email/configuration.txt      |  3 +++
 doc/email/example-aiaiai.cfg     |  3 +++
 email/aiaiai-email-sh-functions  |  7 ++++++-
 email/aiaiai-email-test-patchset |  5 ++++-
 5 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/aiaiai-test-patchset b/aiaiai-test-patchset
index 90c790098e38..efaa07596ae8 100755
--- a/aiaiai-test-patchset
+++ b/aiaiai-test-patchset
@@ -239,7 +239,7 @@ cleanup_handler()
 }
 set_cleanup_handler cleanup_handler
 
-TEMP=`getopt -n $PROG -o j:,c:,i:,w:,C:,p,Q:,K:,M:,v,h --long jobs:,commit-id:,input:,workdir:,logdir:,confdir:,preserve,bisectability,sparse,smatch,cppcheck,coccinelle,quick-fixes:,targets:,keywords:,kmake-opts:,verbose,help -- "$@"` ||
+TEMP=`getopt -n $PROG -o j:,c:,i:,w:,C:,p,Q:,K:,M:,v,h --long jobs:,commit-id:,input:,workdir:,logdir:,confdir:,preserve,bisectability,sparse,smatch,cppcheck,coccinelle,checkpatch,quick-fixes:,targets:,keywords:,kmake-opts:,verbose,help -- "$@"` ||
 	fail_usage ""
 eval set -- "$TEMP"
 
@@ -253,6 +253,7 @@ sparse=
 smatch=
 cppcheck=
 coccinelle=
+checkpatch=
 quick_fixes=
 targets="all"
 keywords=
@@ -316,6 +317,8 @@ while true; do
 	--targets)
 		targets="$2"
 		shift
+	--checkpatch)
+		checkpatch="yes"
 		;;
 	-K|--keywords)
 		keywords="$(opt_check_read "$1" "$2")"
@@ -419,13 +422,20 @@ git diff -U0 -M "$commit_id1".."$commit_id2" > "$tmpdir/diff-for-diff-log"
 # Generate a diff for checkpatch.pl
 git diff -M "$commit_id1".."$commit_id2" > "$tmpdir/diff-for-checkpatch"
 
-# Make a copy of 'checlpatch.pl' and coccinelle scripts. This is safer than
+# Make a copy of 'checkpatch.pl' and coccinelle scripts. This is safer than
 # using them directly from the git tree because we'll apply patches under test
-# there, and the patches may also change 'checlpatch.pl' or coccinelle scripts.
-mkdir -p $verbose "$tmpdir/checkpatch" >&2
-checkpatch_pl="$tmpdir/checkpatch/checkpatch.pl"
-git show "$commit_id1:scripts/checkpatch.pl" > "$checkpatch_pl"
-chmod $verbose u+x "$checkpatch_pl" >&2
+# there, and the patches may also change 'checkpatch.pl' or coccinelle scripts.
+if [ -n "$checkpatch" ]; then
+	if git cat-file -e "$commit_id1:scripts/checkpatch.pl" 2>/dev/null; then
+		mkdir -p $verbose "$tmpdir/checkpatch" >&2
+		checkpatch_pl="$tmpdir/checkpatch/checkpatch.pl"
+		git show "$commit_id1:scripts/checkpatch.pl" > "$checkpatch_pl"
+		chmod $verbose u+x "$checkpatch_pl" >&2
+	else
+		verbose "Can't find checkpatch.pl.. disabling checkpatch tests."
+		checkpatch=
+	fi
+fi
 
 if [ -n "$coccinelle" ]; then
 	if git cat-file -e "$commit_id1:scripts/coccinelle"; then
@@ -440,8 +450,10 @@ if [ -n "$coccinelle" ]; then
 fi
 
 # Run checkpatch.pl in backgound.
-test_checkpatch &
-pid_checkpatch="$!"
+if [ -n "$checkpatch" ]; then
+	test_checkpatch &
+	pid_checkpatch="$!"
+fi
 
 # Search for keywords
 if [ -n "$keywords" ]; then
@@ -464,7 +476,7 @@ for defconfig in $defconfigs; do
 	test_configuration "$defconfig"
 done
 
-wait "$pid_checkpatch" || die "checkpatch failed"
+[ -z "$checkpatch" ]   || wait "$pid_checkpatch" || die "checkpatch failed"
 [ -z "$keywords" ]     || wait "$pid_keywords" || die "aiaiai-match-keywords failed"
 [ -z "$pid_bisect" ]   || wait "$pid_bisect"   || die "aiaiai-test-bisectability failed"
 
diff --git a/doc/email/configuration.txt b/doc/email/configuration.txt
index 3ba16a48ff4d..fba254cce889 100644
--- a/doc/email/configuration.txt
+++ b/doc/email/configuration.txt
@@ -134,6 +134,9 @@ additive.
 * coccinelle
     A boolean (0 or 1) indicating whether to use the coccinelle scripts during
     static analysis.
+* checkpatch
+    A boolean (0 or 1) indicating whether to use checkpatch.pl for testing
+    patches. Requires kernel project with checkpatch provided.
 
 The following options do not have default settings per project and must be
 specified for each project.
diff --git a/doc/email/example-aiaiai.cfg b/doc/email/example-aiaiai.cfg
index e9f7585769d4..ba780de11cf4 100644
--- a/doc/email/example-aiaiai.cfg
+++ b/doc/email/example-aiaiai.cfg
@@ -136,6 +136,9 @@
 	# Set to (1) to enable coccinelle scripts during kernel builds
 	coccinelle = 1
 
+	# Set to (1) to enable checkpatch.pl check during testing
+	checkpatch = 1
+
 
 # The e-mail front-end may operate on several project. Each project has its
 # own kernel tree, kernel configuration, and some other settings. These are
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index ad652606ed4b..5656b53b4282 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -257,7 +257,7 @@ parse_config()
 # __dcfg_configs, __dcfg_always_cc, __dcfg_reply_to_all, __dcfg_accept_notify,
 # __dcfg_unwanted_keywords, __dcfg_kmake_opts, __dcfg_targets,
 # __dcfg_defconfigdir, __dcfg_bisectability, __dcfg_sparse, __dcfg_smatch,
-# __dcfg_cppcheck, __dcfg_coccinelle
+# __dcfg_cppcheck, __dcfg_coccinelle, __dcfg_checkpatch
 #
 # It is expected that this is used internally by the parse_prj_config and
 # should not normally be called outside of this file.
@@ -280,6 +280,7 @@ __parse_default_config()
 	__dcfg_smatch="$(ini_config_get "$cfgfile" "defaults" "smatch")"
 	__dcfg_cppcheck="$(ini_config_get "$cfgfile" "defaults" "cppcheck")"
 	__dcfg_coccinelle="$(ini_config_get "$cfgfile" "defaults" "coccinelle")"
+	__dcfg_checkpatch="$(ini_config_get "$cfgfile" "defaults" "checkpatch")"
 }
 
 # Similar to "parse_config", but parses a project configuration section. If the
@@ -369,6 +370,10 @@ parse_prj_config()
 	pcfg_coccinelle="$(ini_config_get "$cfgfile" "prj_$prj" "coccinelle")"
 	ini_config_is_set "$cfgfile" "prj_$prj" "coccinelle" || pcfg_coccinelle="$__dcfg_coccinelle"
 	pcfg_coccinelle="$(config_check_boolean "coccinelle" "$pcfg_coccinelle")"
+
+	pcfg_checkpatch="$(ini_config_get "$cfgfile" "prj_$prj" "checkpatch")"
+	ini_config_is_set "$cfgfile" "prj_$prj" "checkpatch" || pcfg_checkpatch="$__dcfg_checkpatch"
+	pcfg_checkpatch="$(config_check_boolean "checkpatch" "$pcfg_checkpatch")"
 }
 
 # Compose (but not send) e-mail reply. This function assumes that the following
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index 5a1cebfc3d3b..f2a463908b43 100755
--- a/email/aiaiai-email-test-patchset
+++ b/email/aiaiai-email-test-patchset
@@ -330,11 +330,13 @@ sparse=
 smatch=
 cppcheck=
 coccinelle=
+checkpatch=
 [ "$pcfg_bisectability" != "1" ] || bisectablity="--bisectability"
 [ "$pcfg_sparse" != "1" ] || sparse="--sparse"
 [ "$pcfg_smatch" != "1" ] || smatch="--smatch"
 [ "$pcfg_cppcheck" != "1" ] || cppcheck="--cppcheck"
 [ "$pcfg_coccinelle" != "1" ] || coccinelle="--coccinelle"
+[ "$pcfg_checkpatch" != "1" ] || checkpatch="--checkpatch"
 
 # Create the Cc list for replies that we'll be sending
 if [ "$pcfg_reply_to_all" = "1" ]; then
@@ -358,7 +360,8 @@ commit="$(fetch_header "X-Aiaiai-Commit" < "$hookoutput")"
 # Test the path (or patch-set)
 verbose "Test configs \"$pcfg_configs\" branch \"$pcfg_branch\" of \"$pcfg_path\""
 aiaiai-test-patchset $verbose ${cfg_preserve_files:+--preserve} \
-	${pcfg_targets:+--targets "$pcfg_targets"} $bisectability $sparse $smatch $cppcheck $coccinelle \
+	${pcfg_targets:+--targets "$pcfg_targets"} $bisectability \
+	$sparse $smatch $cppcheck $coccinelle $checkpatch \
 	-i "$mbox" -j "$cfg_jobs" -c "$commit" -w "$tmpdir" \
 	${pcfg_defconfigdir:+-C "$pcfg_defconfigdir"} \
 	${pcfg_unwanted_keywords:+-K "$pcfg_unwanted_keywords"} \
-- 
1.9.0




More information about the aiaiai mailing list