[PATCH 5/6] email: add "debug" section to configuration file

Jacob Keller jacob.e.keller at intel.com
Mon Mar 10 16:46:13 PDT 2014


This patch further extends the configuration file so that it has a debug
section which currently includes replacements for test-mode and preserve
options. These options are very useful for debugging aiaiai, but today
cannot easily be changed without modifying the command line. Instead,
remove them from the options and include them via the configuration
file.

I chose not to add "verbose" to this list, because we actually use
verbose earlier than we parse the configuration. It may still be worth
coming up with some interface where command line options overwrite
configuration options, but I wasn't sure the best way to handle this
yet.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
 doc/email/example-aiaiai.cfg     | 10 ++++++++++
 email/aiaiai-email-lda           | 12 +++---------
 email/aiaiai-email-sh-functions  |  9 +++++++--
 email/aiaiai-email-test-patchset | 21 +++++----------------
 4 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/doc/email/example-aiaiai.cfg b/doc/email/example-aiaiai.cfg
index f94b4958f14c..e41c36143137 100644
--- a/doc/email/example-aiaiai.cfg
+++ b/doc/email/example-aiaiai.cfg
@@ -44,6 +44,16 @@
 	# aiaiai will insert it for you.
 	built_preamble = I have tested your changes
 
+# These options are probably not useful, but may help debug issues with aiaiai
+[debug]
+	# Set to (1) to disable sending reply emails when a patch is tested.
+	# This can help prevent spam while testing or debugging aiaiai.
+	disable_notifications = 0
+
+	# Set to (1) to preserve generated files instead of allowing aiaiai to
+	# cleanup after itself.
+	preserve_files = 0
+
 # The "defaults" section specifies various default settings for projects. These
 # values are overridden by the same values in the prj_* sections, so you may
 # customize the settings per project if desired.
diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda
index ded1641b2d94..c0a18875ff20 100755
--- a/email/aiaiai-email-lda
+++ b/email/aiaiai-email-lda
@@ -51,8 +51,6 @@ Options:
                              minutes ago from the mail archive directory;
       --reap-incomplete=MIN  remove all incomplete patch series older than
                              current time minus MIN minutes;
-      --test-mode            test mode - work as usually, but do not send
-                             replies;
   -v, --verbose              be verbose;
   -h, --help                 show this text and exit.
 EOF
@@ -111,10 +109,10 @@ reject_and_reply()
 
 	[ -z "$verbose" ] || cat -- "$lda_tmp/mail" >&2
 
-	if [ -z "$test_mode" ]; then
+	if [ "$cfg_disable_notifications" != "1" ]; then
 		mutt -x -H "$lda_tmp/mail" </dev/null
 	else
-		verbose "Do not actually send the email - we are in test mode"
+		verbose "Email notifications have been disabled in the configuration file"
 	fi
 }
 
@@ -470,20 +468,16 @@ cleanup_handler()
 }
 set_cleanup_handler cleanup_handler
 
-TEMP=`getopt -n $PROG -o v,h --long test-mode,reap-archive:,reap-incomplete:,verbose,help -- "$@"` ||
+TEMP=`getopt -n $PROG -o v,h --long reap-archive:,reap-incomplete:,verbose,help -- "$@"` ||
 	fail_usage ""
 eval set -- "$TEMP"
 
-test_mode=
 archive_min=
 incomplete_min=
 verbose=
 
 while true; do
 	case "$1" in
-	--test-mode)
-		test_mode=y
-		;;
 	--reap-archive)
 		archive_min="$(opt_check_number "$1" "$2")"
 		shift
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index 9e17f70cb02b..440e358daff9 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -139,7 +139,8 @@ ini_config_get_or_die()
 # file:
 #
 # cfg_ownname, cfg_ownmail, cfg_adminname, cfg_adminmail, cfg_workdir,
-# cfg_max_validators, cfg_jobs, cfg_preamble, cfg_signature, cfg_built_preamble
+# cfg_max_validators, cfg_jobs, cfg_preamble, cfg_signature,
+# cfg_built_preamble, cfg_disable_notifications, cfg_preserve_files
 #
 # Additionally, the following variables are set:
 #  o cfg_ownmail_local - the local portion of the ownmail address
@@ -162,6 +163,10 @@ parse_config()
 	ini_config_get_or_die cfg_signature      "$cfgfile" "global" "signature"
 	ini_config_get_or_die cfg_built_preamble "$cfgfile" "global" "built_preamble"
 
+	# Debug options
+	cfg_disable_notifications="$(ini_config_get "$cfgfile" "debug" "disable_notifications")"
+	cfg_preserve_files="$(ini_config_get "$cfgfile" "debug" "preserve_files")"
+
 	# Get the contents of the preamble file
 	cfg_preamble="$(cat "$cfg_preamble")"
 
@@ -237,7 +242,7 @@ parse_prj_config()
 
 	# The following options all take default value from the "defaults"
 	# section, and hence "override" those settings. First we need to populate those.
-	_parse_default_config "$cfgfile"
+	__parse_default_config "$cfgfile"
 
 	# ini_config_is_set is important here, so that defining a value as
 	# empty in the project section actually does define it as empty, rather
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index a9ff7ec446ca..d7400f6bd075 100755
--- a/email/aiaiai-email-test-patchset
+++ b/email/aiaiai-email-test-patchset
@@ -35,9 +35,6 @@ The mbox file containing the patches to test is expected to come from stdin
 
 Options:
   -i, --input=MBOX       use the MBOX file instead of stdin;
-  -p, --preserve         preserve all the temporary files - do not clean up;
-      --test-mode        test mode - work as usually, but do not actually
-                         send replies;
   -v, --verbose          be verbose;
   -h, --help             show this text and exit.
 EOF
@@ -50,7 +47,6 @@ fail_usage()
 	exit 1
 }
 
-preserve=
 verbose=
 mbox=
 tmpdir=
@@ -58,7 +54,7 @@ cleanup_handler()
 {
 	rm $verbose -rf -- "$mbox" >&2
 
-	if [ -n "$preserve" ]; then
+	if [ "$cfg_preserve_files" = "1" ]; then
 		verbose "Preserved tmpdir: $tmpdir"
 	else
 		[ -z "$tmpdir" ] || verbose "Removing $tmpdir";
@@ -91,10 +87,10 @@ send_email()
 
 	[ -z "$verbose" ] || cat -- "$tmpdir/mail" >&2
 
-	if [ -z "$test_mode" ]; then
+	if [ "$cfg_disable_notifications" != "1" ]; then
 		mutt -x -H "$tmpdir/mail" </dev/null
 	else
-		verbose "Do not actually send the email - we are in test mode"
+		verbose "Email nofications have been disabled in the configuration file"
 	fi
 }
 
@@ -176,12 +172,11 @@ $(cat -- $tmpdir/test-patchset.log)
 EOF
 }
 
-TEMP=`getopt -n $PROG -o i:,C:,p,v,h --long test-mode,input:,preserve,verbose,help -- "$@"` ||
+TEMP=`getopt -n $PROG -o i:,C:,p,v,h --long input:,verbose,help -- "$@"` ||
 	fail_usage ""
 eval set -- "$TEMP"
 
 mbox=
-test_mode=
 
 while true; do
 	case "$1" in
@@ -189,12 +184,6 @@ while true; do
 		mbox="$(opt_check_read "$1" "$2")"
 		shift
 		;;
-	-p|--preserve)
-		preserve="--preserve"
-		;;
-	--test-mode)
-		test_mode=y
-		;;
 	-v|--verbose) verbose=-v
 		;;
 	-h|--help)
@@ -312,7 +301,7 @@ fi
 
 # Test the path (or patch-set)
 verbose "Test configs \"$pcfg_configs\" branch \"$pcfg_branch\" of \"$pcfg_path\""
-aiaiai-test-patchset $verbose $preserve \
+aiaiai-test-patchset $verbose ${cfg_preserve_files:+--preserve} \
 	${pcfg_targets:+--targets "$pcfg_targets"} $bisectability $sparse $smatch $cppcheck $coccinelle \
 	-i "$mbox" -j "$cfg_jobs" -c "$pcfg_branch" -w "$tmpdir" \
 	${pcfg_defconfigdir:+-C "$pcfg_defconfigdir"} \
-- 
1.8.3.1




More information about the aiaiai mailing list