]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
coccinelle: improve run_check
authorEric Leblond <eric@regit.org>
Fri, 9 Nov 2012 14:57:52 +0000 (15:57 +0100)
committerEric Leblond <eric@regit.org>
Fri, 9 Nov 2012 15:17:12 +0000 (16:17 +0100)
This patch adds two features to run_check.sh, it is now posssible
to specify a list of files to check:
 ./run_check.sh ../../src/suricata.c ../../src/detect.c
It is also possible to ask a review of the files modified by a commit.
To so simply put the SHA1 as argument
 ./run_check.sh HEAD
 ./run_check 6af7d5f
It is also possible to check all the files for an arbitrary range:
 ./run_check.sh origin/master..buildbot-fixes

Last improvement of this patch is to get a real error message in case
of problem as 2 is not redirected anymore to /dev/null.

qa/coccinelle/run_check.sh

index dce88d52e544f307d951e00e266c0453c1244026..a125cdbc8557c7971cd379c4e0b33a110f068dde 100755 (executable)
@@ -1,7 +1,19 @@
 #!/bin/sh
 
 if [ $1 ]; then
-       LIST=$1;
+       case $1 in
+       *[ch])
+               LIST=$@;
+               ;;
+        *..*) 
+               LIST=$(git diff --pretty="format:" --name-only $1 | grep -E '[ch]$')
+               PREFIX="../../"
+               ;;
+       *)
+               LIST=$(git show --pretty="format:" --name-only $1 | grep -E '[ch]$')
+               PREFIX="../../"
+               ;;
+       esac
 else
        LIST=$(git ls-tree -r --name-only --full-tree  HEAD src/ | grep -E '*.c$')
        PREFIX="../../"
@@ -10,7 +22,7 @@ fi
 for SMPL in *.cocci; do
        echo "Testing cocci file: $SMPL"
        for FILE in $LIST ; do
-               spatch -sp_file $SMPL --undefined UNITTESTS  $PREFIX$FILE 2>/dev/null || exit 1;
+               spatch --very-quiet -sp_file $SMPL --undefined UNITTESTS  $PREFIX$FILE || exit 1;
        done
 done