aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/suricata/qa/coccinelle/run_check.sh
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-09-09 22:21:41 -0700
committerAshlee Young <ashlee@onosfw.com>2015-09-09 22:21:41 -0700
commit8879b125d26e8db1a5633de5a9c692eb2d1c4f83 (patch)
treec7259d85a991b83dfa85ab2e339360669fc1f58e /framework/src/suricata/qa/coccinelle/run_check.sh
parent13d05bc8458758ee39cb829098241e89616717ee (diff)
suricata checkin based on commit id a4bce14770beee46a537eda3c3f6e8e8565d5d0a
Change-Id: I9a214fa0ee95e58fc640e50bd604dac7f42db48f
Diffstat (limited to 'framework/src/suricata/qa/coccinelle/run_check.sh')
-rwxr-xr-xframework/src/suricata/qa/coccinelle/run_check.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/framework/src/suricata/qa/coccinelle/run_check.sh b/framework/src/suricata/qa/coccinelle/run_check.sh
new file mode 100755
index 00000000..79ec9cc6
--- /dev/null
+++ b/framework/src/suricata/qa/coccinelle/run_check.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+if [ $1 ]; then
+ case $1 in
+ *[ch])
+ LIST=$@;
+ ;;
+ *..*)
+ LIST=$(git diff --pretty="format:" --name-only $1 | grep -E '[ch]$')
+ PREFIX=$(git rev-parse --show-toplevel)/
+ ;;
+ *)
+ LIST=$(git show --pretty="format:" --name-only $1 | grep -E '[ch]$')
+ PREFIX=$(git rev-parse --show-toplevel)/
+ ;;
+ esac
+else
+ LIST=$(git ls-tree -r --name-only --full-tree HEAD src/ | grep -E '*.c$')
+ PREFIX=$(git rev-parse --show-toplevel)/
+fi
+
+if [ -z "$CONCURRENCY_LEVEL" ]; then
+ CONCURRENCY_LEVEL=1
+ echo "No concurrency"
+else
+ echo "Using concurrency level $CONCURRENCY_LEVEL"
+fi
+
+for SMPL in $(git rev-parse --show-toplevel)/qa/coccinelle/*.cocci; do
+ echo "Testing cocci file: $SMPL"
+ if command -v parallel >/dev/null; then
+ echo -n $LIST | parallel -d ' ' -j $CONCURRENCY_LEVEL spatch --very-quiet -sp_file $SMPL --undefined UNITTESTS $PREFIX{} || if [ -z "$NOT_TERMINAL" ]; then exit 1; fi
+ else
+ for FILE in $LIST ; do
+ spatch --very-quiet -sp_file $SMPL --undefined UNITTESTS $PREFIX$FILE || if [ -z "$NOT_TERMINAL" ]; then exit 1; fi
+ done
+ fi
+done
+
+exit 0