From 200e847ace58644641afbc9bb562430bab7c1f2b Mon Sep 17 00:00:00 2001 From: Himanshu Jha Date: Mon, 19 Nov 2018 21:35:08 +0530 Subject: [PATCH] scripts: coccicheck: Improve continuous run operation The current implementation of continuous run operation using command `./scripts/coccicheck` i.e., without specifying any options, `coccicheck` default runs in `report` mode with all available coccinelle scripts present at `scripts/coccinelle/`. Not all scripts have report mode implemented in them, which leads to failure of coccicheck. With this new implementation we choose whatever available mode is present in coccinelle script and pass it to MODE variable without stopping continuous coverage. And perhaps if there are plans to add `coccicheck` as a sanity checker in future to the Zephyr automated CI, then certainly we want the warnings/errors produced by scripts to be less verbose to the users. Therefore, in this new implementation we prioritise the modes as: 1. report 2. context 3. patch and lastly falling to 4. org Lastly, in order to differentiate between outputs of various coccinelle scripts being run, `x------x` separator has been used to make reports mode readable. Signed-off-by: Himanshu Jha --- scripts/coccicheck | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/coccicheck b/scripts/coccicheck index 3510a8e7c53..b662006ed04 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -143,9 +143,20 @@ coccinelle () { echo "Consider adding vitrual rules to the script." exit 1 elif [[ $VIRTUAL != *"$MODE"* ]]; then - echo "Invalid mode \"$MODE\" supplied." - echo "Available modes for \"$COCCI\" are: `echo $VIRTUAL`" - exit 1 + echo "Invalid mode \"$MODE\" supplied!" + echo "Available modes for \"`basename $COCCI`\" are: "$VIRTUAL"" + + if [[ $VIRTUAL == *report* ]]; then + MODE=report + elif [[ $VIRTUAL == *context* ]]; then + MODE=context + elif [[ $VIRTUAL == *patch* ]]; then + MODE=patch + else + MODE=org + fi + echo "Using random availble mode: \"$MODE\"" + echo '' fi if [ $VERBOSE -ne 0 ] ; then @@ -201,6 +212,7 @@ coccinelle () { run_cmd_parmap $SPATCH -D $MODE $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1 fi + MODE=report } if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then @@ -215,6 +227,8 @@ fi if [ "$COCCI" = "" ] ; then for f in `find $ZEPHYR_BASE/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do coccinelle $f + echo '-------------------------------------------------------------------------' + echo '' done else coccinelle $COCCI