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 <himanshujha199640@gmail.com>
This commit is contained in:
Himanshu Jha 2018-11-19 21:35:08 +05:30 committed by Anas Nashif
parent 160c5742a4
commit 200e847ace

View File

@ -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